summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/industry_cmd.cpp4
-rw-r--r--src/landscape.cpp4
-rw-r--r--src/saveload/afterload.cpp25
-rw-r--r--src/station_cmd.cpp3
-rw-r--r--src/tile_cmd.h2
5 files changed, 37 insertions, 1 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 0f7bf1a7c..92d510cd2 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -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);
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 372cf5d50..bf1d4414e 100644
--- 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 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);
}
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 26ca23b22..afe2060a7 100644
--- 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 @@ 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);
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index bd2c41dfe..7db3d6d6c 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -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;
diff --git a/src/tile_cmd.h b/src/tile_cmd.h
index 1b6c44128..59504ec1f 100644
--- a/src/tile_cmd.h
+++ b/src/tile_cmd.h
@@ -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);
}