|
@@ -570,16 +570,14 @@ bool DoCommandP(TileIndex tile, uint32 p
|
|
|
|
|
|
if (_pause_mode != PM_UNPAUSED && !IsCommandAllowedWhilePaused(cmd)) {
|
|
|
ShowErrorMessage(GB(cmd, 16, 16), STR_ERROR_NOT_ALLOWED_WHILE_PAUSED, WL_INFO, x, y);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
/* Only set p2 when the command does not come from the network. */
|
|
|
if (!(cmd & CMD_NETWORK_COMMAND) && GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) 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. */
|
|
|
StringID error_part1 = GB(cmd, 16, 16);
|
|
|
if (estimate_only || (IsLocalCompany() && error_part1 != 0 && my_cmd)) {
|
|
@@ -643,16 +641,14 @@ CommandCost DoCommandPInternal(TileIndex
|
|
|
|
|
|
/* Command flags are used internally */
|
|
|
CommandFlags cmd_flags = GetCommandFlags(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);
|
|
|
|
|
|
/* Always execute server and spectator commands as spectator */
|
|
|
bool exec_as_spectator = (cmd_flags & (CMD_SPECTATOR | CMD_SERVER)) != 0;
|
|
@@ -693,13 +689,12 @@ CommandCost DoCommandPInternal(TileIndex
|
|
|
DEBUG(desync, 1, "cmdf: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
|
|
}
|
|
|
cur_company.Restore();
|
|
|
return_dcpi(res);
|
|
|
}
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
/*
|
|
|
* If we are in network, and the command is not from the network
|
|
|
* send it to the command-queue and abort execution
|
|
|
*/
|
|
|
if (_networking && !_generating_world && !(cmd & CMD_NETWORK_COMMAND)) {
|
|
|
NetworkSendCommand(tile, p1, p2, cmd & ~CMD_FLAGS_MASK, callback, text, _current_company);
|
|
@@ -708,13 +703,12 @@ CommandCost DoCommandPInternal(TileIndex
|
|
|
/* Don't return anything special here; no error, no costs.
|
|
|
* This way it's not handled by DoCommand and only the
|
|
|
* actual execution of the command causes messages. Also
|
|
|
* reset the storages as we've not executed the command. */
|
|
|
return_dcpi(CommandCost());
|
|
|
}
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
|
|
|
|
|
/* Actually try and execute the command. If no cost-type is given
|
|
|
* use the construction one */
|
|
|
_cleared_object_areas.Clear();
|
|
|
BasePersistentStorageArray::SwitchMode(PSM_ENTER_COMMAND);
|