]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
runstandardplayerphysics: also implement the no-args case
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 26 Nov 2011 11:51:58 +0000 (11:51 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 26 Nov 2011 11:52:03 +0000 (12:52 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11578 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=4b91503dea08798bc9e5275421482be1d390cea4

clvm_cmds.c
prvm_offsets.h

index 8647ff23e918fdeae381bb20e2917194485fd8ee..a07cee7a152ab91f2bf6cb455951ae5e5a6e4687 100644 (file)
@@ -1455,33 +1455,61 @@ static void VM_CL_runplayerphysics (prvm_prog_t *prog)
        cl_clientmovement_state_t s;
        prvm_edict_t *ent;
 
-       VM_SAFEPARMCOUNT(1, VM_CL_runplayerphysics);
+       VM_SAFEPARMCOUNTRANGE(0, 1, VM_CL_runplayerphysics);
+
+       ent = (prog->argc == 1 ? PRVM_G_EDICT(OFS_PARM0) : prog->edicts);
+       if(ent == prog->edicts)
+       {
+               // deprecated use
+               VectorCopy(PRVM_clientglobalvector(pmove_org), s.origin);
+               VectorCopy(PRVM_clientglobalvector(pmove_vel), s.velocity);
+               VectorCopy(PRVM_clientglobalvector(pmove_mins), s.mins);
+               VectorCopy(PRVM_clientglobalvector(pmove_maxs), s.maxs);
+               s.crouched = 0;
+               s.waterjumptime = PRVM_clientglobalfloat(pmove_waterjumptime);
+               s.cmd.canjump = (int)PRVM_clientglobalfloat(pmove_jump_held) == 0;
+       }
+       else
+       {
+               // new use
+               VectorCopy(PRVM_clientedictvector(ent, origin), s.origin);
+               VectorCopy(PRVM_clientedictvector(ent, velocity), s.velocity);
+               VectorCopy(PRVM_clientedictvector(ent, mins), s.mins);
+               VectorCopy(PRVM_clientedictvector(ent, maxs), s.maxs);
+               s.crouched = ((int)PRVM_clientedictfloat(ent, pmove_flags) & PMF_DUCKED) != 0;
+               s.waterjumptime = 0; // FIXME where do we get this from? FTEQW lacks support for this too
+               s.cmd.canjump = ((int)PRVM_clientedictfloat(ent, pmove_flags) & PMF_JUMP_HELD) == 0;
+       }
 
-       ent = PRVM_G_EDICT(OFS_PARM0);
-       VectorCopy(PRVM_clientedictvector(ent, origin), s.origin);
-       VectorCopy(PRVM_clientedictvector(ent, velocity), s.velocity);
-       VectorCopy(PRVM_clientedictvector(ent, mins), s.mins);
-       VectorCopy(PRVM_clientedictvector(ent, maxs), s.maxs);
-       s.crouched = ((int)PRVM_clientedictfloat(ent, pmove_flags) & PMF_DUCKED) != 0;
-       s.waterjumptime = 0; // FIXME where do we get this from? FTEQW lacks support for this too
        VectorCopy(PRVM_clientglobalvector(input_angles), s.cmd.viewangles);
        s.cmd.forwardmove = PRVM_clientglobalvector(input_movevalues)[0];
        s.cmd.sidemove = PRVM_clientglobalvector(input_movevalues)[1];
        s.cmd.upmove = PRVM_clientglobalvector(input_movevalues)[2];
        s.cmd.buttons = PRVM_clientglobalfloat(input_buttons);
        s.cmd.frametime = PRVM_clientglobalfloat(input_timelength);
-       s.cmd.canjump = ((int)PRVM_clientedictfloat(ent, pmove_flags) & PMF_JUMP_HELD) == 0;
        s.cmd.jump = (s.cmd.buttons & 2) != 0;
        s.cmd.crouch = (s.cmd.buttons & 16) != 0;
 
        CL_ClientMovement_PlayerMove(&s);
 
-       VectorCopy(s.origin, PRVM_clientedictvector(ent, origin));
-       VectorCopy(s.velocity, PRVM_clientedictvector(ent, velocity));
-       PRVM_clientedictfloat(ent, pmove_flags) =
-               (s.crouched ? PMF_DUCKED : 0) |
-               (s.cmd.canjump ? 0 : PMF_JUMP_HELD) |
-               (s.onground ? PMF_ONGROUND : 0);
+       if(ent == prog->edicts)
+       {
+               // deprecated use
+               VectorCopy(s.origin, PRVM_clientglobalvector(pmove_org));
+               VectorCopy(s.velocity, PRVM_clientglobalvector(pmove_vel));
+               PRVM_clientglobalfloat(pmove_jump_held) = !s.cmd.canjump;
+               PRVM_clientglobalfloat(pmove_waterjumptime) = s.waterjumptime;
+       }
+       else
+       {
+               // new use
+               VectorCopy(s.origin, PRVM_clientedictvector(ent, origin));
+               VectorCopy(s.velocity, PRVM_clientedictvector(ent, velocity));
+               PRVM_clientedictfloat(ent, pmove_flags) =
+                       (s.crouched ? PMF_DUCKED : 0) |
+                       (s.cmd.canjump ? 0 : PMF_JUMP_HELD) |
+                       (s.onground ? PMF_ONGROUND : 0);
+       }
 }
 
 //#348 string(float playernum, string keyname) getplayerkeyvalue (EXT_CSQC)
index 09ac75edcc95298ae85aba795704ffcc443cfc39..639240ea52305c0a2a7d221cb217f7f8285ec060 100644 (file)
@@ -186,6 +186,8 @@ PRVM_DECLARE_clientglobalvector(pmove_inwater)
 PRVM_DECLARE_clientglobalvector(pmove_maxs)
 PRVM_DECLARE_clientglobalvector(pmove_mins)
 PRVM_DECLARE_clientglobalvector(pmove_onground)
+PRVM_DECLARE_clientglobalfloat(pmove_waterjumptime)
+PRVM_DECLARE_clientglobalfloat(pmove_jump_held)
 PRVM_DECLARE_clientglobalvector(pmove_org)
 PRVM_DECLARE_clientglobalvector(pmove_vel)
 PRVM_DECLARE_clientglobalvector(trace_endpos)
@@ -522,6 +524,8 @@ PRVM_DECLARE_global(pmove_inwater)
 PRVM_DECLARE_global(pmove_maxs)
 PRVM_DECLARE_global(pmove_mins)
 PRVM_DECLARE_global(pmove_onground)
+PRVM_DECLARE_global(pmove_waterjumptime)
+PRVM_DECLARE_global(pmove_jump_held)
 PRVM_DECLARE_global(pmove_org)
 PRVM_DECLARE_global(pmove_vel)
 PRVM_DECLARE_global(require_spawnfunc_prefix)