]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Cleanse anticheat of self
authorMario <mario@smbclan.net>
Tue, 22 Mar 2016 07:19:19 +0000 (17:19 +1000)
committerMario <mario@smbclan.net>
Tue, 22 Mar 2016 07:19:36 +0000 (17:19 +1000)
qcsrc/common/state.qc
qcsrc/server/anticheat.qc
qcsrc/server/anticheat.qh
qcsrc/server/cl_client.qc
qcsrc/server/command/sv_cmd.qc

index 226ff1ba5680135cf45db7b6db3b34d6ead38a83..0d05f195fc41c67722f51238909c3ac076bd2c3e 100644 (file)
@@ -57,7 +57,7 @@ void ClientState_attach(entity this)
 
 void bot_clientdisconnect();
 void W_HitPlotClose(entity this);
-void anticheat_report();
+void anticheat_report(entity this);
 void playerdemo_shutdown();
 void entcs_detach(entity this);
 void accuracy_free(entity this);
@@ -74,7 +74,7 @@ void ClientState_detach(entity this)
     bot_clientdisconnect();
 
     W_HitPlotClose(this);
-    anticheat_report();
+    anticheat_report(this);
     playerdemo_shutdown();
     entcs_detach(this);
     accuracy_free(self);
index 0e0121db67aae70f0460bd53679ff0f712618dbf..4861fe2a79c25cb75ca100e3ddc6b1545870d863 100644 (file)
@@ -146,15 +146,14 @@ void anticheat_physics(entity this)
        }
 }
 
-void anticheat_spectatecopy(entity spectatee)
-{SELFPARAM();
+void anticheat_spectatecopy(entity this, entity spectatee)
+{
        // div0_evade -> SPECTATORS
-       self.angles = CS(spectatee).anticheat_div0_evade_v_angle;
+       this.angles = CS(spectatee).anticheat_div0_evade_v_angle;
 }
 
-void anticheat_prethink()
+void anticheat_prethink(entity this)
 {
-    SELFPARAM();
        // div0_evade -> SPECTATORS
        CS(this).anticheat_div0_evade_offset = 0;
 }
@@ -170,52 +169,52 @@ string anticheat_display(float f, float tmin, float mi, float ma)
        return strcat(s, ":-");
 }
 
