summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command.cpp8
-rw-r--r--src/command.h2
-rw-r--r--src/network/core/tcp.h1
-rw-r--r--src/network/network_client.cpp1
-rw-r--r--src/network/network_data.cpp3
-rw-r--r--src/network/network_server.cpp3
6 files changed, 12 insertions, 6 deletions
diff --git a/src/command.cpp b/src/command.cpp
index 9c0a714ee..8216bd840 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -429,7 +429,7 @@ Money GetAvailableMoneyForCommand()
/* toplevel network safe docommand function for the current player. must not be called recursively.
* the callback is called when the command succeeded or failed. */
-bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd)
+bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd)
{
CommandCost res, res2;
CommandProc *proc;
@@ -455,7 +455,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
/** Spectator has no rights except for the (dedicated) server which
* is/can be a spectator but as the server it can do anything */
if (_current_player == PLAYER_SPECTATOR && !_network_server) {
- ShowErrorMessage(_error_message, error_part1, x, y);
+ if (my_cmd) ShowErrorMessage(_error_message, error_part1, x, y);
_cmd_text = NULL;
return false;
}
@@ -572,7 +572,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
if (res2.GetCost() != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2.GetCost());
if (_additional_cash_required != 0) {
SetDParam(0, _additional_cash_required);
- ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x, y);
+ if (my_cmd) ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x, y);
if (res2.GetCost() == 0) goto callb_err;
}
}
@@ -585,7 +585,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
show_error:
/* show error message if the command fails? */
- if (IsLocalPlayer() && error_part1 != 0) {
+ if (IsLocalPlayer() && error_part1 != 0 && my_cmd) {
ShowErrorMessage(_error_message, error_part1, x, y);
}
diff --git a/src/command.h b/src/command.h
index 8cb78c9e0..809fdab0f 100644
--- a/src/command.h
+++ b/src/command.h
@@ -202,7 +202,7 @@ static const CommandCost CMD_ERROR = CommandCost((StringID)INVALID_STRING_ID);
/* command.cpp */
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
-bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd);
+bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd = true);
#ifdef ENABLE_NETWORK
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index bd6a1d01f..8314edc17 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -68,6 +68,7 @@ struct CommandPacket {
char text[80]; ///< possible text sent for name changes etc
uint32 frame; ///< the frame in which this packet is executed
byte callback; ///< any callback function executed upon successful completion of the command
+ bool my_cmd; ///< did the command originate from "me"
};
/** Status of a client */
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 0cf21c2ba..495181d76 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -628,6 +628,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMMAND)
p->Recv_string(cp->text, sizeof(cp->text));
cp->callback = p->Recv_uint8();
cp->frame = p->Recv_uint32();
+ cp->my_cmd = p->Recv_bool();
cp->next = NULL;
// The server did send us this command..
diff --git a/src/network/network_data.cpp b/src/network/network_data.cpp
index 3e148cb43..8f0ffb33e 100644
--- a/src/network/network_data.cpp
+++ b/src/network/network_data.cpp
@@ -62,6 +62,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
CommandPacket *new_cp = MallocT<CommandPacket>(1);
*new_cp = c;
+ new_cp->my_cmd = true;
if (_local_command_queue == NULL) {
_local_command_queue = new_cp;
} else {
@@ -102,7 +103,7 @@ void NetworkExecuteCommand(CommandPacket *cp)
debug_dump_commands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)cp->player, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text);
#endif /* DUMP_COMMANDS */
- DoCommandP(cp->tile, cp->p1, cp->p2, _callback_table[cp->callback], cp->cmd | CMD_NETWORK_COMMAND);
+ DoCommandP(cp->tile, cp->p1, cp->p2, _callback_table[cp->callback], cp->cmd | CMD_NETWORK_COMMAND, cp->my_cmd);
}
#endif /* ENABLE_NETWORK */
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index ad9985572..8de68e0aa 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -491,6 +491,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkTCPSocketHandler *cs
p->Send_string(cp->text);
p->Send_uint8 (cp->callback);
p->Send_uint32(cp->frame);
+ p->Send_bool (cp->my_cmd);
cs->Send_Packet(p);
}
@@ -915,11 +916,13 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
// Callbacks are only send back to the client who sent them in the
// first place. This filters that out.
cp->callback = (new_cs != cs) ? 0 : callback;
+ cp->my_cmd = (new_cs == cs);
NetworkAddCommandQueue(new_cs, cp);
}
}
cp->callback = 0;
+ cp->my_cmd = false;
// Queue the command on the server
if (_local_command_queue == NULL) {
_local_command_queue = cp;