From ca7a067b7a57578e05cefec1ef647a67a9b5be07 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 10 Aug 2010 15:49:35 +0000 Subject: (svn r20435) -Codechange: move spritegroup to GRFFilePropsBase and prepare it for more spritegroups --- src/newgrf_commons.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/newgrf_commons.h') diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index 5d575973f..129e662b4 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -135,25 +135,31 @@ uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL); TileIndex GetNearbyTile(byte parameter, TileIndex tile); uint32 GetNearbyTileInformation(TileIndex tile); -/** Data related to the handling of grf files. */ +/** + * Data related to the handling of grf files. + * @tparam Tcnt Number of spritegroups + */ +template struct GRFFilePropsBase { - /** Set all data constructor for the props. */ - GRFFilePropsBase(uint local_id, const struct GRFFile *grffile) : local_id(local_id), grffile(grffile) {} - /** Simple constructor for the props. */ - GRFFilePropsBase() {} - uint16 local_id; ///< id defined by the grf file for this entity - const struct GRFFile *grffile; ///< grf file that introduced this entity + /* The lack of constructor means the default zero-ing constructor is used. */ + uint16 local_id; ///< id defined by the grf file for this entity + const struct GRFFile *grffile; ///< grf file that introduced this entity + const struct SpriteGroup *spritegroup[Tcnt]; ///< pointer to the different sprites of the entity }; /** Data related to the handling of grf files. */ -struct GRFFileProps : GRFFilePropsBase { +struct GRFFileProps : GRFFilePropsBase<1> { /** Set all default data constructor for the props. */ GRFFileProps(uint16 subst_id) : - GRFFilePropsBase(0, NULL), subst_id(subst_id), spritegroup(NULL), override(subst_id) {} + GRFFilePropsBase<1>(), subst_id(subst_id), override(subst_id) + { + /* Check whether the constructor did comply with the specs. */ + assert(this->spritegroup[0] == NULL); + } + /** Simple constructor for the props. */ - GRFFileProps() : GRFFilePropsBase() {} + GRFFileProps() : GRFFilePropsBase<1>() {} uint16 subst_id; - struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the entity uint16 override; ///< id of the entity been replaced by }; -- cgit v1.2.3-54-g00ecf