diff options
author | rubidium <rubidium@openttd.org> | 2009-05-26 19:23:02 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-05-26 19:23:02 +0000 |
commit | fd9bbdc54ae68312bc387e71f294d0608a2d62ae (patch) | |
tree | cda1ced151af558e13f4299d0672ef6dc6e1282e /src | |
parent | e3c5bc8d2ebb9f8ab8f4cb64002bc3b8d0e10e37 (diff) | |
download | openttd-fd9bbdc54ae68312bc387e71f294d0608a2d62ae.tar.xz |
(svn r16435) -Codechange: don't require the 'user company 0' hack for commands.
Diffstat (limited to 'src')
-rw-r--r-- | src/command.cpp | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/command.cpp b/src/command.cpp index 85d1cfd4c..1915c5561 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -505,13 +505,6 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac CompanyID old_company = _current_company; - /** 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_company == COMPANY_SPECTATOR && !_network_server) { - if (my_cmd) ShowErrorMessage(_error_message, error_part1, x, y); - return false; - } - /* get pointer to command handler */ byte cmd_id = cmd & CMD_ID_MASK; assert(cmd_id < lengthof(_command_proc_table)); @@ -527,8 +520,13 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac /* 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 false; - /* If the server is a spectator, it may only do server commands! */ - if (_current_company == COMPANY_SPECTATOR && (cmd_flags & (CMD_SPECTATOR | CMD_SERVER)) == 0) return false; + /* If the company isn't valid it may only do server command or start a new company! + * The server will ditch any server commands a client sends to it, so effectively + * this guards the server from executing functions for an invalid company. */ + if ((cmd_flags & (CMD_SPECTATOR | CMD_SERVER)) == 0 && !Company::IsValidID(_current_company)) { + if (my_cmd) ShowErrorMessage(_error_message, error_part1, x, y); + return false; + } bool notest = (cmd_flags & CMD_NO_TEST) != 0; @@ -572,18 +570,12 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac } #ifdef ENABLE_NETWORK - /** If we are in network, and the command is not from the network + /* + * If we are in network, and the command is not from the network * send it to the command-queue and abort execution - * If we are a dedicated server temporarily switch local company, otherwise - * the other parties won't be able to execute our command and will desync. - * We also need to do this if the server's company has gone bankrupt - * @todo Rewrite (dedicated) server to something more than a dirty hack! */ if (_networking && !(cmd & CMD_NETWORK_COMMAND)) { - CompanyID bck = _local_company; - if (_network_dedicated || (_network_server && bck == COMPANY_SPECTATOR)) _local_company = COMPANY_FIRST; NetworkSend_Command(tile, p1, p2, cmd & ~CMD_FLAGS_MASK, callback, text); - if (_network_dedicated || (_network_server && bck == COMPANY_SPECTATOR)) _local_company = bck; _docommand_recursive = 0; ClearStorageChanges(false); return true; |