From 434abd6dea136ac0be3d64b0d5b6fa7ce7b38353 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 7 Dec 2010 21:09:30 +0000 Subject: [PATCH] (svn r21428) -Fix [FS#4021]: vehicles could be built while the game it paused. Now you can enable or disable that with a setting --- src/command.cpp | 5 +++++ src/lang/english.txt | 1 + src/openttd.cpp | 2 +- src/window.cpp | 35 ++++++++++++++++++++++++++++------- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index be30d11e6b..273e22bd0c 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -515,6 +515,11 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac int x = TileX(tile) * TILE_SIZE; int y = TileY(tile) * TILE_SIZE; + 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; diff --git a/src/lang/english.txt b/src/lang/english.txt index d5a23bde40..010f50efe8 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3464,6 +3464,7 @@ STR_ERROR_OWNED_BY :{WHITE}... owne STR_ERROR_AREA_IS_OWNED_BY_ANOTHER :{WHITE}... area is owned by another company STR_ERROR_NAME_MUST_BE_UNIQUE :{WHITE}Name must be unique STR_ERROR_GENERIC_OBJECT_IN_THE_WAY :{WHITE}{1:STRING} in the way +STR_ERROR_NOT_ALLOWED_WHILE_PAUSED :{WHITE}Not allowed while paused # Local authority errors STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS :{WHITE}{TOWN} local authority refuses to allow this diff --git a/src/openttd.cpp b/src/openttd.cpp index 14c667abf3..335533770f 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1365,7 +1365,7 @@ void GameLoop() if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations(); - if (!_pause_mode || _cheats.build_in_pause.value) MoveAllTextEffects(); + if (!_pause_mode || _settings_game.construction.command_pause_level > CMDPL_NO_CONSTRUCTION) MoveAllTextEffects(); InputLoop(); diff --git a/src/window.cpp b/src/window.cpp index 1e85a42c07..7d1f6e1206 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2213,13 +2213,34 @@ static void MouseLoop(MouseClick click, int mousewheel) case MC_DOUBLE_LEFT: case MC_LEFT: DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite); - if (_thd.place_mode != HT_NONE && - /* query button and place sign button work in pause mode */ - _cursor.sprite != SPR_CURSOR_QUERY && - _cursor.sprite != SPR_CURSOR_SIGN && - _pause_mode != PM_UNPAUSED && - !_cheats.build_in_pause.value) { - return; + if (_thd.place_mode != HT_NONE && _pause_mode != PM_UNPAUSED) { + switch (_settings_game.construction.command_pause_level) { + case CMDPL_ALL_ACTIONS: + /* We allow all actions. */ + break; + + case CMDPL_NO_LANDSCAPING: + if (_cursor.sprite == SPR_CURSOR_CLONE_TRAIN || + _cursor.sprite == SPR_CURSOR_CLONE_ROADVEH || + _cursor.sprite == SPR_CURSOR_CLONE_SHIP || + _cursor.sprite == SPR_CURSOR_CLONE_AIRPLANE) { + /* Cloning is allowed. */ + break; + } + /* FALL THROUGH */ + case CMDPL_NO_CONSTRUCTION: + if (_cursor.sprite == SPR_CURSOR_SIGN || + (_cursor.sprite >= SPR_CURSOR_PICKSTATION_FIRST && _cursor.sprite <= SPR_CURSOR_PICKSTATION_LAST)) { + /* Building signs or making orders is allowed. */ + break; + } + /* FALL THROUGH */ + case CMDPL_NO_ACTIONS: + if (_cursor.sprite == SPR_CURSOR_QUERY) break; + + /* All other ones are not allowed to build. */ + return; + } } if (!HandleViewportClicked(vp, x, y) &&