From c72baf2f3f9189dc347a8fe05a7dec8af02cbc10 Mon Sep 17 00:00:00 2001 From: drjaska Date: Wed, 4 Sep 2024 12:51:31 +0300 Subject: [PATCH] Allow logless cheat legality checks --- qcsrc/server/cheats.qc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 9ec7cc69a..3073b3702 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -54,14 +54,14 @@ void CheatShutdown() { } -float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets passed as argument for possible future ACL checking +float CheatsAllowed(entity this, float imp, int argc, float cheatframe, bool logattempt) // the cheat gets passed as argument for possible future ACL checking { if(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 +72,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 +98,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))) \ break float num_autoscreenshot; -- 2.39.2