Cheater warning

This commit is contained in:
Sally Coolatta 2022-09-27 15:22:59 -04:00
parent 562f5398a0
commit e2b2b7785c
3 changed files with 22 additions and 0 deletions

View file

@ -1774,6 +1774,11 @@ static void Got_NetVar(UINT8 **p, INT32 playernum)
if (cvar)
Setvalue(cvar, svalue, stealth);
if ((cvar->flags & CV_CHEAT) && stricmp(svalue, cvar->defaultvalue) != 0)
{
CV_CheaterWarning(playernum, va("%s %s", cvar->name, svalue));
}
}
void CV_SaveVars(UINT8 **p, boolean in_demo)
@ -1917,6 +1922,15 @@ boolean CV_CheatsEnabled(void)
return (boolean)cv_cheats.value;
}
// Consistent print about cheaters in multiplayer.
void CV_CheaterWarning(UINT8 playerID, const char *command)
{
if (netgame)
{
CONS_Printf("\x85" "%s cheats:" "\x80" " %s\n", player_names[playerID], command);
}
}
/** Sets a value to a variable, performing some checks and calling the
* callback function if there is one.
* Does as if "<varname> <value>" is entered at the console.

View file

@ -233,6 +233,7 @@ void CV_CheatsChanged(void);
boolean CV_IsSetToDefault(consvar_t *v);
boolean CV_CheatsEnabled(void);
void CV_CheaterWarning(UINT8 playerID, const char *command);
// Returns cvar by name. Exposed here for Lua.
consvar_t *CV_FindVar(const char *name);

View file

@ -5306,6 +5306,13 @@ static void Got_GiveItemcmd(UINT8 **cp, INT32 playernum)
players[playernum].itemtype = item;
players[playernum].itemamount = amt;
CV_CheaterWarning(
playernum,
(amt != 1) // FIXME: we should have actual KITEM_ name array
? va("kartgiveitem %s %d", cv_kartdebugitem.PossibleValue[item+1].strvalue, amt)
: va("kartgiveitem %s", cv_kartdebugitem.PossibleValue[item+1].strvalue)
);
}
static void Got_ScheduleTaskcmd(UINT8 **cp, INT32 playernum)