(svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated

This commit is contained in:
rubidium
2009-07-01 14:51:05 +00:00
parent 4e15c61aff
commit 3b44f44287
5 changed files with 37 additions and 1 deletions

View File

@@ -30,6 +30,7 @@
#include "../ai/ai.hpp"
#include "../town.h"
#include "../economy_base.h"
#include "../animated_tile_func.h"
#include "table/strings.h"
@@ -1890,6 +1891,30 @@ bool AfterLoadGame()
}
}
if (CheckSavegameVersion(122)) {
/* Animated tiles would sometimes not be actually animated or
* in case of old savegames duplicate. */
extern TileIndex *_animated_tile_list;
extern uint _animated_tile_count;
for (uint i = 0; i < _animated_tile_count; /* Nothing */) {
/* Remove if tile is not animated */
bool remove = _tile_type_procs[GetTileType(_animated_tile_list[i])]->animate_tile_proc == NULL;
/* and remove if duplicate */
for (uint j = 0; !remove && j < i; j++) {
remove = _animated_tile_list[i] == _animated_tile_list[j];
}
if (remove) {
DeleteAnimatedTile(_animated_tile_list[i]);
} else {
i++;
}
}
}
AfterLoadLabelMaps();
GamelogPrintDebug(1);