From: drjaska Date: Wed, 4 Sep 2024 09:51:31 +0000 (+0300) Subject: Allow logless cheat legality checks X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f857ae3a13e14de5c0bc47a87c330f066864ca60;p=xonotic%2Fxonotic-data.pk3dir.git Allow logless cheat legality checks --- diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 9ec7cc69a..67f2f1e14 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -54,14 +54,15 @@ void CheatShutdown() { } -float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets passed as argument for possible future ACL checking +// the cheat gets passed as argument for possible future ACL checking +float CheatsAllowed(entity this, float imp, int argc, float cheatframe, bool logattempt, bool ignoredead) { - if(IS_DEAD(this)) + if(!ignoredead && IS_DEAD(this)) return 0; if(gamestart_sv_cheats < 2 && !IS_PLAYER(this)) return 0; - if(i == CHIMPULSE_CLONE_MOVING.impulse || i == CHIMPULSE_CLONE_STANDING.impulse) + if(imp == CHIMPULSE_CLONE_MOVING.impulse || imp == CHIMPULSE_CLONE_STANDING.impulse) if(this.lip < autocvar_sv_clones) return 1; @@ -72,16 +73,18 @@ float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets if(gamestart_sv_cheats && autocvar_sv_cheats) return 1; - // if we get here, player is not allowed to cheat. Log it. - if(i) - bprintf("Player %s^7 tried to use cheat 'impulse %d'\n", playername(this.netname, this.team, false), i); - else if(argc) - bprintf("Player %s^7 tried to use cheat '%s'\n", playername(this.netname, this.team, false), argv(0)); - else if(fr) - bprintf("Player %s^7 tried to use cheat frame %d\n", playername(this.netname, this.team, false), fr); - else - bprintf("Player %s^7 tried to use an unknown cheat\n", playername(this.netname, this.team, false)); - + if (logattempt) + { + // if we get here, player is not allowed to cheat. Log it. + if(imp) + bprintf("Player %s^7 tried to use cheat 'impulse %d'\n", playername(this.netname, this.team, false), imp); + else if(argc) + bprintf("Player %s^7 tried to use cheat '%s'\n", playername(this.netname, this.team, false), argv(0)); + else if(cheatframe) + bprintf("Player %s^7 tried to use cheat frame %d\n", playername(this.netname, this.team, false), cheatframe); + else + bprintf("Player %s^7 tried to use an unknown cheat\n", playername(this.netname, this.team, false)); + } return 0; } @@ -96,7 +99,7 @@ float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets ADD_CHEATS(this, cheating); \ return attempting #define IS_CHEAT(ent,i,argc,fr) \ - if((++attempting, !CheatsAllowed(ent,i,argc,fr))) \ + if((++attempting, !CheatsAllowed(ent,i,argc,fr,true,false))) \ break float num_autoscreenshot; diff --git a/qcsrc/server/cheats.qh b/qcsrc/server/cheats.qh index 9ab0fade7..784f963b7 100644 --- a/qcsrc/server/cheats.qh +++ b/qcsrc/server/cheats.qh @@ -11,6 +11,7 @@ float cheatcount_total; .float cheatcount; void CheatInit(); void CheatShutdown(); +float CheatsAllowed(entity this, float impulse, int argc, float cheatframe, bool logattempt, bool ignoredead); float CheatImpulse(entity this, int imp); float CheatCommand(entity this, int argc); float CheatFrame(entity this);