summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/openttd.cpp9
-rw-r--r--src/saveload.cpp2
-rw-r--r--src/town_cmd.cpp12
-rw-r--r--src/unmovable_cmd.cpp6
-rw-r--r--src/unmovable_map.h20
5 files changed, 41 insertions, 8 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 01de0e3cd..b212d318e 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -64,6 +64,7 @@
#include "road_map.h"
#include "water_map.h"
#include "industry_map.h"
+#include "unmovable_map.h"
#include <stdarg.h>
@@ -1835,6 +1836,14 @@ bool AfterLoadGame()
if (CheckSavegameVersion(49)) FOR_ALL_PLAYERS(p) p->face = ConvertFromOldPlayerFace(p->face);
+ if (CheckSavegameVersion(52)) {
+ for (TileIndex t = 0; t < map_size; t++) {
+ if (IsStatueTile(t)) {
+ _m[t].m2 = CalcClosestTownFromTile(t, (uint)-1)->index;
+ }
+ }
+ }
+
return true;
}
diff --git a/src/saveload.cpp b/src/saveload.cpp
index 43c76d609..d35cb37af 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -28,7 +28,7 @@
#include "variables.h"
#include <setjmp.h>
-extern const uint16 SAVEGAME_VERSION = 51;
+extern const uint16 SAVEGAME_VERSION = 52;
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index b212af129..14079e98b 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1465,7 +1465,7 @@ static void TownActionRoadRebuild(Town* t)
NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_GENERAL, 0), t->xy, 0);
}
-static bool DoBuildStatueOfCompany(TileIndex tile)
+static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)
{
PlayerID old;
int32 r;
@@ -1485,7 +1485,7 @@ static bool DoBuildStatueOfCompany(TileIndex tile)
if (CmdFailed(r)) return false;
- MakeStatue(tile, _current_player);
+ MakeStatue(tile, _current_player, town_id);
MarkTileDirtyByTile(tile);
return true;
@@ -1493,12 +1493,12 @@ static bool DoBuildStatueOfCompany(TileIndex tile)
/**
* Search callback function for TownActionBuildStatue
- * @param data that is passed by the caller. In this case, nothing
+ * @param town_id The town_id for which we want a statue
* @return the result of the test
*/
-static bool SearchTileForStatue(TileIndex tile, uint32 data)
+static bool SearchTileForStatue(TileIndex tile, uint32 town_id)
{
- return DoBuildStatueOfCompany(tile);
+ return DoBuildStatueOfCompany(tile, town_id);
}
/**
@@ -1510,7 +1510,7 @@ static void TownActionBuildStatue(Town* t)
{
TileIndex tile = t->xy;
- if (CircularTileSearch(tile, 9, SearchTileForStatue, 0))
+ if (CircularTileSearch(tile, 9, SearchTileForStatue, t->index))
SETBIT(t->statues, _current_player); ///< Once found and built, "inform" the Town
}
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index a7f7bb46c..b531e6827 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -233,6 +233,12 @@ static int32 ClearTile_Unmovable(TileIndex tile, byte flags)
if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
+ if (IsStatue(tile)) {
+ TownID town = GetStatueTownID(tile);
+ CLRBIT(GetTown(town)->statues, _current_player);
+ InvalidateWindow(WC_TOWN_AUTHORITY, town);
+ }
+
if (flags & DC_EXEC) {
DoClearSquare(tile);
}
diff --git a/src/unmovable_map.h b/src/unmovable_map.h
index b31c932e9..28c364ff1 100644
--- a/src/unmovable_map.h
+++ b/src/unmovable_map.h
@@ -54,6 +54,23 @@ static inline bool IsCompanyHQ(TileIndex t)
return IS_INT_INSIDE(GetUnmovableType(t), UNMOVABLE_HQ_NORTH, UNMOVABLE_HQ_END);
}
+static inline bool IsStatue(TileIndex t)
+{
+ assert(IsTileType(t, MP_UNMOVABLE));
+ return GetUnmovableType(t) == UNMOVABLE_STATUE;
+}
+
+static inline bool IsStatueTile(TileIndex t)
+{
+ return IsTileType(t, MP_UNMOVABLE) && IsStatue(t);
+}
+
+static inline TownID GetStatueTownID(TileIndex t)
+{
+ assert(IsStatue(t));
+ return _m[t].m2;
+}
+
static inline byte GetCompanyHQSize(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
@@ -100,9 +117,10 @@ static inline void MakeLighthouse(TileIndex t)
MakeUnmovable(t, UNMOVABLE_LIGHTHOUSE, OWNER_NONE);
}
-static inline void MakeStatue(TileIndex t, Owner o)
+static inline void MakeStatue(TileIndex t, Owner o, TownID town_id)
{
MakeUnmovable(t, UNMOVABLE_STATUE, o);
+ _m[t].m2 = town_id;
}
static inline void MakeOwnedLand(TileIndex t, Owner o)