From 6ad9fcc6eca707a74a3b7c18ad7edcf6041f5487 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 7 Feb 2009 12:02:13 +0000 Subject: (svn r15395) -Fix [FS#2611] (r15377): one couldn't reset companies anymore in a 'dedicated' server. --- src/command.cpp | 4 ++-- src/command_type.h | 13 +++++++------ src/network/network_server.cpp | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/command.cpp b/src/command.cpp index cea9162ad..34658a143 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -304,7 +304,7 @@ static const Command _command_proc_table[] = { {CmdMoneyCheat, CMD_OFFLINE}, /* CMD_MONEY_CHEAT */ {CmdBuildCanal, CMD_AUTO}, /* CMD_BUILD_CANAL */ - {CmdCompanyCtrl, 0}, /* CMD_COMPANY_CTRL */ + {CmdCompanyCtrl, CMD_SPECTATOR}, /* CMD_COMPANY_CTRL */ {CmdLevelLand, CMD_ALL_TILES | CMD_NO_TEST | CMD_AUTO}, /* CMD_LEVEL_LAND; test run might clear tiles multiple times, in execution that only happens once */ @@ -524,7 +524,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return false; /* If the server is a spectator, it may only do server commands! */ - if (_current_company == COMPANY_SPECTATOR && (cmd_flags & CMD_SERVER) == 0) return false; + if (_current_company == COMPANY_SPECTATOR && (cmd_flags & (CMD_SPECTATOR | CMD_SERVER)) == 0) return false; bool notest = (cmd_flags & CMD_NO_TEST) != 0; diff --git a/src/command_type.h b/src/command_type.h index f0f2b27a0..fbc0092e8 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -334,12 +334,13 @@ enum { * This enumeration defines flags for the _command_proc_table. */ enum { - CMD_SERVER = 0x01, ///< the command can only be initiated by the server - CMD_OFFLINE = 0x02, ///< the command cannot be executed in a multiplayer game; single-player only - CMD_AUTO = 0x04, ///< set the DC_AUTO flag on this command - CMD_NO_TEST = 0x08, ///< the command's output may differ between test and execute due to town rating changes etc. - CMD_NO_WATER = 0x10, ///< set the DC_NO_WATER flag on this command - CMD_ALL_TILES= 0x20, ///< allow this command also on MP_VOID tiles + CMD_SERVER = 0x01, ///< the command can only be initiated by the server + CMD_SPECTATOR = 0x02, ///< the command may be initiated by a spectator + CMD_OFFLINE = 0x04, ///< the command cannot be executed in a multiplayer game; single-player only + CMD_AUTO = 0x08, ///< set the DC_AUTO flag on this command + CMD_ALL_TILES = 0x10, ///< allow this command also on MP_VOID tiles + CMD_NO_TEST = 0x20, ///< the command's output may differ between test and execute due to town rating changes etc. + CMD_NO_WATER = 0x40, ///< set the DC_NO_WATER flag on this command }; /** diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 20820c4ab..03c873684 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -871,7 +871,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) return; } - if (cp.cmd != CMD_COMPANY_CTRL && !IsValidCompanyID(cp.company) && ci->client_id != CLIENT_ID_SERVER) { + if ((GetCommandFlags(cp.cmd) & CMD_SPECTATOR) == 0 && !IsValidCompanyID(cp.company) && ci->client_id != CLIENT_ID_SERVER) { IConsolePrintF(CC_ERROR, "WARNING: spectator issueing command from client %d (IP: %s), kicking...", ci->client_id, GetClientIP(ci)); SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_KICKED); return; -- cgit v1.2.3-54-g00ecf