summaryrefslogtreecommitdiff
path: root/src/command.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-08-18 17:06:45 +0000
committerrubidium <rubidium@openttd.org>2010-08-18 17:06:45 +0000
commit69fa0b36d3bb043858621ac0b32d451674ed2719 (patch)
treef345c20f27f03cdc6e8fa9b7ddd0803739a83c96 /src/command.cpp
parent287ee8c01d900ef15bd434e61607c0f341ec2d7e (diff)
downloadopenttd-69fa0b36d3bb043858621ac0b32d451674ed2719.tar.xz
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
Diffstat (limited to 'src/command.cpp')
-rw-r--r--src/command.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/command.cpp b/src/command.cpp
index f95e2577b..a931cca03 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -14,6 +14,7 @@
#include "landscape.h"
#include "gui.h"
#include "command_func.h"
+#include "network/network_type.h"
#include "network/network.h"
#include "genworld.h"
#include "newgrf_storage.h"
@@ -283,7 +284,7 @@ static const Command _command_proc_table[] = {
DEF_CMD(CmdMoneyCheat, CMD_OFFLINE), // CMD_MONEY_CHEAT
DEF_CMD(CmdBuildCanal, CMD_AUTO), // CMD_BUILD_CANAL
- DEF_CMD(CmdCompanyCtrl, CMD_SPECTATOR), // CMD_COMPANY_CTRL
+ DEF_CMD(CmdCompanyCtrl, CMD_SPECTATOR | CMD_CLIENT_ID), // CMD_COMPANY_CTRL
DEF_CMD(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
@@ -499,6 +500,10 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac
int x = TileX(tile) * TILE_SIZE;
int y = TileY(tile) * TILE_SIZE;
+#ifdef ENABLE_NETWORK
+ if (only_sending && GetCommandFlags(cmd) & CMD_CLIENT_ID) p2 = CLIENT_ID_SERVER;
+#endif
+
CommandCost res = DoCommandPInternal(tile, p1, p2, cmd, callback, text, my_cmd, estimate_only);
if (res.Failed()) {
/* Only show the error when it's for us. */
@@ -568,6 +573,11 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
/* Flags get send to the DoCommand */
DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags);
+#ifdef ENABLE_NETWORK
+ /* Make sure p2 is properly set to a ClientID. */
+ assert(!(cmd_flags & CMD_CLIENT_ID) || p2 != 0);
+#endif
+
/* Do not even think about executing out-of-bounds tile-commands */
if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return_dcpi(CMD_ERROR, false);