From 790fe2a3d71ce7734402ee6dc712bf1b763598a5 Mon Sep 17 00:00:00 2001 From: Steam Deck User Date: Tue, 7 Mar 2023 19:11:29 -0500 Subject: [PATCH] SERVER: Add some basic anti-cheat for commands in Co-Op --- source/server/utilities/command_parser.qc | 55 ++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/source/server/utilities/command_parser.qc b/source/server/utilities/command_parser.qc index 7db4f63..a8046cc 100644 --- a/source/server/utilities/command_parser.qc +++ b/source/server/utilities/command_parser.qc @@ -27,6 +27,9 @@ */ +// Whether the command prohibits client-sending. +float client_parse_override; + // Success/Failure return codes #define COMMAND_SUCCESS 0 #define COMMAND_FAILURE 1 @@ -37,6 +40,12 @@ // float(string params) Command_give = { + // Anti-Cheat in Co-Op. + if (coop) { + bprint(PRINT_HIGH, "Someone tried to issue Give in a Co-Op match. Nice try!\n"); + return COMMAND_FAILURE; + } + float wep = stof(argv(1)); if (wep) { @@ -86,6 +95,12 @@ float(string params) Command_give = // float(string params) Command_addmoney = { + // Anti-Cheat in Co-Op. + if (coop) { + bprint(PRINT_HIGH, "Someone tried to issue Add Money in a Co-Op match. Nice try!\n"); + return COMMAND_FAILURE; + } + // Grab parameters. tokenize(params); float point_value = stof(argv(0)); @@ -114,6 +129,39 @@ float(string params) Command_softrestart = return COMMAND_SUCCESS; } +// +// Command_godmode() +// Toggles God Mode. +// +float(string params) Command_godmode = +{ + // Anti-Cheat in Co-Op. + if (coop) { + bprint(PRINT_HIGH, "Someone tried to issue God Mode in a Co-Op match. Nice try!\n"); + return COMMAND_FAILURE; + } + + client_parse_override = false; + return COMMAND_SUCCESS; +} + +// +// Command_noclip() +// Toggles No Clip. +// +float(string params) Command_noclip = +{ + // Anti-Cheat in Co-Op. + if (coop) { + bprint(PRINT_HIGH, "Someone tried to issue No-Clip in a Co-Op match. Nice try!\n"); + return COMMAND_FAILURE; + } + + client_parse_override = false; + return COMMAND_SUCCESS; +} + + // // Server command table // command_name : Command string entered into developer console. @@ -131,7 +179,9 @@ var struct { } server_commands[] = { {"addmoney", Command_addmoney, true, "Usage: addmoney \n Gives `point_value` amount of points to the client who requested it.\n"}, {"give", Command_give, true, "Usage: give \n Gives `weapon` of index.\n"}, - {"qc_soft_restart", Command_softrestart, false, "Executes the Soft_Restart QuakeC function. Useful for debugging its functionality.\n"} + {"qc_soft_restart", Command_softrestart, false, "Executes the Soft_Restart QuakeC function. Useful for debugging its functionality.\n"}, + {"god", Command_godmode, false, "Toggles God Mode.\n"}, + {"noclip", Command_noclip, false, "Toggles No Clip.\n"} }; // @@ -139,11 +189,12 @@ var struct { // Server-Side client command parser to add special // gameplay commands that interact with QuakeC. // + void(string command_string) SV_ParseClientCommand = { // If true, we will avoid sending the command info // to the client. - float client_parse_override = false; + client_parse_override = false; // Get the string ready for arg parsing tokenize(command_string);