summaryrefslogtreecommitdiff
path: root/src/saveload/afterload.cpp
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/afterload.cpp
parent2080a8c16ff4190a8a32f6f3618323f2d3671f5c (diff)
downloadopenttd-35d7e8bca4e24bc211ed24d07fba62193d5f5f31.tar.xz
(svn r25833) -Codechange: Move ObjectType from map array into pool item.
Diffstat (limited to 'src/saveload/afterload.cpp')
-rw-r--r--src/saveload/afterload.cpp36
1 files changed, 28 insertions, 8 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();