# HG changeset patch # User truelight # Date 1173364472 0 # Node ID 82012e77b10ce3d2bf1725e08809948b780c0ed2 # Parent 5f66659ae0484f23e461b90b09dbcf7ab80b5775 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it diff -r 5f66659ae048 -r 82012e77b10c src/openttd.cpp --- a/src/openttd.cpp Thu Mar 08 13:54:19 2007 +0000 +++ b/src/openttd.cpp Thu Mar 08 14:34:32 2007 +0000 @@ -64,6 +64,7 @@ #include "road_map.h" #include "water_map.h" #include "industry_map.h" +#include "unmovable_map.h" #include @@ -1835,6 +1836,14 @@ 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 -r 5f66659ae048 -r 82012e77b10c src/saveload.cpp --- a/src/saveload.cpp Thu Mar 08 13:54:19 2007 +0000 +++ b/src/saveload.cpp Thu Mar 08 14:34:32 2007 +0000 @@ -28,7 +28,7 @@ #include "variables.h" #include -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 -r 5f66659ae048 -r 82012e77b10c src/town_cmd.cpp --- a/src/town_cmd.cpp Thu Mar 08 13:54:19 2007 +0000 +++ b/src/town_cmd.cpp Thu Mar 08 14:34:32 2007 +0000 @@ -1465,7 +1465,7 @@ 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 @@ if (CmdFailed(r)) return false; - MakeStatue(tile, _current_player); + MakeStatue(tile, _current_player, town_id); MarkTileDirtyByTile(tile); return true; @@ -1493,12 +1493,12 @@ /** * 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 @@ { 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 -r 5f66659ae048 -r 82012e77b10c src/unmovable_cmd.cpp --- a/src/unmovable_cmd.cpp Thu Mar 08 13:54:19 2007 +0000 +++ b/src/unmovable_cmd.cpp Thu Mar 08 14:34:32 2007 +0000 @@ -233,6 +233,12 @@ 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 -r 5f66659ae048 -r 82012e77b10c src/unmovable_map.h --- a/src/unmovable_map.h Thu Mar 08 13:54:19 2007 +0000 +++ b/src/unmovable_map.h Thu Mar 08 14:34:32 2007 +0000 @@ -54,6 +54,23 @@ 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 @@ 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)