diff options
-rw-r--r-- | src/command.cpp | 62 | ||||
-rw-r--r-- | src/command_type.h | 1 | ||||
-rw-r--r-- | src/vehicle_cmd.cpp | 3 |
3 files changed, 25 insertions, 41 deletions
diff --git a/src/command.cpp b/src/command.cpp index 713774491..5fd62b745 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -633,40 +633,26 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, if (exec_as_spectator) cur_company.Change(COMPANY_SPECTATOR); bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0; - bool skip_test = _networking && (cmd & CMD_NO_TEST_IF_IN_NETWORK) != 0; - - /* Do we need to do a test run? - * Basically we need to always do this, except when - * the no-test-in-network flag is giving and we're - * in a network game (e.g. restoring orders would - * fail this test because the first order does not - * exist yet when inserting the second, giving that - * a wrong insert location and ignoring the command - * and thus breaking restoring). However, when we - * just want to do cost estimation we don't care - * because it's only done once anyway. */ - CommandCost res; - if (estimate_only || !skip_test) { - /* Test the command. */ - _cleared_object_areas.Clear(); - SetTownRatingTestMode(true); - ClearStorageChanges(false); - res = proc(tile, flags, p1, p2, text); - SetTownRatingTestMode(false); - - /* Make sure we're not messing things up here. */ - assert(exec_as_spectator ? _current_company == COMPANY_SPECTATOR : cur_company.Verify()); - /* If the command fails, we're doing an estimate - * or the player does not have enough money - * (unless it's a command where the test and - * execution phase might return different costs) - * we bail out here. */ - if (res.Failed() || estimate_only || - (!test_and_exec_can_differ && !CheckCompanyHasMoney(res))) { - cur_company.Restore(); - return_dcpi(res, false); - } + /* Test the command. */ + _cleared_object_areas.Clear(); + SetTownRatingTestMode(true); + ClearStorageChanges(false); + CommandCost res = proc(tile, flags, p1, p2, text); + SetTownRatingTestMode(false); + + /* Make sure we're not messing things up here. */ + assert(exec_as_spectator ? _current_company == COMPANY_SPECTATOR : cur_company.Verify()); + + /* If the command fails, we're doing an estimate + * or the player does not have enough money + * (unless it's a command where the test and + * execution phase might return different costs) + * we bail out here. */ + if (res.Failed() || estimate_only || + (!test_and_exec_can_differ && !CheckCompanyHasMoney(res))) { + cur_company.Restore(); + return_dcpi(res, false); } #ifdef ENABLE_NETWORK @@ -705,11 +691,11 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, cur_company.Restore(); } - /* If the test and execution can differ, or we skipped the test - * we have to check the return of the command. Otherwise we can - * check whether the test and execution have yielded the same - * result, i.e. cost and error state are the same. */ - if (!test_and_exec_can_differ && !skip_test) { + /* If the test and execution can differ we have to check the + * return of the command. Otherwise we can check whether the + * test and execution have yielded the same result, + * i.e. cost and error state are the same. */ + if (!test_and_exec_can_differ) { assert(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed()); // sanity check } else if (res2.Failed()) { return_dcpi(res2, false); diff --git a/src/command_type.h b/src/command_type.h index 7308f76aa..35c05573b 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -345,7 +345,6 @@ DECLARE_ENUM_AS_BIT_SET(DoCommandFlag) */ enum FlaggedCommands { CMD_NETWORK_COMMAND = 0x0100, ///< execute the command without sending it on the network - CMD_NO_TEST_IF_IN_NETWORK = 0x0200, ///< When enabled, the command will bypass the no-DC_EXEC round if in network CMD_FLAGS_MASK = 0xFF00, ///< mask for all command flags CMD_ID_MASK = 0x00FF, ///< mask for the command ID }; diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 32f4eaec3..f7d993aa7 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -56,8 +56,7 @@ const uint32 _veh_refit_proc_table[] = { }; const uint32 _send_to_depot_proc_table[] = { - /* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */ - CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_TRAIN_TO_DEPOT) | CMD_NO_TEST_IF_IN_NETWORK, + CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_TRAIN_TO_DEPOT), CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_ROAD_VEHICLE_TO_DEPOT), CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_SHIP_TO_DEPOT), CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR), |