-void anticheat_report()
-{SELFPARAM();
+void anticheat_report(entity this)
+{
        if(!autocvar_sv_eventlog)
                return;
        // TODO(divVerent): Use xonstat to acquire good thresholds.
-       GameLogEcho(strcat(":anticheat:_time:", ftos(self.playerid), ":", ftos(servertime - CS(self).anticheat_jointime)));
-       GameLogEcho(strcat(":anticheat:speedhack:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack), 240, 0, 9999))); // Actually this one seems broken.
-       GameLogEcho(strcat(":anticheat:speedhack_m1:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m1), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:speedhack_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m2), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:speedhack_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m3), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:speedhack_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m4), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:speedhack_m5:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_speedhack_m5), 240, 1.01, 1.25)));
-       GameLogEcho(strcat(":anticheat:div0_strafebot_old:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_old), 120, 0.15, 0.4)));
-       GameLogEcho(strcat(":anticheat:div0_strafebot_new:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_new), 120, 0.25, 0.8)));
-       GameLogEcho(strcat(":anticheat:div0_evade:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_div0_evade), 120, 0.2, 0.5)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_signal:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_noise:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m2), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m3), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m4), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m7:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m7), 120, 0, 9999)));
-       GameLogEcho(strcat(":anticheat:idle_snapaim_m10:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m10), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:_time:", ftos(this.playerid), ":", ftos(servertime - CS(this).anticheat_jointime)));
+       GameLogEcho(strcat(":anticheat:speedhack:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_speedhack), 240, 0, 9999))); // Actually this one seems broken.
+       GameLogEcho(strcat(":anticheat:speedhack_m1:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_speedhack_m1), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:speedhack_m2:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_speedhack_m2), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:speedhack_m3:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_speedhack_m3), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:speedhack_m4:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_speedhack_m4), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:speedhack_m5:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_speedhack_m5), 240, 1.01, 1.25)));
+       GameLogEcho(strcat(":anticheat:div0_strafebot_old:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_div0_strafebot_old), 120, 0.15, 0.4)));
+       GameLogEcho(strcat(":anticheat:div0_strafebot_new:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_div0_strafebot_new), 120, 0.25, 0.8)));
+       GameLogEcho(strcat(":anticheat:div0_evade:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_div0_evade), 120, 0.2, 0.5)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_noise), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_signal:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_signal), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_noise:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_noise), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m2:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m2), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m3:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m3), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m4:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m4), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m7:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m7), 120, 0, 9999)));
+       GameLogEcho(strcat(":anticheat:idle_snapaim_m10:", ftos(this.playerid), ":", anticheat_display(MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m10), 120, 0, 9999)));
 }
 
-float anticheat_getvalue(string id)
-{SELFPARAM();
+float anticheat_getvalue(entity this, string id)
+{
        switch(id) {
-               case "_time": return servertime - CS(self).anticheat_jointime;
-               case "speedhack": return MEAN_EVALUATE(CS(self), anticheat_speedhack);
-               case "speedhack_m1": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m1);
-               case "speedhack_m2": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m2);
-               case "speedhack_m3": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m3);
-               case "speedhack_m4": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m4);
-               case "speedhack_m5": return MEAN_EVALUATE(CS(self), anticheat_speedhack_m5);
-               case "div0_strafebot_old": return MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_old);
-               case "div0_strafebot_new": return MEAN_EVALUATE(CS(self), anticheat_div0_strafebot_new);
-               case "div0_evade": return MEAN_EVALUATE(CS(self), anticheat_div0_evade);
-               case "idle_snapaim": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise);
-               case "idle_snapaim_signal": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_signal);
-               case "idle_snapaim_noise": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_noise);
-               case "idle_snapaim_m2": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m2);
-               case "idle_snapaim_m3": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m3);
-               case "idle_snapaim_m4": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m4);
-               case "idle_snapaim_m7": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m7);
-               case "idle_snapaim_m10": return MEAN_EVALUATE(CS(self), anticheat_idle_snapaim_m10);
+               case "_time": return servertime - CS(this).anticheat_jointime;
+               case "speedhack": return MEAN_EVALUATE(CS(this), anticheat_speedhack);
+               case "speedhack_m1": return MEAN_EVALUATE(CS(this), anticheat_speedhack_m1);
+               case "speedhack_m2": return MEAN_EVALUATE(CS(this), anticheat_speedhack_m2);
+               case "speedhack_m3": return MEAN_EVALUATE(CS(this), anticheat_speedhack_m3);
+               case "speedhack_m4": return MEAN_EVALUATE(CS(this), anticheat_speedhack_m4);
+               case "speedhack_m5": return MEAN_EVALUATE(CS(this), anticheat_speedhack_m5);
+               case "div0_strafebot_old": return MEAN_EVALUATE(CS(this), anticheat_div0_strafebot_old);
+               case "div0_strafebot_new": return MEAN_EVALUATE(CS(this), anticheat_div0_strafebot_new);
+               case "div0_evade": return MEAN_EVALUATE(CS(this), anticheat_div0_evade);
+               case "idle_snapaim": return MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_noise);
+               case "idle_snapaim_signal": return MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_signal);
+               case "idle_snapaim_noise": return MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_noise);
+               case "idle_snapaim_m2": return MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m2);
+               case "idle_snapaim_m3": return MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m3);
+               case "idle_snapaim_m4": return MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m4);
+               case "idle_snapaim_m7": return MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m7);
+               case "idle_snapaim_m10": return MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m10);
        }
        return -1;
 }
@@ -231,7 +230,7 @@ void anticheat_fixangle(entity this)
 }
 
 void anticheat_endframe()
-{SELFPARAM();
+{
        FOREACH_CLIENT(it.fixangle, anticheat_fixangle(it));
        anticheat_div0_evade_evasion_delta += frametime * (0.5 + random());
 }
index c3e99078db66a72c6a658b582424466e58ce80f3..2b0522b991fb25747ce48c06003cf4433c74e30d 100644 (file)
@@ -1,13 +1,13 @@
 #pragma once
 
 void anticheat_init(entity this);
-void anticheat_report();
+void anticheat_report(entity this);
 
 void anticheat_physics(entity this);
-void anticheat_spectatecopy(entity spectatee);
-void anticheat_prethink();
+void anticheat_spectatecopy(entity this, entity spectatee);
+void anticheat_prethink(entity this);
 
-float anticheat_getvalue(string name);
+float anticheat_getvalue(entity this, string name);
 
 void anticheat_startframe();
 void anticheat_endframe();
index f37e806ec3eca06d3554eca4d46ac2fed3b24e40..c13d372607bd3fb172f84401f15df4aaef8fd503 100644 (file)
@@ -1586,7 +1586,7 @@ void SpectateCopy(entity this, entity spectatee)
        setsize(this, spectatee.mins, spectatee.maxs);
        SetZoomState(spectatee.zoomstate);
 
-    anticheat_spectatecopy(spectatee);
+    anticheat_spectatecopy(this, spectatee);
        this.hud = spectatee.hud;
        if(spectatee.vehicle)
     {
@@ -2046,7 +2046,7 @@ void PlayerPreThink ()
        if(frametime)
        {
                // physics frames: update anticheat stuff
-               anticheat_prethink();
+               anticheat_prethink(self);
        }
 
        if(blockSpectators && frametime)
index b48844d20dd780420cf0ad3ede27ffbf5691a3b5..75f63b71f60a17e0e2b0e470d28c1427deaac77c 100644 (file)
@@ -230,7 +230,7 @@ void GameCommand_anticheat(float request, float argc)
 
                        if (accepted > 0)
                        {
-                               WITH(entity, self, client, anticheat_report());
+                               anticheat_report(client);
                                return;
                        }
                        else