summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-10-12 16:30:42 +0000
committerfrosch <frosch@openttd.org>2013-10-12 16:30:42 +0000
commit35d7e8bca4e24bc211ed24d07fba62193d5f5f31 (patch)
tree5bd7a702966ef90ce1c815b3d73d380e6be0e628 /src/saveload
parent2080a8c16ff4190a8a32f6f3618323f2d3671f5c (diff)
downloadopenttd-35d7e8bca4e24bc211ed24d07fba62193d5f5f31.tar.xz
(svn r25833) -Codechange: Move ObjectType from map array into pool item.
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp36
-rw-r--r--src/saveload/object_sl.cpp3
-rw-r--r--src/saveload/saveload.cpp3
3 files changed, 31 insertions, 11 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 4643530aa..5f56b0a08 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -248,6 +248,12 @@ static void InitializeWindowsAndCaches()
}
}
+ /* Count number of objects per type */
+ Object *o;
+ FOR_ALL_OBJECTS(o) {
+ Object::IncTypeCount(o->type);
+ }
+
RecomputePrices();
GroupStatistics::UpdateAfterLoad();
@@ -1444,7 +1450,7 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(52)) {
for (TileIndex t = 0; t < map_size; t++) {
- if (IsTileType(t, MP_OBJECT) && GetObjectType(t) == OBJECT_STATUE) {
+ if (IsTileType(t, MP_OBJECT) && _m[t].m5 == OBJECT_STATUE) {
_m[t].m2 = CalcClosestTownFromTile(t)->index;
}
}
@@ -1940,7 +1946,7 @@ bool AfterLoadGame()
if (!IsTileType(t, MP_OBJECT)) continue;
/* Reordering/generalisation of the object bits. */
- ObjectType type = GetObjectType(t);
+ ObjectType type = _m[t].m5;
SB(_m[t].m6, 2, 4, type == OBJECT_HQ ? GB(_m[t].m3, 2, 3) : 0);
_m[t].m3 = type == OBJECT_HQ ? GB(_m[t].m3, 1, 1) | GB(_m[t].m3, 0, 1) << 4 : 0;
@@ -1967,7 +1973,7 @@ bool AfterLoadGame()
if (offset == 0) {
/* No offset, so make the object. */
- ObjectType type = GetObjectType(t);
+ ObjectType type = _m[t].m5;
int size = type == OBJECT_HQ ? 2 : 1;
if (!Object::CanAllocateItem()) {
@@ -2200,11 +2206,6 @@ bool AfterLoadGame()
}
}
- if (IsSavegameVersionBefore(127)) {
- Station *st;
- FOR_ALL_STATIONS(st) UpdateStationAcceptance(st, false);
- }
-
if (IsSavegameVersionBefore(128)) {
const Depot *d;
FOR_ALL_DEPOTS(d) {
@@ -2814,6 +2815,25 @@ bool AfterLoadGame()
_settings_game.locale.units_height = Clamp(_old_units, 0, 2);
}
+ if (IsSavegameVersionBefore(185)) {
+ /* Move ObjectType from map to pool */
+ for (TileIndex t = 0; t < map_size; t++) {
+ if (IsTileType(t, MP_OBJECT)) {
+ Object *o = Object::GetByTile(t);
+ o->type = _m[t].m5;
+ _m[t].m5 = 0; // cleanup for next usage
+ }
+ }
+ }
+
+
+
+ /* Station acceptance is some kind of cache */
+ if (IsSavegameVersionBefore(127)) {
+ Station *st;
+ FOR_ALL_STATIONS(st) UpdateStationAcceptance(st, false);
+ }
+
/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();
diff --git a/src/saveload/object_sl.cpp b/src/saveload/object_sl.cpp
index 037fc6b4d..4e8539793 100644
--- a/src/saveload/object_sl.cpp
+++ b/src/saveload/object_sl.cpp
@@ -24,6 +24,7 @@ static const SaveLoad _object_desc[] = {
SLE_VAR(Object, build_date, SLE_UINT32),
SLE_CONDVAR(Object, colour, SLE_UINT8, 148, SL_MAX_VERSION),
SLE_CONDVAR(Object, view, SLE_UINT8, 155, SL_MAX_VERSION),
+ SLE_CONDVAR(Object, type, SLE_UINT16, 186, SL_MAX_VERSION),
SLE_END()
};
@@ -56,8 +57,6 @@ static void Ptrs_OBJS()
if (IsSavegameVersionBefore(148) && !IsTileType(o->location.tile, MP_OBJECT)) {
/* Due to a small bug stale objects could remain. */
delete o;
- } else {
- Object::IncTypeCount(GetObjectType(o->location.tile));
}
}
}
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 8f58ea381..086dd41f3 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -251,8 +251,9 @@
* 183 25363
* 184 25508
* 185 25620
+ * 186 TODO
*/
-extern const uint16 SAVEGAME_VERSION = 185; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 186; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading