X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fanticheat.qc;h=32742d82d9555e41330fa559acbee64314a1b7f3;hb=a97b89297fa91ae42b9d56c262662eb34ede3e45;hp=9a1872c89fadfb68d651babe38a85097dd1b9091;hpb=75f257c5016b7a4bf92a2c737a81273d6b258371;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index 9a1872c89..32742d82d 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -1,29 +1,17 @@ -.float anticheat_jointime; +#include "anticheat.qh" -void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight) -{ - if(weight == 0) - return; - if(mean == 0) - e.a *= pow(value, weight); - else - e.a += pow(value, mean) * weight; - e.c += weight; -} +#include "antilag.qh" +#include "autocvars.qh" +#include "defs.qh" +#include "miscfunctions.qh" + +#include "../dpdefs/progsdefs.qh" +#include "../dpdefs/dpextensions.qh" -float mean_evaluate(entity e, .float a, .float c, float mean) -{ - if(e.c == 0) - return 0; - if(mean == 0) - return pow(e.a, 1.0 / e.c); - else - return pow(e.a / e.c, 1.0 / mean); -} -#define MEAN_ACCUMULATE(prefix,v,w) mean_accumulate(self,prefix##_accumulator,prefix##_count,prefix##_mean,v,w) -#define MEAN_EVALUATE(prefix) mean_evaluate(self,prefix##_accumulator,prefix##_count,prefix##_mean) -#define MEAN_DECLARE(prefix,m) float prefix##_mean = m; .float prefix##_count, prefix##_accumulator +#include "command/common.qh" + +.float anticheat_jointime; .float anticheat_fixangle_endtime; @@ -75,9 +63,8 @@ float movement_oddity(vector m0, vector m1) } void anticheat_physics() -{ - float f, wishspeed; - vector wishvel; +{SELFPARAM(); + float f; // div0_evade -> SPECTATORS makevectors(self.v_angle); @@ -160,62 +147,16 @@ void anticheat_physics() self.anticheat_speedhack_accu = 1; self.anticheat_speedhack_lasttime = servertime; } - - // race/CTS: force kbd movement for fairness - if(g_race || g_cts) - { - // if record times matter - // ensure nothing EVIL is being done (i.e. div0_evade) - // this hinders joystick users though - // but it still gives SOME analog control - wishvel_x = fabs(self.movement_x); - wishvel_y = fabs(self.movement_y); - if(wishvel_x != 0 && wishvel_y != 0 && wishvel_x != wishvel_y) - { - wishvel_z = 0; - wishspeed = vlen(wishvel); - if(wishvel_x >= 2 * wishvel_y) - { - // pure X motion - if(self.movement_x > 0) - self.movement_x = wishspeed; - else - self.movement_x = -wishspeed; - self.movement_y = 0; - } - else if(wishvel_y >= 2 * wishvel_x) - { - // pure Y motion - self.movement_x = 0; - if(self.movement_y > 0) - self.movement_y = wishspeed; - else - self.movement_y = -wishspeed; - } - else - { - // diagonal - if(self.movement_x > 0) - self.movement_x = M_SQRT1_2 * wishspeed; - else - self.movement_x = -M_SQRT1_2 * wishspeed; - if(self.movement_y > 0) - self.movement_y = M_SQRT1_2 * wishspeed; - else - self.movement_y = -M_SQRT1_2 * wishspeed; - } - } - } } void anticheat_spectatecopy(entity spectatee) -{ +{SELFPARAM(); // div0_evade -> SPECTATORS self.angles = spectatee.anticheat_div0_evade_v_angle; } void anticheat_prethink() -{ +{SELFPARAM(); // div0_evade -> SPECTATORS self.anticheat_div0_evade_offset = 0; } @@ -232,32 +173,32 @@ string anticheat_display(float f, float tmin, float mi, float ma) } void anticheat_report() -{ +{SELFPARAM(); if(!autocvar_sv_eventlog) return; // TODO(divVerent): Use xonstat to acquire good thresholds. GameLogEcho(strcat(":anticheat:_time:", ftos(self.playerid), ":", ftos(servertime - self.anticheat_jointime))); - GameLogEcho(strcat(":anticheat:speedhack:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack), 240, 0.1, 0.15))); - GameLogEcho(strcat(":anticheat:speedhack_m1:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m1), 240, 0.1, 0.15))); - GameLogEcho(strcat(":anticheat:speedhack_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m2), 240, 0.1, 0.15))); - GameLogEcho(strcat(":anticheat:speedhack_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m3), 240, 0.1, 0.15))); - GameLogEcho(strcat(":anticheat:speedhack_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m4), 240, 0.1, 0.15))); - GameLogEcho(strcat(":anticheat:speedhack_m5:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m5), 240, 0.1, 0.15))); - GameLogEcho(strcat(":anticheat:div0_strafebot_old:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_div0_strafebot_old), 120, 0.3, 0.4))); - GameLogEcho(strcat(":anticheat:div0_strafebot_new:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_div0_strafebot_new), 120, 0.3, 0.4))); - GameLogEcho(strcat(":anticheat:div0_evade:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_div0_evade), 120, 0.1, 0.2))); - GameLogEcho(strcat(":anticheat:idle_snapaim:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_signal) - MEAN_EVALUATE(anticheat_idle_snapaim_noise), 120, 0.1, 0.2))); - GameLogEcho(strcat(":anticheat:idle_snapaim_signal:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_signal), 120, 0.1, 0.2))); - GameLogEcho(strcat(":anticheat:idle_snapaim_noise:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_noise), 120, 0.1, 0.2))); - GameLogEcho(strcat(":anticheat:idle_snapaim_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m2), 120, 0.1, 0.2))); - GameLogEcho(strcat(":anticheat:idle_snapaim_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m3), 120, 0.1, 0.2))); - GameLogEcho(strcat(":anticheat:idle_snapaim_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m4), 120, 0.1, 0.2))); - GameLogEcho(strcat(":anticheat:idle_snapaim_m7:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m7), 120, 0.1, 0.2))); - GameLogEcho(strcat(":anticheat:idle_snapaim_m10:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m10), 120, 0.1, 0.2))); + GameLogEcho(strcat(":anticheat:speedhack:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack), 240, 0, 9999))); // Actually this one seems broken. + GameLogEcho(strcat(":anticheat:speedhack_m1:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m1), 240, 1.01, 1.25))); + GameLogEcho(strcat(":anticheat:speedhack_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m2), 240, 1.01, 1.25))); + GameLogEcho(strcat(":anticheat:speedhack_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m3), 240, 1.01, 1.25))); + GameLogEcho(strcat(":anticheat:speedhack_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m4), 240, 1.01, 1.25))); + GameLogEcho(strcat(":anticheat:speedhack_m5:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_speedhack_m5), 240, 1.01, 1.25))); + GameLogEcho(strcat(":anticheat:div0_strafebot_old:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_div0_strafebot_old), 120, 0.15, 0.4))); + GameLogEcho(strcat(":anticheat:div0_strafebot_new:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_div0_strafebot_new), 120, 0.25, 0.8))); + GameLogEcho(strcat(":anticheat:div0_evade:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_div0_evade), 120, 0.2, 0.5))); + GameLogEcho(strcat(":anticheat:idle_snapaim:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_signal) - MEAN_EVALUATE(anticheat_idle_snapaim_noise), 120, 0, 9999))); + GameLogEcho(strcat(":anticheat:idle_snapaim_signal:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_signal), 120, 0, 9999))); + GameLogEcho(strcat(":anticheat:idle_snapaim_noise:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_noise), 120, 0, 9999))); + GameLogEcho(strcat(":anticheat:idle_snapaim_m2:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m2), 120, 0, 9999))); + GameLogEcho(strcat(":anticheat:idle_snapaim_m3:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m3), 120, 0, 9999))); + GameLogEcho(strcat(":anticheat:idle_snapaim_m4:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m4), 120, 0, 9999))); + GameLogEcho(strcat(":anticheat:idle_snapaim_m7:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m7), 120, 0, 9999))); + GameLogEcho(strcat(":anticheat:idle_snapaim_m10:", ftos(self.playerid), ":", anticheat_display(MEAN_EVALUATE(anticheat_idle_snapaim_m10), 120, 0, 9999))); } float anticheat_getvalue(string id) -{ +{SELFPARAM(); switch(id) { case "_time": return servertime - self.anticheat_jointime; case "speedhack": return MEAN_EVALUATE(anticheat_speedhack); @@ -287,22 +228,22 @@ void anticheat_startframe() } void anticheat_fixangle() -{ +{SELFPARAM(); self.anticheat_fixangle_endtime = servertime + ANTILAG_LATENCY(self) + 0.2; } void anticheat_endframe() -{ - entity oldself = self; - FOR_EACH_CLIENT(self) - if (self.fixangle) - anticheat_fixangle(); - self = oldself; +{SELFPARAM(); + entity e; + FOR_EACH_CLIENT(e) + if (e.fixangle) { + WITH(entity, self, e, anticheat_fixangle()); + } anticheat_div0_evade_evasion_delta += frametime * (0.5 + random()); } void anticheat_init() -{ +{SELFPARAM(); self.anticheat_speedhack_offset = 0; self.anticheat_jointime = servertime; }