summaryrefslogtreecommitdiff
path: root/src/newgrf_commons.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-08-10 15:49:35 +0000
committerrubidium <rubidium@openttd.org>2010-08-10 15:49:35 +0000
commitca7a067b7a57578e05cefec1ef647a67a9b5be07 (patch)
tree2ddc3cc481a332a28f072dda0af921ad0b69799b /src/newgrf_commons.h
parent21e4e7ce0699408fd2d4f1e1d1c97ccfd0fa74bc (diff)
downloadopenttd-ca7a067b7a57578e05cefec1ef647a67a9b5be07.tar.xz
(svn r20435) -Codechange: move spritegroup to GRFFilePropsBase and prepare it for more spritegroups
Diffstat (limited to 'src/newgrf_commons.h')
-rw-r--r--src/newgrf_commons.h28
1 files changed, 17 insertions, 11 deletions
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 <size_t Tcnt>
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
};