From ffedcc6533439009c890e513ed60ed02574d2a69 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 3 Aug 2010 08:16:06 +0000 Subject: (svn r20335) -Codechange: change the name of some unmovable map accessors --- src/saveload/afterload.cpp | 4 ++-- src/unmovable_cmd.cpp | 5 ++++- src/unmovable_map.h | 49 +++++++++++++++++++++++----------------------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index db0915c3d..65b9736a4 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1803,8 +1803,8 @@ bool AfterLoadGame() /* Reordering/generalisation of the unmovable bits. */ UnmovableType type = GetUnmovableType(t); - SetCompanyHQSize(t, type == UNMOVABLE_HQ ? GB(_m[t].m3, 2, 3) : 0); - SetCompanyHQSection(t, type == UNMOVABLE_HQ ? GB(_m[t].m3, 1, 1) << 4 | GB(_m[t].m3, 0, 1) : 0); + SetUnmovableAnimationStage(t, type == UNMOVABLE_HQ ? GB(_m[t].m3, 2, 3) : 0); + SetUnmovableOffset(t, type == UNMOVABLE_HQ ? GB(_m[t].m3, 1, 1) << 4 | GB(_m[t].m3, 0, 1) : 0); /* Make sure those bits are clear as well! */ _m[t].m4 = 0; diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp index 41249c3ea..697197beb 100644 --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -46,6 +46,9 @@ return UnmovableSpec::Get(GetUnmovableType(tile)); } +/** We encode the company HQ size in the animation stage. */ +#define GetCompanyHQSize GetUnmovableAnimationStage + /** * Destroy a HQ. * During normal gameplay you can only implicitely destroy a HQ when you are @@ -255,7 +258,7 @@ static void DrawTile_Unmovable(TileInfo *ti) PaletteID palette = COMPANY_SPRITE_COLOUR(GetTileOwner(ti->tile)); - uint8 offset = GetCompanyHQSection(ti->tile); + uint8 offset = GetUnmovableOffset(ti->tile); const DrawTileSprites *t = &_unmovable_display_datas[GetCompanyHQSize(ti->tile) << 2 | GB(offset, 4, 1) << 1 | GB(offset, 0, 1)]; DrawGroundSprite(t->ground.sprite, palette); diff --git a/src/unmovable_map.h b/src/unmovable_map.h index fd88d116a..ca9f2120b 100644 --- a/src/unmovable_map.h +++ b/src/unmovable_map.h @@ -106,52 +106,51 @@ static inline TownID GetStatueTownID(TileIndex t) } /** - * Get the 'stage' of the HQ. - * @param t a tile of the HQ. + * Get animation stage/counter of this tile. + * @param t The tile to query. * @pre IsTileType(t, MP_UNMOVABLE) - * @return the 'stage' of the HQ. + * @return The animation 'stage' of the tile. */ -static inline byte GetCompanyHQSize(TileIndex t) +static inline byte GetUnmovableAnimationStage(TileIndex t) { assert(IsTileType(t, MP_UNMOVABLE)); return GB(_m[t].m6, 2, 4); } /** - * Set the 'stage' of the HQ. - * @param t a tile of the HQ. - * @param size the actual stage of the HQ + * Set animation stage/counter of this tile. + * @param t The tile to query. + * @param stage The stage of this tile. * @pre IsTileType(t, MP_UNMOVABLE) */ -static inline void SetCompanyHQSize(TileIndex t, uint8 size) +static inline void SetUnmovableAnimationStage(TileIndex t, uint8 stage) { assert(IsTileType(t, MP_UNMOVABLE)); - SB(_m[t].m6, 2, 4, size); + SB(_m[t].m6, 2, 4, stage); } /** - * Get the 'section' of the HQ. - * The scetion is in fact which side of teh HQ the tile represent - * @param t a tile of the HQ. + * Get offset to the northern most tile. + * @param t The tile to get the offset from. + * @return The offset to the northern most tile of this structure. * @pre IsTileType(t, MP_UNMOVABLE) - * @return the 'section' of the HQ. */ -static inline byte GetCompanyHQSection(TileIndex t) +static inline byte GetUnmovableOffset(TileIndex t) { assert(IsTileType(t, MP_UNMOVABLE)); return _m[t].m3; } /** - * Set the 'section' of the HQ. - * @param t a tile of the HQ. - * @param section to be set. + * Set offset to the northern most tile. + * @param t The tile to set the offset of. + * @param offset The offset to the northern most tile of this structure. * @pre IsTileType(t, MP_UNMOVABLE) */ -static inline void SetCompanyHQSection(TileIndex t, uint8 section) +static inline void SetUnmovableOffset(TileIndex t, uint8 offset) { assert(IsTileType(t, MP_UNMOVABLE)); - _m[t].m3 = section; + _m[t].m3 = offset; } /** @@ -163,14 +162,14 @@ static inline void SetCompanyHQSection(TileIndex t, uint8 section) */ static inline void EnlargeCompanyHQ(TileIndex t, byte size) { - assert(GetCompanyHQSection(t) == 0); + assert(GetUnmovableOffset(t) == 0); assert(size <= 4); - if (size <= GetCompanyHQSize(t)) return; + if (size <= GetUnmovableAnimationStage(t)) return; - SetCompanyHQSize(t, size); - SetCompanyHQSize(t + TileDiffXY(0, 1), size); - SetCompanyHQSize(t + TileDiffXY(1, 0), size); - SetCompanyHQSize(t + TileDiffXY(1, 1), size); + SetUnmovableAnimationStage(t, size); + SetUnmovableAnimationStage(t + TileDiffXY(0, 1), size); + SetUnmovableAnimationStage(t + TileDiffXY(1, 0), size); + SetUnmovableAnimationStage(t + TileDiffXY(1, 1), size); } -- cgit v1.2.3-54-g00ecf