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

pull/155/head
rubidium 15 years ago
parent 4e15c61aff
commit 3b44f44287

@ -141,6 +141,10 @@ Industry::~Industry()
if (GetIndustryIndex(tile_cur) == this->index) {
/* MakeWaterKeepingClass() can also handle 'land' */
MakeWaterKeepingClass(tile_cur, OWNER_NONE);
/* MakeWaterKeepingClass() doesn't remove animation if the tiles
* become watery, but be on the safe side an always remote it. */
DeleteAnimatedTile(tile_cur);
}
} else if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
DeleteOilRig(tile_cur);

@ -22,6 +22,7 @@
#include "effectvehicle_func.h"
#include "landscape_type.h"
#include "settings_type.h"
#include "animated_tile_func.h"
#include "table/sprites.h"
@ -471,6 +472,9 @@ void DrawFoundation(TileInfo *ti, Foundation f)
void DoClearSquare(TileIndex tile)
{
/* If the tile can have animation and we clear it, delete it from the animated tile list. */
if (_tile_type_procs[GetTileType(tile)]->animate_tile_proc != NULL) DeleteAnimatedTile(tile);
MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0);
MarkTileDirtyByTile(tile);
}

@ -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);

@ -1003,6 +1003,8 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, DoCommandFlag flags, uin
}
}
/* Remove animation if overbuilding */
DeleteAnimatedTile(tile);
byte old_specindex = IsTileType(tile, MP_STATION) ? GetCustomStationSpecIndex(tile) : 0;
MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, (RailType)GB(p1, 0, 4));
/* Free the spec if we overbuild something */
@ -2948,6 +2950,7 @@ void BuildOilRig(TileIndex tile)
st->string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG);
assert(IsTileType(tile, MP_INDUSTRY));
DeleteAnimatedTile(tile);
MakeOilrig(tile, st->index, GetWaterClass(tile));
st->owner = OWNER_NONE;

@ -174,7 +174,7 @@ static inline void AddProducedCargo(TileIndex tile, CargoArray &produced)
static inline void AnimateTile(TileIndex tile)
{
AnimateTileProc *proc = _tile_type_procs[GetTileType(tile)]->animate_tile_proc;
if (proc == NULL) return;
assert(proc != NULL);
proc(tile);
}

Loading…
Cancel
Save