X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fanticheat.qc;h=48c252def49ee3b9d0451fd321c2272c5dcbaae8;hb=e08b3263acb01d68bb72346b762afb0ba262ecec;hp=85bed044fb171d7569ecc0c8ed396b8991da24d9;hpb=08e08edf26f99cfb6da0470c75bb7d0cbd452958;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index 85bed044f..48c252def 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; @@ -81,8 +82,8 @@ void anticheat_physics(entity this) MEAN_ACCUMULATE(CS(this), anticheat_div0_evade, 0.5 - 0.5 * (CS(this).anticheat_div0_evade_forward_initial * v_forward), 1); } - MEAN_ACCUMULATE(CS(this), anticheat_div0_strafebot_old, movement_oddity(this.movement, CS(this).anticheat_div0_strafebot_movement_prev), 1); - CS(this).anticheat_div0_strafebot_movement_prev = this.movement; + MEAN_ACCUMULATE(CS(this), anticheat_div0_strafebot_old, movement_oddity(CS(this).movement, CS(this).anticheat_div0_strafebot_movement_prev), 1); + CS(this).anticheat_div0_strafebot_movement_prev = CS(this).movement; // Note: this actually tries to detect snap-aim. if(CS(this).anticheat_div0_strafebot_forward_prev && time > CS(this).anticheat_fixangle_endtime) { @@ -172,53 +173,52 @@ string anticheat_display(float f, float t, float tmin, float mi, float ma) return strcat(s, ":-"); } -#define ANTICHEATS(this, f) \ - f(this, "speedhack", MEAN_EVALUATE(CS(this), anticheat_speedhack), 240, 0, 9999); /* Actually this one seems broken. */ \ - f(this, "speedhack_m1", MEAN_EVALUATE(CS(this), anticheat_speedhack_m1), 240, 1.01, 1.25); \ - f(this, "speedhack_m2", MEAN_EVALUATE(CS(this), anticheat_speedhack_m2), 240, 1.01, 1.25); \ - f(this, "speedhack_m3", MEAN_EVALUATE(CS(this), anticheat_speedhack_m3), 240, 1.01, 1.25); \ - f(this, "speedhack_m4", MEAN_EVALUATE(CS(this), anticheat_speedhack_m4), 240, 1.01, 1.25); \ - f(this, "speedhack_m5", MEAN_EVALUATE(CS(this), anticheat_speedhack_m5), 240, 1.01, 1.25); \ - f(this, "div0_strafebot_old", MEAN_EVALUATE(CS(this), anticheat_div0_strafebot_old), 120, 0.15, 0.4); \ - f(this, "div0_strafebot_new", MEAN_EVALUATE(CS(this), anticheat_div0_strafebot_new), 120, 0.25, 0.8); \ - f(this, "div0_evade", MEAN_EVALUATE(CS(this), anticheat_div0_evade), 120, 0.2, 0.5); \ - f(this, "idle_snapaim", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_noise), 120, 0, 9999); \ - f(this, "idle_snapaim_signal", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_signal), 120, 0, 9999); \ - f(this, "idle_snapaim_noise", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_noise), 120, 0, 9999); \ - f(this, "idle_snapaim_m2", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m2), 120, 0, 9999); \ - f(this, "idle_snapaim_m3", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m3), 120, 0, 9999); \ - f(this, "idle_snapaim_m4", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m4), 120, 0, 9999); \ - f(this, "idle_snapaim_m7", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m7), 120, 0, 9999); \ - f(this, "idle_snapaim_m10", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m10), 120, 0, 9999) - -void anticheat_report_one_to_eventlog(entity this, string name, float f, float tmin, float mi, float ma) { - GameLogEcho(strcat(":anticheat:", name, ":", anticheat_display(f, servertime - CS(this).anticheat_jointime, tmin, mi, ma))); -} +#define ANTICHEATS(ANTICHEAT) \ + ANTICHEAT("speedhack", MEAN_EVALUATE(CS(this), anticheat_speedhack), 240, 0, 9999); /* Actually this one seems broken. */ \ + ANTICHEAT("speedhack_m1", MEAN_EVALUATE(CS(this), anticheat_speedhack_m1), 240, 1.01, 1.25); \ + ANTICHEAT("speedhack_m2", MEAN_EVALUATE(CS(this), anticheat_speedhack_m2), 240, 1.01, 1.25); \ + ANTICHEAT("speedhack_m3", MEAN_EVALUATE(CS(this), anticheat_speedhack_m3), 240, 1.01, 1.25); \ + ANTICHEAT("speedhack_m4", MEAN_EVALUATE(CS(this), anticheat_speedhack_m4), 240, 1.01, 1.25); \ + ANTICHEAT("speedhack_m5", MEAN_EVALUATE(CS(this), anticheat_speedhack_m5), 240, 1.01, 1.25); \ + ANTICHEAT("div0_strafebot_old", MEAN_EVALUATE(CS(this), anticheat_div0_strafebot_old), 120, 0.15, 0.4); \ + ANTICHEAT("div0_strafebot_new", MEAN_EVALUATE(CS(this), anticheat_div0_strafebot_new), 120, 0.25, 0.8); \ + ANTICHEAT("div0_evade", MEAN_EVALUATE(CS(this), anticheat_div0_evade), 120, 0.2, 0.5); \ + ANTICHEAT("idle_snapaim", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_signal) - MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_noise), 120, 0, 9999); \ + ANTICHEAT("idle_snapaim_signal", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_signal), 120, 0, 9999); \ + ANTICHEAT("idle_snapaim_noise", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_noise), 120, 0, 9999); \ + ANTICHEAT("idle_snapaim_m2", MEAN_EVALUATE(CS(this), anticheat_idle_snapaim_m2), 120, 0, 9999); \ + 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) void anticheat_report_to_eventlog(entity this) { if(!autocvar_sv_eventlog) return; GameLogEcho(strcat(":anticheat:_time:", ftos(this.playerid), ":", ftos(servertime - CS(this).anticheat_jointime))); - ANTICHEATS(this, anticheat_report_one_to_eventlog); -} - -void anticheat_report_one_to_playerstats(entity this, string name, float f, float tmin, float mi, float ma) { - PS_GR_P_ADDVAL(this, strcat(PLAYERSTATS_ANTICHEAT, name), f); +#define ANTICHEAT_REPORT_ONE(name, f, tmin, mi, ma) \ + GameLogEcho(strcat(":anticheat:", name, ":", anticheat_display(f, servertime - CS(this).anticheat_jointime, tmin, mi, ma))) + ANTICHEATS(ANTICHEAT_REPORT_ONE); +#undef ANTICHEAT_REPORT_ONE } void anticheat_report_to_playerstats(entity this) { - PS_GR_P_ADDVAL(this, strcat(PLAYERSTATS_ANTICHEAT, "_time"), servertime - CS(this).anticheat_jointime); - ANTICHEATS(this, anticheat_report_one_to_playerstats); + PlayerStats_GameReport_Event_Player(this, + strcat(PLAYERSTATS_ANTICHEAT, "_time"), servertime - CS(this).anticheat_jointime); +#define ANTICHEAT_REPORT_ONE(name, f, tmin, mi, ma) \ + PlayerStats_GameReport_Event_Player(this, strcat(PLAYERSTATS_ANTICHEAT, name), f) + ANTICHEATS(ANTICHEAT_REPORT_ONE); +#undef ANTICHEAT_REPORT_ONE } -#define ANTICHEAT_REGISTER_ONE_TO_PLAYERSTATS(unused_this, name, unused_f, unused_tmin, unused_mi, unused_ma) \ - PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_ANTICHEAT, name)) void anticheat_register_to_playerstats() { PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_ANTICHEAT, "_time")); - ANTICHEATS(world, ANTICHEAT_REGISTER_ONE_TO_PLAYERSTATS); +#define ANTICHEAT_REGISTER_ONE(name, unused_f, unused_tmin, unused_mi, unused_ma) \ + PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_ANTICHEAT, name)) + ANTICHEATS(ANTICHEAT_REGISTER_ONE); +#undef ANTICHEAT_REGISTER_ONE } -#undef ANTICHEAT_REGISTER_ONE_TO_PLAYERSTATS #undef ANTICHEATS void anticheat_startframe()