diff options
author | rubidium <rubidium@openttd.org> | 2006-12-30 11:51:37 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2006-12-30 11:51:37 +0000 |
commit | c7b1fd6fc2dd73e9b9bf150b5bb81e340fa75958 (patch) | |
tree | 8d29ae84b471412043a0fcc80405fdc3cb907940 /industry_map.h | |
parent | 34bc8008d3d5c65c18bd2762fa7279a30b44e29c (diff) | |
download | openttd-c7b1fd6fc2dd73e9b9bf150b5bb81e340fa75958.tar.xz |
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
Diffstat (limited to 'industry_map.h')
-rw-r--r-- | industry_map.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/industry_map.h b/industry_map.h index bef925ef6..b55ecd749 100644 --- a/industry_map.h +++ b/industry_map.h @@ -233,4 +233,64 @@ static inline void SetIndustryAnimationLoop(TileIndex tile, byte count) _m[tile].m4 = count; } +/** + * Get the animation state + * @param tile the tile to get the animation state of + * @pre IsTileType(tile, MP_INDUSTRY) + */ +static inline byte GetIndustryAnimationState(TileIndex tile) +{ + assert(IsTileType(tile, MP_INDUSTRY)); + switch (GetIndustryGfx(tile)) { + case GFX_POWERPLANT_SPARKS: + return GB(_m[tile].m1, 2, 5); + break; + + case GFX_OILWELL_ANIMATED_1: + case GFX_OILWELL_ANIMATED_2: + case GFX_OILWELL_ANIMATED_3: + return GB(_m[tile].m1, 0, 2); + + case GFX_COAL_MINE_TOWER_ANIMATED: + case GFX_COPPER_MINE_TOWER_ANIMATED: + case GFX_GOLD_MINE_TOWER_ANIMATED: + return _m[tile].m1; + + default: + return _m[tile].m3; + } +} + +/** + * Set the animation state + * @param tile the tile to set the animation state of + * @param count the new animation state + * @pre IsTileType(tile, MP_INDUSTRY) + */ +static inline void SetIndustryAnimationState(TileIndex tile, byte state) +{ + assert(IsTileType(tile, MP_INDUSTRY)); + switch (GetIndustryGfx(tile)) { + case GFX_POWERPLANT_SPARKS: + SB(_m[tile].m1, 2, 5, state); + break; + + case GFX_OILWELL_ANIMATED_1: + case GFX_OILWELL_ANIMATED_2: + case GFX_OILWELL_ANIMATED_3: + SB(_m[tile].m1, 0, 2, state); + break; + + case GFX_COAL_MINE_TOWER_ANIMATED: + case GFX_COPPER_MINE_TOWER_ANIMATED: + case GFX_GOLD_MINE_TOWER_ANIMATED: + _m[tile].m1 = state; + break; + + default: + _m[tile].m3 = state; + break; + } +} + #endif /* INDUSTRY_MAP_H */ |