From aff09306de0118cb7a671b3a03671f59a15c03f0 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 2 Mar 2024 11:45:01 +0100 Subject: [PATCH] Fix #12076: Do not allow 'join' command on dedicated servers --- src/console_cmds.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 98a521861e..0c766b0f47 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -155,6 +155,21 @@ DEF_CONSOLE_HOOK(ConHookNeedNetwork) return CHR_ALLOW; } +/** + * Check whether we are in a multiplayer game and are playing, i.e. we are not the dedicated server. + * @return Are we a client or non-dedicated server in a network game? True when yes, false otherwise. + */ +DEF_CONSOLE_HOOK(ConHookNeedNonDedicatedNetwork) +{ + if (!NetworkAvailable(echo)) return CHR_DISALLOW; + + if (_network_dedicated) { + if (echo) IConsolePrint(CC_ERROR, "This command is not available to a dedicated network server."); + return CHR_DISALLOW; + } + return CHR_ALLOW; +} + /** * Check whether we are in singleplayer mode. * @return True when no network is active. @@ -2693,7 +2708,7 @@ void IConsoleStdLibRegister() IConsole::CmdRegister("reconnect", ConNetworkReconnect, ConHookClientOnly); IConsole::CmdRegister("rcon", ConRcon, ConHookNeedNetwork); - IConsole::CmdRegister("join", ConJoinCompany, ConHookNeedNetwork); + IConsole::CmdRegister("join", ConJoinCompany, ConHookNeedNonDedicatedNetwork); IConsole::AliasRegister("spectate", "join 255"); IConsole::CmdRegister("move", ConMoveClient, ConHookServerOnly); IConsole::CmdRegister("reset_company", ConResetCompany, ConHookServerOnly);