diff options
author | celestar <celestar@openttd.org> | 2006-03-31 09:09:26 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2006-03-31 09:09:26 +0000 |
commit | 20c29f10df67efcada2bd3275863848a21d5040f (patch) | |
tree | 538459d686ebc5fe02d81cb3357858894f1b241a | |
parent | 1c19e7be00b8547df8694fa118f294492c7ef640 (diff) | |
download | openttd-20c29f10df67efcada2bd3275863848a21d5040f.tar.xz |
(svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
-rw-r--r-- | unmovable_cmd.c | 19 | ||||
-rw-r--r-- | unmovable_map.h | 11 |
2 files changed, 17 insertions, 13 deletions
diff --git a/unmovable_cmd.c b/unmovable_cmd.c index 497a61167..da6b8cf2c 100644 --- a/unmovable_cmd.c +++ b/unmovable_cmd.c @@ -67,20 +67,13 @@ void UpdateCompanyHQ(Player *p, uint score) if (tile == 0) return; - (val = 128, score < 170) || - (val+= 4, score < 350) || - (val+= 4, score < 520) || - (val+= 4, score < 720) || - (val+= 4, true); - -/* house is already big enough */ - if (val <= _m[tile].m5) - return; + (val = 0, score < 170) || + (val++, score < 350) || + (val++, score < 520) || + (val++, score < 720) || + (val++, true); - _m[tile + TileDiffXY(0, 0)].m5 = val; - _m[tile + TileDiffXY(0, 1)].m5 = ++val; - _m[tile + TileDiffXY(1, 0)].m5 = ++val; - _m[tile + TileDiffXY(1, 1)].m5 = ++val; + EnlargeCompanyHQ(tile, val); MarkTileDirtyByTile(tile + TileDiffXY(0, 0)); MarkTileDirtyByTile(tile + TileDiffXY(0, 1)); diff --git a/unmovable_map.h b/unmovable_map.h index 6eb164956..fed814ced 100644 --- a/unmovable_map.h +++ b/unmovable_map.h @@ -39,6 +39,17 @@ static inline bool IsOwnedLandTile(TileIndex t) } +static inline void EnlargeCompanyHQ(TileIndex t, byte size) +{ + if (size <= _m[t].m5 - UNMOVABLE_HQ_NORTH) return; + + _m[t + TileDiffXY(0, 0)].m5 = UNMOVABLE_HQ_NORTH + size * 4; + _m[t + TileDiffXY(0, 1)].m5 = UNMOVABLE_HQ_WEST + size * 4; + _m[t + TileDiffXY(1, 0)].m5 = UNMOVABLE_HQ_EAST + size * 4; + _m[t + TileDiffXY(1, 1)].m5 = UNMOVABLE_HQ_SOUTH + size * 4; +} + + static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o) { SetTileType(t, MP_UNMOVABLE); |