]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow logless cheat legality checks
authordrjaska <drjaska83@gmail.com>
Wed, 4 Sep 2024 09:51:31 +0000 (12:51 +0300)
committerdrjaska <drjaska83@gmail.com>
Wed, 4 Sep 2024 09:51:31 +0000 (12:51 +0300)
qcsrc/server/cheats.qc

index 9ec7cc69a637466cfc9759ac3fe398cc5a02558c..3073b3702404c81a12e736561ce813c54f12a1fb 100644 (file)
@@ -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;