diff --git a/bin/data/opntitle.dat b/bin/data/opntitle.dat index 70caa9ff88..264aaff60b 100644 Binary files a/bin/data/opntitle.dat and b/bin/data/opntitle.dat differ diff --git a/src/ai/api/ai_airport.hpp b/src/ai/api/ai_airport.hpp index e4541edf63..fc9fd2acf8 100644 --- a/src/ai/api/ai_airport.hpp +++ b/src/ai/api/ai_airport.hpp @@ -129,7 +129,7 @@ public: * @exception AIError::ERR_FLAT_LAND_REQUIRED * @exception AIError::ERR_LOCAL_AUTHORITY_REFUSES * @exception AIStation::ERR_STATION_TOO_LARGE - * @exception AIStation::ERR_STATION_TOO_CLOSE_TO_OTHER_STATION + * @exception AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION * @return Whether the airport has been/can be build or not. */ static bool BuildAirport(TileIndex tile, AirportType type, StationID station_id); diff --git a/src/ai/api/ai_order.hpp b/src/ai/api/ai_order.hpp index 4ce99bdff0..68830448fd 100644 --- a/src/ai/api/ai_order.hpp +++ b/src/ai/api/ai_order.hpp @@ -328,7 +328,7 @@ public: * @pre AIVehicle::IsValidVehicle(vehicle_id). * @pre AreOrderFlagsValid(destination, order_flags). * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY - * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE + * @exception AIOrder::ERR_ORDER_TOO_MANY * @exception AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION * @return True if and only if the order was appended. */ @@ -341,7 +341,7 @@ public: * @pre AIVehicle::IsValidVehicle(vehicle_id). * @pre IsValidVehicleOrder(vehicle_id, jump_to). * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY - * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE + * @exception AIOrder::ERR_ORDER_TOO_MANY * @return True if and only if the order was appended. */ static bool AppendConditionalOrder(VehicleID vehicle_id, OrderPosition jump_to); @@ -355,7 +355,7 @@ public: * @pre IsValidVehicleOrder(vehicle_id, order_position). * @pre AreOrderFlagsValid(destination, order_flags). * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY - * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE + * @exception AIOrder::ERR_ORDER_TOO_MANY * @exception AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION * @return True if and only if the order was inserted. */ @@ -369,7 +369,7 @@ public: * @pre IsValidVehicleOrder(vehicle_id, order_position). * @pre IsValidVehicleOrder(vehicle_id, jump_to). * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY - * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE + * @exception AIOrder::ERR_ORDER_TOO_MANY * @return True if and only if the order was inserted. */ static bool InsertConditionalOrder(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to); @@ -442,7 +442,7 @@ public: * @pre AIVehicle::IsValidVehicle(vehicle_id). * @pre AIVehicle::IsValidVehicle(main_vehicle_id). * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY - * @exception AIOrder::ERR_ORDER_NO_MORE_SPACE + * @exception AIOrder::ERR_ORDER_TOO_MANY * @return True if and only if the copying succeeded. */ static bool CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id); diff --git a/src/ai/api/ai_road.hpp b/src/ai/api/ai_road.hpp index 7bd26922df..33af0f0119 100644 --- a/src/ai/api/ai_road.hpp +++ b/src/ai/api/ai_road.hpp @@ -349,7 +349,7 @@ public: * @exception AIError::ERR_FLAT_LAND_REQUIRED * @exception AIRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION * @exception AIRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD - * @exception AIError:ERR_VEHICLE_IN_THE_WAY + * @exception AIError::ERR_VEHICLE_IN_THE_WAY * @exception AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION * @exception AIStation::ERR_STATION_TOO_MANY_STATIONS * @exception AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN @@ -372,7 +372,7 @@ public: * @exception AIError::ERR_FLAT_LAND_REQUIRED * @exception AIRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION * @exception AIRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD - * @exception AIError:ERR_VEHICLE_IN_THE_WAY + * @exception AIError::ERR_VEHICLE_IN_THE_WAY * @exception AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION * @exception AIStation::ERR_STATION_TOO_MANY_STATIONS * @exception AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN diff --git a/src/ai/api/ai_vehicle.hpp b/src/ai/api/ai_vehicle.hpp index a4b9a66d2c..83b96a7fe0 100644 --- a/src/ai/api/ai_vehicle.hpp +++ b/src/ai/api/ai_vehicle.hpp @@ -58,7 +58,7 @@ public: ERR_VEHICLE_IN_FLIGHT, // [STR_A017_AIRCRAFT_IS_IN_FLIGHT] /** Vehicle is without power */ - ERR_VEHCILE_NO_POWER, // [STR_TRAIN_START_NO_CATENARY] + ERR_VEHICLE_NO_POWER, // [STR_TRAIN_START_NO_CATENARY] }; diff --git a/src/ai/api/ai_vehicle.hpp.sq b/src/ai/api/ai_vehicle.hpp.sq index 458c59178b..16abc1367c 100644 --- a/src/ai/api/ai_vehicle.hpp.sq +++ b/src/ai/api/ai_vehicle.hpp.sq @@ -37,7 +37,7 @@ void SQAIVehicle_Register(Squirrel *engine) { SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_IS_DESTROYED, "ERR_VEHICLE_IS_DESTROYED"); SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT, "ERR_VEHICLE_NOT_IN_DEPOT"); SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_IN_FLIGHT, "ERR_VEHICLE_IN_FLIGHT"); - SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHCILE_NO_POWER, "ERR_VEHCILE_NO_POWER"); + SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_NO_POWER, "ERR_VEHICLE_NO_POWER"); SQAIVehicle.DefSQConst(engine, AIVehicle::VT_RAIL, "VT_RAIL"); SQAIVehicle.DefSQConst(engine, AIVehicle::VT_ROAD, "VT_ROAD"); SQAIVehicle.DefSQConst(engine, AIVehicle::VT_WATER, "VT_WATER"); @@ -85,7 +85,7 @@ void SQAIVehicle_Register(Squirrel *engine) { AIError::RegisterErrorMap(STR_TRAIN_MUST_BE_STOPPED, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); AIError::RegisterErrorMap(STR_980B_SHIP_MUST_BE_STOPPED_IN, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); AIError::RegisterErrorMap(STR_A017_AIRCRAFT_IS_IN_FLIGHT, AIVehicle::ERR_VEHICLE_IN_FLIGHT); - AIError::RegisterErrorMap(STR_TRAIN_START_NO_CATENARY, AIVehicle::ERR_VEHCILE_NO_POWER); + AIError::RegisterErrorMap(STR_TRAIN_START_NO_CATENARY, AIVehicle::ERR_VEHICLE_NO_POWER); AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_TOO_MANY, "ERR_VEHICLE_TOO_MANY"); AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_NOT_AVAILABLE, "ERR_VEHICLE_NOT_AVAILABLE"); @@ -98,7 +98,7 @@ void SQAIVehicle_Register(Squirrel *engine) { AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_IS_DESTROYED, "ERR_VEHICLE_IS_DESTROYED"); AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT, "ERR_VEHICLE_NOT_IN_DEPOT"); AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_IN_FLIGHT, "ERR_VEHICLE_IN_FLIGHT"); - AIError::RegisterErrorMapString(AIVehicle::ERR_VEHCILE_NO_POWER, "ERR_VEHCILE_NO_POWER"); + AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_NO_POWER, "ERR_VEHICLE_NO_POWER"); SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsValidVehicle, "IsValidVehicle", 2, ".i"); SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetNumWagons, "GetNumWagons", 2, ".i"); diff --git a/src/economy.cpp b/src/economy.cpp index 8c09caef40..38b2976129 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1552,6 +1552,7 @@ void PrepareUnload(Vehicle *front_v) static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) { assert(v->current_order.IsType(OT_LOADING)); + assert(v->load_unload_time_rem != 0); /* We have not waited enough time till the next round of loading/unloading */ if (--v->load_unload_time_rem != 0) { diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index e72dc5ea17..cdc1295b2c 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -416,6 +416,9 @@ bool AfterLoadGame() } } + /* Update all waypoints */ + if (CheckSavegameVersion(12)) FixOldWaypoints(); + if (CheckSavegameVersion(84)) { FOR_ALL_COMPANIES(c) { c->name = CopyFromOldName(c->name_1); @@ -440,7 +443,7 @@ bool AfterLoadGame() Waypoint *wp; FOR_ALL_WAYPOINTS(wp) { wp->name = CopyFromOldName(wp->string); - wp->string = STR_EMPTY; + wp->string = STR_NULL; } } @@ -518,9 +521,6 @@ bool AfterLoadGame() } } - /* Update all waypoints */ - if (CheckSavegameVersion(12)) FixOldWaypoints(); - /* make sure there is a town in the game */ if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, UINT_MAX)) { SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO); diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp index e8a8bf949d..2457ab3b96 100644 --- a/src/saveload/waypoint_sl.cpp +++ b/src/saveload/waypoint_sl.cpp @@ -45,8 +45,8 @@ void FixOldWaypoints() FOR_ALL_WAYPOINTS(wp) { wp->town_index = ClosestTownFromTile(wp->xy, UINT_MAX)->index; wp->town_cn = 0; - if (wp->string & 0xC000) { - wp->town_cn = wp->string & 0x3F; + if ((wp->string & 0xC000) == 0xC000) { + wp->town_cn = (wp->string >> 8) & 0x3F; wp->string = STR_NULL; } } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index d4b7b1b6ef..a3d63280d4 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1557,6 +1557,10 @@ static void MarkTrainAsStuck(Vehicle *v) if (!HasBit(v->u.rail.flags, VRF_TRAIN_STUCK)) { /* It is the first time the problem occured, set the "train stuck" flag. */ SetBit(v->u.rail.flags, VRF_TRAIN_STUCK); + + /* When loading the vehicle is already stopped. No need to change that. */ + if (v->current_order.IsType(OT_LOADING)) return; + v->load_unload_time_rem = 0; /* Stop train */ diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 6a4c1c115c..3fc43b0be4 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -535,6 +535,8 @@ void Vehicle::PreDestructor() GetStation(this->last_station_visited)->loading_vehicles.remove(this); HideFillingPercent(&this->fill_percent_te_id); + + delete this->cargo_payment; } if (IsEngineCountable(this)) { diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 1462d9317a..b14cc92ec7 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -407,7 +407,7 @@ struct RefitWindow : public Window { static const Widget _vehicle_refit_widgets[] = { { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 239, 0, 13, STR_983B_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS}, - { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 239, 14, 27, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, NULL}, + { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 239, 14, 27, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, STR_NULL}, { WWT_MATRIX, RESIZE_BOTTOM, COLOUR_GREY, 0, 227, 28, 139, 0x801, STR_EMPTY}, { WWT_SCROLLBAR, RESIZE_BOTTOM, COLOUR_GREY, 228, 239, 28, 139, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, @@ -1882,7 +1882,7 @@ struct VehicleViewWindow : Window { } else { // no train str = STR_8861_STOPPED; } - } else if (v->type == VEH_TRAIN && HasBit(v->u.rail.flags, VRF_TRAIN_STUCK)) { + } else if (v->type == VEH_TRAIN && HasBit(v->u.rail.flags, VRF_TRAIN_STUCK) && !v->current_order.IsType(OT_LOADING)) { str = STR_TRAIN_STUCK; } else { // vehicle is in a "normal" state, show current order switch (v->current_order.GetType()) {