]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Implement a callback for sv_cheats to disable all lingering cheats when set 0
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 3 Jun 2020 15:28:18 +0000 (15:28 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 3 Jun 2020 15:28:18 +0000 (15:28 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12630 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c

index b095d181f087f551358a6d8ce3ba3895b8f351cb..a944a23074ef5b66e4da06d5180115563aa16ac8 100644 (file)
@@ -330,6 +330,31 @@ static void Host_Ping_f(cmd_state_t *cmd)
        }
 }
 
+// Disable cheats if sv_cheats is turned off
+static void Host_DisableCheats_c(char *value)
+{
+       prvm_prog_t *prog = SVVM_prog;
+       int i = 0;
+
+       if (value[0] == '0' && !value[1])
+       {
+               while (svs.clients[i].edict)
+               {
+                       if (((int)PRVM_serveredictfloat(svs.clients[i].edict, flags) & FL_GODMODE))
+                               PRVM_serveredictfloat(svs.clients[i].edict, flags) = (int)PRVM_serveredictfloat(svs.clients[i].edict, flags) ^ FL_GODMODE;
+                       if (((int)PRVM_serveredictfloat(svs.clients[i].edict, flags) & FL_NOTARGET))
+                               PRVM_serveredictfloat(svs.clients[i].edict, flags) = (int)PRVM_serveredictfloat(svs.clients[i].edict, flags) ^ FL_NOTARGET;
+                       if (PRVM_serveredictfloat(svs.clients[i].edict, movetype) == MOVETYPE_NOCLIP ||
+                               PRVM_serveredictfloat(svs.clients[i].edict, movetype) == MOVETYPE_FLY)
+                       {
+                               noclip_anglehack = false;
+                               PRVM_serveredictfloat(svs.clients[i].edict, movetype) = MOVETYPE_WALK;
+                       }
+                       i++;
+               }
+       }
+}
+
 /*
 ===============================================================================
 
@@ -3020,6 +3045,7 @@ void Host_InitCommands (void)
        Cvar_RegisterVariable(&skin);
        Cvar_RegisterVariable(&noaim);
        Cvar_RegisterVariable(&sv_cheats);
+       Cvar_RegisterCallback(&sv_cheats, Host_DisableCheats_c);
        Cvar_RegisterVariable(&sv_adminnick);
        Cvar_RegisterVariable(&sv_status_privacy);
        Cvar_RegisterVariable(&sv_status_show_qcstatus);