diff options
author | rubidium <rubidium@openttd.org> | 2010-08-03 08:32:58 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-08-03 08:32:58 +0000 |
commit | f812e800028ae4fc65230da398c77d5d0fd695e7 (patch) | |
tree | da9fdd0a058b4d6c8ad1bc6e5d5ef07d97d168a0 | |
parent | ffedcc6533439009c890e513ed60ed02574d2a69 (diff) | |
download | openttd-f812e800028ae4fc65230da398c77d5d0fd695e7.tar.xz |
(svn r20336) -Codechange: rework the HQ updating
-rw-r--r-- | src/table/unmovable_land.h | 10 | ||||
-rw-r--r-- | src/unmovable.h | 1 | ||||
-rw-r--r-- | src/unmovable_cmd.cpp | 28 | ||||
-rw-r--r-- | src/unmovable_map.h | 19 |
4 files changed, 28 insertions, 30 deletions
diff --git a/src/table/unmovable_land.h b/src/table/unmovable_land.h index 7a10e3773..a041fa22b 100644 --- a/src/table/unmovable_land.h +++ b/src/table/unmovable_land.h @@ -101,9 +101,9 @@ static const DrawTileSprites _unmovable_display_datas[] = { #undef TILE_SPRITE_LINE static const UnmovableSpec _original_unmovable[] = { - {STR_LAI_UNMOVABLE_DESCRIPTION_TRANSMITTER, 1, 1}, - {STR_LAI_UNMOVABLE_DESCRIPTION_LIGHTHOUSE, 1, 1}, - {STR_TOWN_BUILDING_NAME_STATUE_1, 1, 1}, - {STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_OWNED_LAND, 10, 2}, - {STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_HEADQUARTERS, 1, 1}, + {STR_LAI_UNMOVABLE_DESCRIPTION_TRANSMITTER, 0x11, 1, 1}, + {STR_LAI_UNMOVABLE_DESCRIPTION_LIGHTHOUSE, 0x11, 1, 1}, + {STR_TOWN_BUILDING_NAME_STATUE_1, 0x11, 1, 1}, + {STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_OWNED_LAND, 0x11, 10, 2}, + {STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_HEADQUARTERS, 0x22, 1, 1}, }; diff --git a/src/unmovable.h b/src/unmovable.h index 330373cb8..e0cf4e597 100644 --- a/src/unmovable.h +++ b/src/unmovable.h @@ -21,6 +21,7 @@ void UpdateCompanyHQ(Company *c, uint score); /** An (unmovable) object that isn't use for transport, industries or houses. */ struct UnmovableSpec { StringID name; ///< The name for this object. + uint8 size; ///< The size of this objects; low nibble for X, high nibble for Y. uint8 build_cost_multiplier; ///< Build cost multiplier per tile. uint8 clear_cost_multiplier; ///< Clear cost multiplier per tile. diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp index 697197beb..2db837823 100644 --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -46,8 +46,27 @@ return UnmovableSpec::Get(GetUnmovableType(tile)); } +/** + * Increase the animation stage of a whole structure. + * @param northern The northern tile of the structure. + * @pre GetUnmovableOffset(northern) == 0 + */ +void IncreaseAnimationStage(TileIndex northern) +{ + assert(GetUnmovableOffset(northern) == 0); + const UnmovableSpec *spec = UnmovableSpec::GetByTile(northern); + + TileArea ta(northern, GB(spec->size, 0, 4), GB(spec->size, 4, 4)); + TILE_AREA_LOOP(t, ta) { + SetUnmovableAnimationStage(t, GetUnmovableAnimationStage(t) + 1); + MarkTileDirtyByTile(t); + } +} + /** We encode the company HQ size in the animation stage. */ #define GetCompanyHQSize GetUnmovableAnimationStage +/** We encode the company HQ size in the animation stage. */ +#define IncreaseCompanyHQSize IncreaseAnimationStage /** * Destroy a HQ. @@ -91,12 +110,9 @@ void UpdateCompanyHQ(Company *c, uint score) (val++, score < 720) || (val++, true); - EnlargeCompanyHQ(tile, val); - - MarkTileDirtyByTile(tile); - MarkTileDirtyByTile(tile + TileDiffXY(0, 1)); - MarkTileDirtyByTile(tile + TileDiffXY(1, 0)); - MarkTileDirtyByTile(tile + TileDiffXY(1, 1)); + while (GetCompanyHQSize(tile) < val) { + IncreaseCompanyHQSize(tile); + } } extern CommandCost CheckFlatLand(TileArea tile_area, DoCommandFlag flags); diff --git a/src/unmovable_map.h b/src/unmovable_map.h index ca9f2120b..44395f4d8 100644 --- a/src/unmovable_map.h +++ b/src/unmovable_map.h @@ -153,25 +153,6 @@ static inline void SetUnmovableOffset(TileIndex t, uint8 offset) _m[t].m3 = offset; } -/** - * Enlarge the given HQ to the given size. If the new size - * is larger than the current size, nothing happens. - * @param t the tile of the HQ. - * @param size the new size of the HQ. - * @pre t is the northern tile of the HQ - */ -static inline void EnlargeCompanyHQ(TileIndex t, byte size) -{ - assert(GetUnmovableOffset(t) == 0); - assert(size <= 4); - if (size <= GetUnmovableAnimationStage(t)) return; - - SetUnmovableAnimationStage(t, size); - SetUnmovableAnimationStage(t + TileDiffXY(0, 1), size); - SetUnmovableAnimationStage(t + TileDiffXY(1, 0), size); - SetUnmovableAnimationStage(t + TileDiffXY(1, 1), size); -} - /** * Make an Unmovable tile. |