Mercurial > hg > openttd
changeset 6257:d7d39048e2ee draft
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
author | truelight <truelight@openttd.org> |
---|---|
date | Thu, 08 Mar 2007 14:34:32 +0000 |
parents | f7a3e330a35c |
children | 51ac8dd32194 |
files | src/openttd.cpp src/saveload.cpp src/town_cmd.cpp src/unmovable_cmd.cpp src/unmovable_map.h |
diffstat | 5 files changed, 41 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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; }
--- 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!
--- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -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 }
--- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -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); }
--- a/src/unmovable_map.h +++ b/src/unmovable_map.h @@ -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)