]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/physics/player.qc
Consolidates a few of the networked stats to free up some slots. Also removes an...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / player.qc
index ade9c4d6f8acc5a90f0411b680ab4ab34467dcf5..d562ab64bde15bffc3923e8e385553bd59fbdc64 100644 (file)
@@ -1,14 +1,12 @@
 #include "player.qh"
-#include "../mapobjects/_mod.qh"
-#include "../viewloc.qh"
 
-#ifdef SVQC
+#include <common/mapobjects/_mod.qh>
+#include <common/viewloc.qh>
 
-#include <server/client.qh>
-#include <server/miscfunctions.qh>
+#ifdef SVQC
 #include <common/mapobjects/defs.qh>
-#include "../mapobjects/trigger/viewloc.qh"
-#include <server/main.qh>
+#include <common/mapobjects/trigger/viewloc.qh>
+#include <server/client.qh>
 
 // client side physics
 bool Physics_Valid(string thecvar)
@@ -21,9 +19,9 @@ float Physics_ClientOption(entity this, string option, float defaultval)
        if(!autocvar_g_physics_clientselect)
                return defaultval;
 
-       if(IS_REAL_CLIENT(this) && Physics_Valid(CS(this).cvar_cl_physics))
+       if(IS_REAL_CLIENT(this) && Physics_Valid(CS_CVAR(this).cvar_cl_physics))
        {
-               string s = strcat("g_physics_", CS(this).cvar_cl_physics, "_", option);
+               string s = strcat("g_physics_", CS_CVAR(this).cvar_cl_physics, "_", option);
                if(cvar_type(s) & CVAR_TYPEFLAG_EXISTS)
                        return cvar(s);
        }
@@ -424,9 +422,6 @@ bool PlayerJump(entity this)
        SET_JUMP_HELD(this);
 
 #ifdef SVQC
-
-       this.oldvelocity_z = this.velocity_z;
-
        animdecide_setaction(this, ANIMACTION_JUMP, true);
 
        if (autocvar_g_jump_grunt)
@@ -455,6 +450,7 @@ void CheckWaterJump(entity this)
                {       // open at eye level
                        this.velocity_z = 225;
                        this.flags |= FL_WATERJUMP;
+                       this.teleport_time = time + 2; // safety net
                        SET_JUMP_HELD(this);
                }
        }
@@ -462,7 +458,7 @@ void CheckWaterJump(entity this)
 
 
 #ifdef SVQC
-       #define JETPACK_JUMP(s) CS(s).cvar_cl_jetpack_jump
+       #define JETPACK_JUMP(s) CS_CVAR(s).cvar_cl_jetpack_jump
 #elif defined(CSQC)
        float autocvar_cl_jetpack_jump;
        #define JETPACK_JUMP(s) autocvar_cl_jetpack_jump
@@ -522,8 +518,6 @@ void SpecialCommand(entity this)
                if (!CheatImpulse(this, CHIMPULSE_GIVE_ALL.impulse))
                        LOG_INFO("A hollow voice says \"Plugh\".");
        }
-       else
-               STAT(MOVEVARS_SPECIALCOMMAND, this) = true;
 }
 #endif
 
@@ -531,22 +525,18 @@ bool PM_check_specialcommand(entity this, int buttons)
 {
 #ifdef SVQC
        string c;
-       if (!buttons)
-               c = "x";
-       else if (buttons == 1)
-               c = "1";
-       else if (buttons == 2)
-               c = " ";
-       else if (buttons == 128)
-               c = "s";
-       else if (buttons == 256)
-               c = "w";
-       else if (buttons == 512)
-               c = "a";
-       else if (buttons == 1024)
-               c = "d";
-       else
-               c = "?";
+       switch (buttons)
+       {
+               // buttons mapped in PHYS_INPUT_BUTTON_MASK
+               case 0: c = "x"; break;
+               case BIT(0): c = "1"; break;
+               case BIT(2): c = " "; break;
+               case BIT(7): c = "s"; break;
+               case BIT(8): c = "w"; break;
+               case BIT(9): c = "a"; break;
+               case BIT(10): c = "d"; break;
+               default: c = "?";
+       }
 
        if (c == substring(specialcommand, CS(this).specialcommand_pos, 1))
        {
@@ -653,7 +643,7 @@ void PM_check_hitground(entity this)
 void PM_Footsteps(entity this)
 {
 #ifdef SVQC
-       if (!g_footsteps) return;
+       if (!autocvar_g_footsteps) return;
        if (IS_DUCKED(this)) return;
        if (time >= this.lastground + 0.2) return;
        if (vdist(this.velocity, <=, autocvar_sv_maxspeed * 0.6)) return;