X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fanticheat.qc;h=a818df3eb6ec8e2b45eff3e12fd12a4e7c49b790;hb=9375a0a0df0b5753b14de78cbde928547fb45ad3;hp=7173ae5970721388811a5f639476540732851b54;hpb=46682a49ba71f1664e5625fe2d9c3be5e95db901;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index 7173ae597..a818df3eb 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -1,13 +1,14 @@ #include "anticheat.qh" -#include "antilag.qh" -#include "autocvars.qh" -#include "defs.qh" -#include "miscfunctions.qh" - -#include "command/common.qh" #include #include +#include +#include +#include +#include +#include +#include +#include .float anticheat_jointime; @@ -25,6 +26,9 @@ MEAN_DECLARE(anticheat_div0_strafebot_old, 5); .vector anticheat_div0_strafebot_forward_prev; MEAN_DECLARE(anticheat_div0_strafebot_new, 5); +.vector anticheat_div0_snapback_prev; +MEAN_DECLARE(anticheat_div0_snapback, 5); + // Snap-aim detection: we track the average angular speed of aiming over time, in "radians per second". // Signal: a high-power mean. Cheaters will have high "signal" here. // Noise: a low-power mean. Active/shivery players will have high "noise" here. @@ -108,6 +112,18 @@ void anticheat_physics(entity this) MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m4, anglespeed, dt); MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m7, anglespeed, dt); MEAN_ACCUMULATE(CS(this), anticheat_idle_snapaim_m10, anglespeed, dt); + + // Detect snapping _back_. + float f = bound(0, dt * 4, 1); // About 0.25 seconds horizon for snapping back. + vector aim_move = v_forward - CS(this).anticheat_div0_strafebot_forward_prev; + vector snapback_prev = CS(this).anticheat_div0_snapback_prev; + float snapback_len = vlen(snapback_prev); + if (snapback_len != 0) { + float aim_snap = max(0, (aim_move * snapback_prev) / -snapback_len); + // Scales with aim_move, but is positive only when snapping back, otherwise zero. + MEAN_ACCUMULATE(CS(this), anticheat_div0_snapback, aim_snap, dt); + } + CS(this).anticheat_div0_snapback_prev = snapback_prev * (1 - f) + aim_move * f; } } CS(this).anticheat_div0_strafebot_forward_prev = v_forward; @@ -189,7 +205,8 @@ string anticheat_display(float f, float t, float tmin, float mi, float ma) ANTICHEAT("idle_snapaim_m3", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m3), 120, 0, 9999); \ ANTICHEAT("idle_snapaim_m4", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m4), 120, 0, 9999); \ ANTICHEAT("idle_snapaim_m7", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m7), 120, 0, 9999); \ - ANTICHEAT("idle_snapaim_m10", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m10), 120, 0, 9999) + ANTICHEAT("idle_snapaim_m10", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m10), 120, 0, 9999); \ + ANTICHEAT("div0_snapback", MEAN_EVALUATE(CS(this), anticheat_div0_snapback), 120, 0, 9999) void anticheat_report_to_eventlog(entity this) { if(!autocvar_sv_eventlog) @@ -202,9 +219,10 @@ void anticheat_report_to_eventlog(entity this) { } void anticheat_report_to_playerstats(entity this) { - PS_GR_P_ADDVAL(this, strcat(PLAYERSTATS_ANTICHEAT, "_time"), servertime - CS(this).anticheat_jointime); + PlayerStats_GameReport_Event_Player(this, + strcat(PLAYERSTATS_ANTICHEAT, "_time"), servertime - CS(this).anticheat_jointime); #define ANTICHEAT_REPORT_ONE(name, f, tmin, mi, ma) \ - PS_GR_P_ADDVAL(this, strcat(PLAYERSTATS_ANTICHEAT, name), f) + PlayerStats_GameReport_Event_Player(this, strcat(PLAYERSTATS_ANTICHEAT, name), f) ANTICHEATS(ANTICHEAT_REPORT_ONE); #undef ANTICHEAT_REPORT_ONE }