X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fanticheat.qc;h=32742d82d9555e41330fa559acbee64314a1b7f3;hb=a97b89297fa91ae42b9d56c262662eb34ede3e45;hp=a9d7fa8c8550564a776d84e78706f4b2b9232c24;hpb=ba0988ca930f50286f8cf3b6c114ebc6584964af;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index a9d7fa8c8..32742d82d 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -1,42 +1,17 @@ -#if defined(CSQC) -#elif defined(MENUQC) -#elif defined(SVQC) - #include "../dpdefs/progsdefs.qc" - #include "../dpdefs/dpextensions.qc" - #include "sys-post.qh" - #include "../warpzonelib/mathlib.qh" - #include "autocvars.qh" - #include "defs.qh" - #include "command/common.qh" - #include "anticheat.qh" -#endif +#include "anticheat.qh" -.float anticheat_jointime; +#include "antilag.qh" +#include "autocvars.qh" +#include "defs.qh" +#include "miscfunctions.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 "../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; @@ -88,7 +63,7 @@ float movement_oddity(vector m0, vector m1) } void anticheat_physics() -{ +{SELFPARAM(); float f; // div0_evade -> SPECTATORS @@ -175,13 +150,13 @@ void anticheat_physics() } 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; } @@ -198,7 +173,7 @@ 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. @@ -223,7 +198,7 @@ void anticheat_report() } float anticheat_getvalue(string id) -{ +{SELFPARAM(); switch(id) { case "_time": return servertime - self.anticheat_jointime; case "speedhack": return MEAN_EVALUATE(anticheat_speedhack); @@ -253,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; }