animated_tile_sl.cpp
Go to the documentation of this file.00001
00002
00005 #include "../stdafx.h"
00006 #include "../tile_type.h"
00007 #include "../core/alloc_func.hpp"
00008
00009 #include "saveload.h"
00010
00011 extern TileIndex *_animated_tile_list;
00012 extern uint _animated_tile_count;
00013 extern uint _animated_tile_allocated;
00014
00018 static void Save_ANIT()
00019 {
00020 SlSetLength(_animated_tile_count * sizeof(*_animated_tile_list));
00021 SlArray(_animated_tile_list, _animated_tile_count, SLE_UINT32);
00022 }
00023
00027 static void Load_ANIT()
00028 {
00029
00030 if (CheckSavegameVersion(80)) {
00031
00032 SlArray(_animated_tile_list, 256, CheckSavegameVersion(6) ? (SLE_FILE_U16 | SLE_VAR_U32) : SLE_UINT32);
00033
00034 for (_animated_tile_count = 0; _animated_tile_count < 256; _animated_tile_count++) {
00035 if (_animated_tile_list[_animated_tile_count] == 0) break;
00036 }
00037 return;
00038 }
00039
00040 _animated_tile_count = (uint)SlGetFieldLength() / sizeof(*_animated_tile_list);
00041
00042
00043 _animated_tile_allocated = 256;
00044 while (_animated_tile_allocated < _animated_tile_count) _animated_tile_allocated *= 2;
00045
00046 _animated_tile_list = ReallocT<TileIndex>(_animated_tile_list, _animated_tile_allocated);
00047 SlArray(_animated_tile_list, _animated_tile_count, SLE_UINT32);
00048 }
00049
00054 extern const ChunkHandler _animated_tile_chunk_handlers[] = {
00055 { 'ANIT', Save_ANIT, Load_ANIT, CH_RIFF | CH_LAST},
00056 };