diff --git a/src/command_type.h b/src/command_type.h index 59c9a052b0..7386fa4114 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -483,18 +483,19 @@ enum FlaggedCommands { * This enumeration defines flags for the _command_proc_table. */ enum CommandFlags { - CMD_SERVER = 0x001, ///< the command can only be initiated by the server - CMD_SPECTATOR = 0x002, ///< the command may be initiated by a spectator - CMD_OFFLINE = 0x004, ///< the command cannot be executed in a multiplayer game; single-player only - CMD_AUTO = 0x008, ///< set the DC_AUTO flag on this command - CMD_ALL_TILES = 0x010, ///< allow this command also on MP_VOID tiles - CMD_NO_TEST = 0x020, ///< the command's output may differ between test and execute due to town rating changes etc. - CMD_NO_WATER = 0x040, ///< set the DC_NO_WATER flag on this command - CMD_CLIENT_ID = 0x080, ///< set p2 with the ClientID of the sending client. - CMD_DEITY = 0x100, ///< the command may be executed by COMPANY_DEITY - CMD_STR_CTRL = 0x200, ///< the command's string may contain control strings - CMD_NO_EST = 0x400, ///< the command is never estimated. - CMD_PROCEX = 0x800, ///< the command proc function has extended parameters + CMD_SERVER = 0x001, ///< the command can only be initiated by the server + CMD_SPECTATOR = 0x002, ///< the command may be initiated by a spectator + CMD_OFFLINE = 0x004, ///< the command cannot be executed in a multiplayer game; single-player only + CMD_AUTO = 0x008, ///< set the DC_AUTO flag on this command + CMD_ALL_TILES = 0x010, ///< allow this command also on MP_VOID tiles + CMD_NO_TEST = 0x020, ///< the command's output may differ between test and execute due to town rating changes etc. + CMD_NO_WATER = 0x040, ///< set the DC_NO_WATER flag on this command + CMD_CLIENT_ID = 0x080, ///< set p2 with the ClientID of the sending client. + CMD_DEITY = 0x100, ///< the command may be executed by COMPANY_DEITY + CMD_STR_CTRL = 0x200, ///< the command's string may contain control strings + CMD_NO_EST = 0x400, ///< the command is never estimated. + CMD_PROCEX = 0x800, ///< the command proc function has extended parameters + CMD_SERVER_NS = 0x1000, ///< the command can only be initiated by the server (this is not executed in spectator mode) }; DECLARE_ENUM_AS_BIT_SET(CommandFlags) diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 65a735d2c8..0012864728 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1157,7 +1157,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(Packet } - if ((GetCommandFlags(cp.cmd) & CMD_SERVER) && ci->client_id != CLIENT_ID_SERVER && !this->settings_authed) { + if ((GetCommandFlags(cp.cmd) & (CMD_SERVER | CMD_SERVER_NS)) && ci->client_id != CLIENT_ID_SERVER && !this->settings_authed) { IConsolePrintF(CC_ERROR, "WARNING: server only command from: client %d (IP: %s), kicking...", ci->client_id, this->GetClientIP()); return this->SendError(NETWORK_ERROR_KICKED); } @@ -1173,7 +1173,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(Packet * something pretty naughty (or a bug), and will be kicked */ if (!(cp.cmd == CMD_COMPANY_CTRL && cp.p1 == 0 && ci->client_playas == COMPANY_NEW_COMPANY) && ci->client_playas != cp.company && - !((GetCommandFlags(cp.cmd) & CMD_SERVER) && this->settings_authed)) { + !((GetCommandFlags(cp.cmd) & (CMD_SERVER | CMD_SERVER_NS)) && this->settings_authed)) { IConsolePrintF(CC_ERROR, "WARNING: client %d (IP: %s) tried to execute a command as company %d, kicking...", ci->client_playas + 1, this->GetClientIP(), cp.company + 1); return this->SendError(NETWORK_ERROR_COMPANY_MISMATCH);