Mercurial > hg > openttd
changeset 12292:a6d140648fde draft
(svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
author | rubidium <rubidium@openttd.org> |
---|---|
date | Wed, 01 Jul 2009 14:51:05 +0000 |
parents | 1a6cc2073e2f |
children | ae8e7e6cd2a6 |
files | src/industry_cmd.cpp src/landscape.cpp src/saveload/afterload.cpp src/station_cmd.cpp src/tile_cmd.h |
diffstat | 5 files changed, 37 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -141,6 +141,10 @@ 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);
--- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -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 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); }
--- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -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 @@ } } + 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);
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1003,6 +1003,8 @@ } } + /* 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 @@ 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;