* Decide what to do with the command depending on current game state. * @param cmd Command to execute. * @param flags Command flags. * @param tile Tile of command execution. * @param err_message Message prefix to show on error. * @param network_command Does this command come from the network? * @return error state + do only cost estimation? + send to network only? */
| 205 | * @return error state + do only cost estimation? + send to network only? |
| 206 | */ |
| 207 | std::tuple<bool, bool, bool> CommandHelperBase::InternalPostBefore(Commands cmd, CommandFlags flags, TileIndex tile, StringID err_message, bool network_command) |
| 208 | { |
| 209 | /* Cost estimation is generally only done when the |
| 210 | * local user presses shift while doing something. |
| 211 | * However, in case of incoming network commands, |
| 212 | * map generation or the pause button we do want |
| 213 | * to execute. */ |
| 214 | bool estimate_only = _shift_pressed && IsLocalCompany() && !_generating_world && !network_command && !flags.Test(CommandFlag::NoEst); |
| 215 | |
| 216 | /* We're only sending the command, so don't do |
| 217 | * fancy things for 'success'. */ |
| 218 | bool only_sending = _networking && !network_command; |
| 219 | |
| 220 | if (_pause_mode.Any() && !IsCommandAllowedWhilePaused(cmd) && !estimate_only) { |
| 221 | ShowErrorMessage(GetEncodedString(err_message), GetEncodedString(STR_ERROR_NOT_ALLOWED_WHILE_PAUSED), |
| 222 | WL_INFO, TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE); |
| 223 | return { true, estimate_only, only_sending }; |
| 224 | } else { |
| 225 | return { false, estimate_only, only_sending }; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * Process result of executing a command, possibly displaying any error to the player. |
nothing calls this directly
no test coverage detected