summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp47
-rw-r--r--src/saveload/cargodest_sl.cpp181
-rw-r--r--src/saveload/cargopacket_sl.cpp6
-rw-r--r--src/saveload/economy_sl.cpp2
-rw-r--r--src/saveload/industry_sl.cpp12
-rw-r--r--src/saveload/map_sl.cpp6
-rw-r--r--src/saveload/order_sl.cpp9
-rw-r--r--src/saveload/saveload.cpp10
-rw-r--r--src/saveload/saveload.h8
-rw-r--r--src/saveload/station_sl.cpp3
-rw-r--r--src/saveload/town_sl.cpp16
-rw-r--r--src/saveload/vehicle_sl.cpp4
12 files changed, 298 insertions, 6 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 15c44d392..2f84ef0e8 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -51,7 +51,9 @@
#include "../core/backup_type.hpp"
#include "../smallmap_gui.h"
#include "../news_func.h"
+#include "../cargodest_func.h"
#include "../error.h"
+#include "../trafficlight_func.h"
#include "saveload_internal.h"
@@ -254,6 +256,7 @@ static void InitializeWindowsAndCaches()
Station::RecomputeIndustriesNearForAll();
RebuildSubsidisedSourceAndDestinationCache();
+ RebuildCargoLinkCounts();
/* Towns have a noise controlled number of airports system
* So each airport's noise value must be added to the town->noise_reached value
@@ -2761,6 +2764,50 @@ bool AfterLoadGame()
_settings_game.script.settings_profile = IsInsideMM(_old_diff_level, SP_BEGIN, SP_END) ? _old_diff_level : (uint)SP_MEDIUM;
}
+ if (IsSavegameVersionBefore(180)) {
+ /* Update cargo acceptance map of towns. */
+ for (TileIndex t = 0; t < map_size; t++) {
+ if (!IsTileType(t, MP_HOUSE)) continue;
+ Town::Get(GetTownIndex(t))->cargo_accepted.Add(t);
+ }
+
+ Town *town;
+ FOR_ALL_TOWNS(town) {
+ UpdateTownCargoes(town);
+ }
+
+ /* Update cargo acceptance of industries. */
+ Industry *ind;
+ FOR_ALL_INDUSTRIES(ind) {
+ UpdateIndustryAcceptance(ind);
+ ind->average_production[0] = ind->last_month_production[0];
+ ind->average_production[1] = ind->last_month_production[1];
+ }
+
+ UpdateCargoLinks();
+
+ Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ /* Set the current order index from the order list. */
+ Order *o = v->GetOrder(v->cur_implicit_order_index);
+ if (o != NULL) v->current_order.index = o->index;
+
+ /* Pre-fill route links from orders. */
+ if (v->IsFrontEngine()) PrefillRouteLinks(v);
+ }
+ }
+
+ if (IsSavegameVersionBefore(TL_SV)) {
+ /* Savegames before this version can not have trafficlights already.
+ * Sometimes they are added randomly when loading old savegames.
+ * Unfortunately also in the wrong places -> not on crossings.
+ *
+ * Iterate over the whole map and remove any trafficlights found. */
+ for (TileIndex tile = 0; tile < MapSize(); tile++) {
+ if (HasTrafficLights(tile)) ClearTrafficLights(tile);
+ }
+ }
+
/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();
diff --git a/src/saveload/cargodest_sl.cpp b/src/saveload/cargodest_sl.cpp
new file mode 100644
index 000000000..1950268c0
--- /dev/null
+++ b/src/saveload/cargodest_sl.cpp
@@ -0,0 +1,181 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file cargodest_sl.cpp Code handling saving and loading of cargo destinations. */
+
+#include "../stdafx.h"
+#include "../cargodest_base.h"
+#include "../town.h"
+#include "../industry.h"
+#include "saveload.h"
+
+static uint32 _cargolink_uint;
+static const SaveLoadGlobVarList _cargolink_uint_desc[] = {
+ SLEG_VAR(_cargolink_uint, SLE_UINT32),
+ SLEG_END()
+};
+
+static const SaveLoad _cargolink_desc[] = {
+ SLE_VAR(CargoLink, amount.old_max, SLE_UINT32),
+ SLE_VAR(CargoLink, amount.new_max, SLE_UINT32),
+ SLE_VAR(CargoLink, amount.old_act, SLE_UINT32),
+ SLE_VAR(CargoLink, amount.new_act, SLE_UINT32),
+ SLE_VAR(CargoLink, weight, SLE_UINT32),
+ SLE_VAR(CargoLink, weight_mod, SLE_UINT8),
+ SLE_END()
+};
+
+void CargoSourceSink::SaveCargoSourceSink()
+{
+ if (IsSavegameVersionBefore(180)) return;
+
+ static const SaveLoad _cargosourcesink_desc[] = {
+ SLE_ARR(CargoSourceSink, cargo_links_weight, SLE_UINT32, NUM_CARGO),
+ SLE_END()
+ };
+ SlObject(this, _cargosourcesink_desc);
+
+ for (uint cid = 0; cid < lengthof(this->cargo_links); cid++) {
+ _cargolink_uint = this->cargo_links[cid].Length();
+ SlObject(NULL, _cargolink_uint_desc);
+ for (CargoLink *l = this->cargo_links[cid].Begin(); l != this->cargo_links[cid].End(); l++) {
+ SourceID dest = INVALID_SOURCE;
+ SourceTypeByte type;
+ type = ST_TOWN;
+
+ if (l->dest != NULL) {
+ type = l->dest->GetType();
+ dest = l->dest->GetID();
+ }
+
+ /* Pack type and destination index into temp variable. */
+ assert_compile(sizeof(SourceID) <= 3);
+ _cargolink_uint = type | (dest << 8);
+
+ SlGlobList(_cargolink_uint_desc);
+ SlObject(l, _cargolink_desc);
+ }
+ }
+}
+
+void CargoSourceSink::LoadCargoSourceSink()
+{
+ if (IsSavegameVersionBefore(180)) return;
+
+ static const SaveLoad _cargosourcesink_desc[] = {
+ SLE_ARR(CargoSourceSink, cargo_links_weight, SLE_UINT32, NUM_CARGO),
+ SLE_END()
+ };
+ SlObject(this, _cargosourcesink_desc);
+
+ for (uint cid = 0; cid < lengthof(this->cargo_links); cid++) {
+ /* Remove links created by constructors. */
+ this->cargo_links[cid].Clear();
+ /* Read vector length and allocate storage. */
+ SlObject(NULL, _cargolink_uint_desc);
+ this->cargo_links[cid].Append(_cargolink_uint);
+
+ for (CargoLink *l = this->cargo_links[cid].Begin(); l != this->cargo_links[cid].End(); l++) {
+ /* Read packed type and dest and store in dest pointer. */
+ SlGlobList(_cargolink_uint_desc);
+ *(size_t*)&l->dest = _cargolink_uint;
+
+ SlObject(l, _cargolink_desc);
+ }
+ }
+}
+
+void CargoSourceSink::PtrsCargoSourceSink()
+{
+ if (IsSavegameVersionBefore(180)) return;
+
+ for (uint cid = 0; cid < lengthof(this->cargo_links); cid++) {
+ for (CargoLink *l = this->cargo_links[cid].Begin(); l != this->cargo_links[cid].End(); l++) {
+ /* Extract type and destination index. */
+ SourceType type = (SourceType)((size_t)l->dest & 0xFF);
+ SourceID dest = (SourceID)((size_t)l->dest >> 8);
+
+ /* Resolve index. */
+ l->dest = NULL;
+ if (dest != INVALID_SOURCE) {
+ switch (type) {
+ case ST_TOWN:
+ if (!Town::IsValidID(dest)) SlErrorCorrupt("Invalid cargo link destination");
+ l->dest = Town::Get(dest);
+ break;
+
+ case ST_INDUSTRY:
+ if (!Industry::IsValidID(dest)) SlErrorCorrupt("Invalid cargo link destination");
+ l->dest = Industry::Get(dest);
+ break;
+
+ default:
+ SlErrorCorrupt("Invalid cargo link destination type");
+ }
+ }
+ }
+ }
+}
+
+/**
+ * Wrapper function to get the RouteLinks's internal structure while
+ * some of the variables itself are private.
+ * @return The SaveLoad description for RouteLinks.
+ */
+const SaveLoad *GetRouteLinkDescription()
+{
+ static const SaveLoad _routelink_desc[] = {
+ SLE_VAR(RouteLink, dest, SLE_UINT16),
+ SLE_VAR(RouteLink, prev_order, SLE_UINT16),
+ SLE_VAR(RouteLink, next_order, SLE_UINT16),
+ SLE_VAR(RouteLink, owner, SLE_UINT8),
+ SLE_VAR(RouteLink, vtype, SLE_UINT8),
+ SLE_VAR(RouteLink, travel_time, SLE_UINT32),
+ SLE_VAR(RouteLink, wait_time, SLE_UINT16),
+
+ SLE_END()
+ };
+ return _routelink_desc;
+}
+
+/** Save the RouteLink chunk. */
+static void Save_RTLN()
+{
+ RouteLink *link;
+
+ FOR_ALL_ROUTELINKS(link) {
+ SlSetArrayIndex(link->index);
+ SlObject(link, GetRouteLinkDescription());
+ }
+}
+
+/** Load the RouteLink chunk. */
+static void Load_RTLN()
+{
+ int index;
+
+ while ((index = SlIterateArray()) != -1) {
+ RouteLink *link = new (index) RouteLink();
+ SlObject(link, GetRouteLinkDescription());
+ }
+}
+
+/** Resolve references after loading the RouteLink chunk. */
+static void Ptrs_RTLN()
+{
+ RouteLink *link;
+
+ FOR_ALL_ROUTELINKS(link) {
+ SlObject(link, GetRouteLinkDescription());
+ }
+}
+
+extern const ChunkHandler _routelink_chunk_handlers[] = {
+ { 'RTLN', Save_RTLN, Load_RTLN, Ptrs_RTLN, NULL, CH_ARRAY | CH_LAST},
+};
diff --git a/src/saveload/cargopacket_sl.cpp b/src/saveload/cargopacket_sl.cpp
index 092301e95..95a8d1554 100644
--- a/src/saveload/cargopacket_sl.cpp
+++ b/src/saveload/cargopacket_sl.cpp
@@ -95,6 +95,12 @@ const SaveLoad *GetCargoPacketDesc()
SLE_VAR(CargoPacket, feeder_share, SLE_INT64),
SLE_CONDVAR(CargoPacket, source_type, SLE_UINT8, 125, SL_MAX_VERSION),
SLE_CONDVAR(CargoPacket, source_id, SLE_UINT16, 125, SL_MAX_VERSION),
+ SLE_CONDVAR(CargoPacket, dest_xy, SLE_UINT32, 180, SL_MAX_VERSION),
+ SLE_CONDVAR(CargoPacket, dest_id, SLE_UINT16, 180, SL_MAX_VERSION),
+ SLE_CONDVAR(CargoPacket, dest_type, SLE_UINT8, 180, SL_MAX_VERSION),
+ SLE_CONDVAR(CargoPacket, flags, SLE_UINT8, 180, SL_MAX_VERSION),
+ SLE_CONDVAR(CargoPacket, next_order, SLE_UINT16, 180, SL_MAX_VERSION),
+ SLE_CONDVAR(CargoPacket, next_station, SLE_UINT16, 180, SL_MAX_VERSION),
/* Used to be paid_for, but that got changed. */
SLE_CONDNULL(1, 0, 120),
diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp
index 9bdad61a9..e5d6c9ed4 100644
--- a/src/saveload/economy_sl.cpp
+++ b/src/saveload/economy_sl.cpp
@@ -67,6 +67,8 @@ static const SaveLoad _cargopayment_desc[] = {
SLE_VAR(CargoPayment, route_profit, SLE_INT64),
SLE_VAR(CargoPayment, visual_profit, SLE_INT64),
+ SLE_CONDVAR(CargoPayment, transfer_profit, SLE_INT64, 180, SL_MAX_VERSION),
+
SLE_END()
};
diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp
index 8943a5d52..be51bdc57 100644
--- a/src/saveload/industry_sl.cpp
+++ b/src/saveload/industry_sl.cpp
@@ -30,12 +30,14 @@ static const SaveLoad _industry_desc[] = {
SLE_ARR(Industry, production_rate, SLE_UINT8, 2),
SLE_CONDNULL( 3, 0, 60), ///< used to be industry's accepts_cargo
SLE_CONDARR(Industry, accepts_cargo, SLE_UINT8, 3, 78, SL_MAX_VERSION),
+ SLE_CONDVAR(Industry, produced_accepted_mask, SLE_UINT32, 180, SL_MAX_VERSION),
SLE_VAR(Industry, prod_level, SLE_UINT8),
SLE_ARR(Industry, this_month_production, SLE_UINT16, 2),
SLE_ARR(Industry, this_month_transported, SLE_UINT16, 2),
SLE_ARR(Industry, last_month_pct_transported, SLE_UINT8, 2),
SLE_ARR(Industry, last_month_production, SLE_UINT16, 2),
SLE_ARR(Industry, last_month_transported, SLE_UINT16, 2),
+ SLE_CONDARR(Industry, average_production, SLE_UINT16, 2, 180, SL_MAX_VERSION),
SLE_VAR(Industry, counter, SLE_UINT16),
@@ -63,6 +65,12 @@ static const SaveLoad _industry_desc[] = {
SLE_END()
};
+static void RealSave_INDY(Industry *ind)
+{
+ SlObject(ind, _industry_desc);
+ ind->SaveCargoSourceSink();
+}
+
static void Save_INDY()
{
Industry *ind;
@@ -70,7 +78,7 @@ static void Save_INDY()
/* Write the industries */
FOR_ALL_INDUSTRIES(ind) {
SlSetArrayIndex(ind->index);
- SlObject(ind, _industry_desc);
+ SlAutolength((AutolengthProc *)RealSave_INDY, ind);
}
}
@@ -93,6 +101,7 @@ static void Load_INDY()
while ((index = SlIterateArray()) != -1) {
Industry *i = new (index) Industry();
SlObject(i, _industry_desc);
+ i->LoadCargoSourceSink();
/* Before savegame version 161, persistent storages were not stored in a pool. */
if (IsSavegameVersionBefore(161) && !IsSavegameVersionBefore(76)) {
@@ -121,6 +130,7 @@ static void Ptrs_INDY()
FOR_ALL_INDUSTRIES(i) {
SlObject(i, _industry_desc);
+ i->PtrsCargoSourceSink();
}
}
diff --git a/src/saveload/map_sl.cpp b/src/saveload/map_sl.cpp
index 7088a4406..c54e54e92 100644
--- a/src/saveload/map_sl.cpp
+++ b/src/saveload/map_sl.cpp
@@ -11,6 +11,7 @@
#include "../stdafx.h"
#include "../map_func.h"
+#include "../layer_func.h"
#include "../core/bitmath_func.hpp"
#include "../fios.h"
@@ -18,10 +19,12 @@
static uint32 _map_dim_x;
static uint32 _map_dim_y;
+static uint32 _layer_count;
static const SaveLoadGlobVarList _map_dimensions[] = {
SLEG_CONDVAR(_map_dim_x, SLE_UINT32, 6, SL_MAX_VERSION),
SLEG_CONDVAR(_map_dim_y, SLE_UINT32, 6, SL_MAX_VERSION),
+ SLEG_CONDVAR(_layer_count, SLE_UINT32, 6, SL_MAX_VERSION),
SLEG_END()
};
@@ -29,13 +32,14 @@ static void Save_MAPS()
{
_map_dim_x = MapSizeX();
_map_dim_y = MapSizeY();
+ _layer_count = LayerCount();
SlGlobList(_map_dimensions);
}
static void Load_MAPS()
{
SlGlobList(_map_dimensions);
- AllocateMap(_map_dim_x, _map_dim_y);
+ AllocateMap(_map_dim_x, _map_dim_y/_layer_count, _layer_count);
}
static void Check_MAPS()
diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp
index 4d2a4b02e..0799b0b33 100644
--- a/src/saveload/order_sl.cpp
+++ b/src/saveload/order_sl.cpp
@@ -203,7 +203,14 @@ static void Ptrs_ORDR()
const SaveLoad *GetOrderListDescription()
{
static const SaveLoad _orderlist_desc[] = {
- SLE_REF(OrderList, first, REF_ORDER),
+ SLE_REF( OrderList, first, REF_ORDER),
+ SLE_CONDVAR(OrderList, current_sep_mode, SLE_UINT, SL_TTSEP_VER, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderList, num_sep_vehicles, SLE_UINT, SL_TTSEP_VER, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderList, separation_counter, SLE_UINT, SL_TTSEP_VER, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderList, separation_counter, SLE_UINT, SL_TTSEP_VER, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderList, is_separation_valid, SLE_BOOL, SL_TTSEP_VER, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderList, current_separation, SLE_INT, SL_TTSEP_VER, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderList, last_timetable_init, SLE_INT, SL_TTSEP_VER, SL_MAX_VERSION),
SLE_END()
};
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index a21f6242a..da3dab7c9 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -41,6 +41,7 @@
#include "../string_func.h"
#include "../fios.h"
#include "../error.h"
+#include "../cargodest_base.h"
#include "table/strings.h"
@@ -245,7 +246,7 @@
* 179 24810
* 180 24998
*/
-extern const uint16 SAVEGAME_VERSION = 180; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = SL_TTSEP_VER; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading
@@ -426,6 +427,7 @@ extern const ChunkHandler _autoreplace_chunk_handlers[];
extern const ChunkHandler _labelmaps_chunk_handlers[];
extern const ChunkHandler _airport_chunk_handlers[];
extern const ChunkHandler _object_chunk_handlers[];
+extern const ChunkHandler _routelink_chunk_handlers[];
extern const ChunkHandler _persistent_storage_chunk_handlers[];
/** Array of all chunks in a savegame, \c NULL terminated. */
@@ -460,6 +462,7 @@ static const ChunkHandler * const _chunk_handlers[] = {
_labelmaps_chunk_handlers,
_airport_chunk_handlers,
_object_chunk_handlers,
+ _routelink_chunk_handlers,
_persistent_storage_chunk_handlers,
NULL,
};
@@ -1214,6 +1217,7 @@ static size_t ReferenceToInt(const void *obj, SLRefType rt)
case REF_ENGINE_RENEWS: return ((const EngineRenew*)obj)->index + 1;
case REF_CARGO_PACKET: return ((const CargoPacket*)obj)->index + 1;
case REF_ORDERLIST: return ((const OrderList*)obj)->index + 1;
+ case REF_ROUTE_LINK: return ((const RouteLink*)obj)->index + 1;
case REF_STORAGE: return ((const PersistentStorage*)obj)->index + 1;
default: NOT_REACHED();
}
@@ -1284,6 +1288,10 @@ static void *IntToReference(size_t index, SLRefType rt)
if (CargoPacket::IsValidID(index)) return CargoPacket::Get(index);
SlErrorCorrupt("Referencing invalid CargoPacket");
+ case REF_ROUTE_LINK:
+ if (RouteLink::IsValidID(index)) return RouteLink::Get(index);
+ SlErrorCorrupt("Referencing invalid RouteLink");
+
case REF_STORAGE:
if (PersistentStorage::IsValidID(index)) return PersistentStorage::Get(index);
SlErrorCorrupt("Referencing invalid PersistentStorage");
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h
index c5ffbeff8..c4a26b4fa 100644
--- a/src/saveload/saveload.h
+++ b/src/saveload/saveload.h
@@ -15,6 +15,8 @@
#include "../fileio_type.h"
#include "../strings_type.h"
+#define SL_TTSEP_VER 200
+
/** Save or load result codes. */
enum SaveOrLoadResult {
SL_OK = 0, ///< completed successfully
@@ -82,9 +84,13 @@ enum SLRefType {
REF_ENGINE_RENEWS = 6, ///< Load/save a reference to an engine renewal (autoreplace).
REF_CARGO_PACKET = 7, ///< Load/save a reference to a cargo packet.
REF_ORDERLIST = 8, ///< Load/save a reference to an orderlist.
- REF_STORAGE = 9, ///< Load/save a reference to a persistent storage.
+ REF_ROUTE_LINK = 9, ///< Load/save a reference to a route link.
+ REF_STORAGE = 10, ///< Load/save a reference to a persistent storage.
};
+/* Current savegame version. */
+static const uint TL_SV = 200;
+
/** Highest possible savegame version. */
#define SL_MAX_VERSION 255
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index 9feb1f274..f7793bd8c 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -258,7 +258,10 @@ const SaveLoad *GetGoodsDesc()
SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, 14, 64),
SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, 65, 67),
SLE_CONDVAR(GoodsEntry, amount_fract, SLE_UINT8, 150, SL_MAX_VERSION),
+ SLE_CONDVAR(GoodsEntry, cargo_counter, SLE_UINT16, 180, SL_MAX_VERSION),
SLE_CONDLST(GoodsEntry, cargo.packets, REF_CARGO_PACKET, 68, SL_MAX_VERSION),
+ SLE_CONDVAR(GoodsEntry, cargo.next_start, SLE_UINT32, 180, SL_MAX_VERSION),
+ SLE_CONDLST(GoodsEntry, routes, REF_ROUTE_LINK, 180, SL_MAX_VERSION),
SLE_END()
};
diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp
index de52604f5..6041bd98e 100644
--- a/src/saveload/town_sl.cpp
+++ b/src/saveload/town_sl.cpp
@@ -249,6 +249,8 @@ static void RealSave_Town(Town *t)
SlObject(&t->received[i], _town_received_desc);
}
+ t->SaveCargoSourceSink();
+
if (IsSavegameVersionBefore(166)) return;
SlObject(&t->cargo_accepted, GetTileMatrixDesc());
@@ -287,6 +289,8 @@ static void Load_TOWN()
SlErrorCorrupt("Invalid town name generator");
}
+ t->LoadCargoSourceSink();
+
if (IsSavegameVersionBefore(166)) continue;
SlObject(&t->cargo_accepted, GetTileMatrixDesc());
@@ -298,16 +302,26 @@ static void Load_TOWN()
/* Rebuild total cargo acceptance. */
UpdateTownCargoTotal(t);
}
+
+ /* Cache the aligned tile index of the centre tile. */
+ uint town_x = (TileX(t->xy) / AcceptanceMatrix::GRID) * AcceptanceMatrix::GRID;
+ uint town_y = (TileY(t->xy) / AcceptanceMatrix::GRID) * AcceptanceMatrix::GRID;
+ t->xy_aligned= TileXY(town_x, town_y);
}
}
/** Fix pointers when loading town data. */
static void Ptrs_TOWN()
{
+ Town *t;
+
+ FOR_ALL_TOWNS(t) {
+ t->PtrsCargoSourceSink();
+ }
+
/* Don't run when savegame version lower than 161. */
if (IsSavegameVersionBefore(161)) return;
- Town *t;
FOR_ALL_TOWNS(t) {
SlObject(t, _town_desc);
}
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index a33ceb6d3..8599f3d9f 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -604,6 +604,8 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_VAR(Vehicle, vehstatus, SLE_UINT8),
SLE_CONDVAR(Vehicle, last_station_visited, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
SLE_CONDVAR(Vehicle, last_station_visited, SLE_UINT16, 5, SL_MAX_VERSION),
+ SLE_CONDVAR(Vehicle, last_station_loaded, SLE_UINT16, 180, SL_MAX_VERSION),
+ SLE_CONDVAR(Vehicle, last_order_id, SLE_UINT16, 180, SL_MAX_VERSION),
SLE_VAR(Vehicle, cargo_type, SLE_UINT8),
SLE_CONDVAR(Vehicle, cargo_subtype, SLE_UINT8, 35, SL_MAX_VERSION),
@@ -616,6 +618,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_CONDLST(Vehicle, cargo.packets, REF_CARGO_PACKET, 68, SL_MAX_VERSION),
SLE_CONDVAR(Vehicle, cargo_age_counter, SLE_UINT16, 162, SL_MAX_VERSION),
+ SLE_CONDVAR(Vehicle, travel_time, SLE_UINT32, 180, SL_MAX_VERSION),
SLE_VAR(Vehicle, day_counter, SLE_UINT8),
SLE_VAR(Vehicle, tick_counter, SLE_UINT8),
SLE_CONDVAR(Vehicle, running_ticks, SLE_UINT8, 88, SL_MAX_VERSION),
@@ -635,6 +638,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_CONDVAR(Vehicle, current_order.type, SLE_UINT8, 5, SL_MAX_VERSION),
SLE_CONDVAR(Vehicle, current_order.flags, SLE_UINT8, 5, SL_MAX_VERSION),
SLE_CONDVAR(Vehicle, current_order.dest, SLE_UINT16, 5, SL_MAX_VERSION),
+ SLE_CONDVAR(Vehicle, current_order.index, SLE_UINT16, 180, SL_MAX_VERSION),
/* Refit in current order */
SLE_CONDVAR(Vehicle, current_order.refit_cargo, SLE_UINT8, 36, SL_MAX_VERSION),