summaryrefslogtreecommitdiff
path: root/src/oldloader.cpp
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-10-11 11:32:43 +0000
committertruelight <truelight@openttd.org>2007-10-11 11:32:43 +0000
commit8b7f864c2dbe193ad043762697e7b1f6021cc030 (patch)
tree22a5bc3bf928300de166b0facdeda4ace1152036 /src/oldloader.cpp
parent645e5b1fb08d4f75a7940857872bc4fdc8876ef7 (diff)
downloadopenttd-8b7f864c2dbe193ad043762697e7b1f6021cc030.tar.xz
(svn r11245) -Fix r11228: the moreanimation feature made loading TTD(p) games impossible (Csaboka)
Diffstat (limited to 'src/oldloader.cpp')
-rw-r--r--src/oldloader.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index a7b93fe92..0910200e6 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -502,6 +502,29 @@ static bool LoadOldOrder(LoadgameState *ls, int num)
return true;
}
+static bool LoadOldAnimTileList(LoadgameState *ls, int num)
+{
+ /* This is sligthly hackish - we must load a chunk into an array whose
+ * address isn't static, but instead pointed to by _animated_tile_list.
+ * To achieve that, create an OldChunks list on the stack on the fly.
+ * The list cannot be static because the value of _animated_tile_list
+ * can change between calls. */
+
+ const OldChunks anim_chunk[] = {
+ OCL_VAR ( OC_TILE, 256, _animated_tile_list ),
+ OCL_END ()
+ };
+
+ if (!LoadChunk(ls, NULL, anim_chunk)) return false;
+
+ /* Update the animated tile counter by counting till the first zero in the array */
+ for (_animated_tile_count = 0; _animated_tile_count < 256; _animated_tile_count++) {
+ if (_animated_tile_list[_animated_tile_count] == 0) break;
+ }
+
+ return true;
+}
+
static const OldChunks depot_chunk[] = {
OCL_SVAR( OC_TILE, Depot, xy ),
OCL_VAR ( OC_UINT32, 1, &_old_town_index ),
@@ -1423,7 +1446,7 @@ static const OldChunks main_chunk[] = {
OCL_CHUNK(5000, LoadOldOrder ),
OCL_ASSERT( 0x4328 ),
- OCL_VAR ( OC_TILE, 256, _animated_tile_list ),
+ OCL_CHUNK( 1, LoadOldAnimTileList ),
OCL_NULL( 4 ), ///< old end-of-order-list-pointer, no longer in use
OCL_CHUNK( 255, LoadOldDepot ),
@@ -1554,10 +1577,6 @@ static bool LoadOldMain(LoadgameState *ls)
_m[i].m4 = _old_map3[i * 2 + 1];
}
- for (_animated_tile_count = 0; _animated_tile_count < 256; _animated_tile_count++) {
- if (_animated_tile_list[_animated_tile_count] == 0) break;
- }
-
for (i = 0; i < OLD_MAP_SIZE; i ++) {
switch (GetTileType(i)) {
case MP_STATION: