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 /src/unmovable_cmd.cpp | |
parent | ffedcc6533439009c890e513ed60ed02574d2a69 (diff) | |
download | openttd-f812e800028ae4fc65230da398c77d5d0fd695e7.tar.xz |
(svn r20336) -Codechange: rework the HQ updating
Diffstat (limited to 'src/unmovable_cmd.cpp')
-rw-r--r-- | src/unmovable_cmd.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
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); |