diff options
author | frosch <frosch@openttd.org> | 2011-09-11 15:09:13 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-09-11 15:09:13 +0000 |
commit | de27360549ec0afcc5090369cf05cfeafeda5868 (patch) | |
tree | beff25700a4261b74ac951c1c9a8d6c070c3248b /src/newgrf_commons.h | |
parent | b4d7919f8ad3bc5b079422d392d15123d8880b3b (diff) | |
download | openttd-de27360549ec0afcc5090369cf05cfeafeda5868.tar.xz |
(svn r22923) -Codechange: Move application of the construction stage into TileLayoutSpriteGroup::ProcessRegisters().
Diffstat (limited to 'src/newgrf_commons.h')
-rw-r--r-- | src/newgrf_commons.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index ec669d907..a77da3cd2 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -70,6 +70,25 @@ enum TileLayoutFlags { DECLARE_ENUM_AS_BIT_SET(TileLayoutFlags) /** + * Determines which sprite to use from a spriteset for a specific construction stage. + * @param construction_stage Construction stage 0 - 3. + * @param num_sprites Number of available sprites to select stage from. + * @return Sprite to use + */ +static inline uint GetConstructionStageOffset(uint construction_stage, uint num_sprites) +{ + assert(num_sprites > 0); + if (num_sprites > 4) num_sprites = 4; + switch (construction_stage) { + case 0: return 0; + case 1: return num_sprites > 2 ? 1 : 0; + case 2: return num_sprites > 2 ? num_sprites - 2 : 0; + case 3: return num_sprites - 1; + default: NOT_REACHED(); + } +} + +/** * Additional modifiers for items in sprite layouts. */ struct TileLayoutRegisters { |