changeset 11055:4c8d23865b6d draft

(svn r15395) -Fix [FS#2611] (r15377): one couldn't reset companies anymore in a 'dedicated' server.
author rubidium <rubidium@openttd.org>
date Sat, 07 Feb 2009 12:02:13 +0000
parents da73fac03cd6
children 399e5cb92660
files src/command.cpp src/command_type.h src/network/network_server.cpp
diffstat 3 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -304,7 +304,7 @@
 
 	{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 @@
 	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;
 
--- a/src/command_type.h
+++ b/src/command_type.h
@@ -334,12 +334,13 @@
  * 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
 };
 
 /**
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -871,7 +871,7 @@
 		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;