From: cloudwalk Date: Wed, 3 Jun 2020 15:28:18 +0000 (+0000) Subject: Implement a callback for sv_cheats to disable all lingering cheats when set 0 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1814b2df58302baa47df6718b09465265dfc7e5c;p=xonotic%2Fdarkplaces.git Implement a callback for sv_cheats to disable all lingering cheats when set 0 git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12630 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/host_cmd.c b/host_cmd.c index b095d181..a944a230 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -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);