summaryrefslogtreecommitdiff
path: root/src/newgrf_spritegroup.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-08-08 21:26:58 +0000
committerfrosch <frosch@openttd.org>2011-08-08 21:26:58 +0000
commitd10168f21183d1097b88ebe86ed5b5a9b1b3ef5e (patch)
tree8545d23253e91ffa08acb30046f4c16bd176bb48 /src/newgrf_spritegroup.h
parent68068b6eff894c0702bc69462aa7657eaf26c8ff (diff)
downloadopenttd-d10168f21183d1097b88ebe86ed5b5a9b1b3ef5e.tar.xz
(svn r22731) -Fix: [NewGRF] The construction stage sprites were incorrectly selected in cases other than 1 or 4 sprites per set.
Diffstat (limited to 'src/newgrf_spritegroup.h')
-rw-r--r--src/newgrf_spritegroup.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h
index 811547832..94ec430d4 100644
--- a/src/newgrf_spritegroup.h
+++ b/src/newgrf_spritegroup.h
@@ -292,6 +292,25 @@ struct TileLayoutSpriteGroup : SpriteGroup {
NewGRFSpriteLayout dts;
const DrawTileSprites *ProcessRegisters(uint8 *stage) const;
+
+ /**
+ * Determines which sprite to use from a spriteset for a specific construction stage.
+ * @param construction_stage Construction stage 0 - 3.
+ * @return Sprite to use
+ */
+ uint GetConstructionStageOffset(uint construction_stage) const
+ {
+ uint num_sprites = this->num_building_stages;
+ 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();
+ }
+ }
};
struct IndustryProductionSpriteGroup : SpriteGroup {