]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/physics/player.qc
Merge branch 'master' into martin-t/okc
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / player.qc
index 47249356bb564fb42504b4e0d6047fe71eec1512..20e2d4cc32f16d0b736e421d0a1172262492ff7c 100644 (file)
@@ -15,9 +15,9 @@ bool Physics_Valid(string thecvar)
 
 float Physics_ClientOption(entity this, string option, float defaultval)
 {
-       if(IS_REAL_CLIENT(this) && Physics_Valid(this.cvar_cl_physics))
+       if(IS_REAL_CLIENT(this) && Physics_Valid(CS(this).cvar_cl_physics))
        {
-               string s = strcat("g_physics_", this.cvar_cl_physics, "_", option);
+               string s = strcat("g_physics_", CS(this).cvar_cl_physics, "_", option);
                if(cvar_type(s) & CVAR_TYPEFLAG_EXISTS)
                        return cvar(s);
        }
@@ -30,8 +30,14 @@ float Physics_ClientOption(entity this, string option, float defaultval)
        return defaultval;
 }
 
-void Physics_UpdateStats(entity this, float maxspd_mod)
+void Physics_UpdateStats(entity this)
 {
+       // update this first, as it's used on all stats (wouldn't want to update them all manually from a mutator hook now, would we?)
+       STAT(MOVEVARS_HIGHSPEED, this) = autocvar_g_movement_highspeed;
+
+       MUTATOR_CALLHOOK(PlayerPhysics_UpdateStats, this);
+       float maxspd_mod = PHYS_HIGHSPEED(this);
+
        STAT(MOVEVARS_AIRACCEL_QW, this) = AdjustAirAccelQW(Physics_ClientOption(this, "airaccel_qw", autocvar_sv_airaccel_qw), maxspd_mod);
        STAT(MOVEVARS_AIRSTRAFEACCEL_QW, this) = (Physics_ClientOption(this, "airstrafeaccel_qw", autocvar_sv_airstrafeaccel_qw))
                ? AdjustAirAccelQW(Physics_ClientOption(this, "airstrafeaccel_qw", autocvar_sv_airstrafeaccel_qw), maxspd_mod)
@@ -427,7 +433,7 @@ void CheckWaterJump(entity this)
 
 
 #ifdef SVQC
-       #define JETPACK_JUMP(s) s.cvar_cl_jetpack_jump
+       #define JETPACK_JUMP(s) CS(s).cvar_cl_jetpack_jump
 #elif defined(CSQC)
        float autocvar_cl_jetpack_jump;
        #define JETPACK_JUMP(s) autocvar_cl_jetpack_jump
@@ -482,8 +488,13 @@ string specialcommand = "xwxwxsxsxaxdxaxdx1x ";
 .float specialcommand_pos;
 void SpecialCommand(entity this)
 {
-       if (!CheatImpulse(this, CHIMPULSE_GIVE_ALL.impulse))
-               LOG_INFO("A hollow voice says \"Plugh\".\n");
+       if(autocvar_sv_cheats || this.maycheat)
+       {
+               if (!CheatImpulse(this, CHIMPULSE_GIVE_ALL.impulse))
+                       LOG_INFO("A hollow voice says \"Plugh\".");
+       }
+       else
+               STAT(MOVEVARS_SPECIALCOMMAND, this) = true;
 }
 #endif
 
@@ -508,18 +519,18 @@ bool PM_check_specialcommand(entity this, int buttons)
        else
                c = "?";
 
-       if (c == substring(specialcommand, this.specialcommand_pos, 1))
+       if (c == substring(specialcommand, CS(this).specialcommand_pos, 1))
        {
-               this.specialcommand_pos += 1;
-               if (this.specialcommand_pos >= strlen(specialcommand))
+               CS(this).specialcommand_pos += 1;
+               if (CS(this).specialcommand_pos >= strlen(specialcommand))
                {
-                       this.specialcommand_pos = 0;
+                       CS(this).specialcommand_pos = 0;
                        SpecialCommand(this);
                        return true;
                }
        }
-       else if (this.specialcommand_pos && (c != substring(specialcommand, this.specialcommand_pos - 1, 1)))
-               this.specialcommand_pos = 0;
+       else if (CS(this).specialcommand_pos && (c != substring(specialcommand, CS(this).specialcommand_pos - 1, 1)))
+               CS(this).specialcommand_pos = 0;
 #endif
        return false;
 }
@@ -802,7 +813,8 @@ void CSQC_ClientMovement_PlayerMove_Frame(entity this)
 {
 #ifdef SVQC
        // needs to be called before physics are run!
-       PM_UpdateButtons(this, CS(this));
+       if(IS_REAL_CLIENT(this))
+               PM_UpdateButtons(this, CS(this));
 #endif
 
        sys_phys_update(this, PHYS_INPUT_TIMELENGTH);