diff options
author | Michael Lutz <michi@icosahedron.de> | 2018-04-15 01:15:26 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2018-04-15 20:49:29 +0200 |
commit | 7dd6027194a5fb12ac5fa074c9c7a055a67ad41a (patch) | |
tree | 15d8691eb06537e86520dec53e8d2feca55ba7dd /src/saveload/oldloader_sl.cpp | |
parent | 4851feb10270f893b09cc03f7297022c942e0d1f (diff) | |
download | openttd-7dd6027194a5fb12ac5fa074c9c7a055a67ad41a.tar.xz |
Codechange: Use a SmallVec for the animated tile list instead of replicating most of the logic.
Diffstat (limited to 'src/saveload/oldloader_sl.cpp')
-rw-r--r-- | src/saveload/oldloader_sl.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 0c5716681..61a5aa5c6 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -28,6 +28,7 @@ #include "../engine_func.h" #include "../company_base.h" #include "../disaster_vehicle.h" +#include "../core/smallvec_type.hpp" #include "saveload_internal.h" #include "oldloader.h" @@ -490,8 +491,7 @@ static inline uint RemapOrderIndex(uint x) return _savegame_type == SGT_TTO ? (x - 0x1AC4) / 2 : (x - 0x1C18) / 2; } -extern TileIndex *_animated_tile_list; -extern uint _animated_tile_count; +extern SmallVector<TileIndex, 256> _animated_tiles; extern char *_old_name_array; static uint32 _old_town_index; @@ -640,22 +640,18 @@ static bool LoadOldOrder(LoadgameState *ls, int num) static bool LoadOldAnimTileList(LoadgameState *ls, int num) { - /* This is slightly 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. */ - + TileIndex anim_list[256]; const OldChunks anim_chunk[] = { - OCL_VAR ( OC_TILE, 256, _animated_tile_list ), + OCL_VAR ( OC_TILE, 256, anim_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; + /* The first zero in the loaded array indicates the end of the list. */ + for (int i = 0; i < 256; i++) { + if (anim_list[i] == 0) break; + *_animated_tiles.Append() = anim_list[i]; } return true; |