summaryrefslogtreecommitdiff
path: root/src/newgrf_commons.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-05-14 17:25:45 +0000
committerfrosch <frosch@openttd.org>2011-05-14 17:25:45 +0000
commit7415b9cca278e86db5ba00b84aa535057279ef37 (patch)
tree9f01e323319a68661a0ebcd8d846fdf52c70e0d3 /src/newgrf_commons.h
parent3183cb79079a20739e68966de2c0c0356e3c67b1 (diff)
downloadopenttd-7415b9cca278e86db5ba00b84aa535057279ef37.tar.xz
(svn r22456) -Codechange: Derive NewGRFSpriteLayout from DrawTileSprites for spritelayouts allocated on the heap, and make use of constructors and destructors.
Diffstat (limited to 'src/newgrf_commons.h')
-rw-r--r--src/newgrf_commons.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h
index 171ccf759..1ddfdc181 100644
--- a/src/newgrf_commons.h
+++ b/src/newgrf_commons.h
@@ -16,8 +16,10 @@
#define NEWGRF_COMMONS_H
#include "tile_type.h"
+#include "sprite.h"
+#include "core/alloc_type.hpp"
-/** Contextx for tile accesses */
+/** Context for tile accesses */
enum TileContext {
TCX_NORMAL, ///< Nothing special.
TCX_UPPER_HALFTILE, ///< Querying information about the upper part of a tile with halftile foundation.
@@ -25,6 +27,32 @@ enum TileContext {
};
/**
+ * NewGRF supplied spritelayout.
+ * In contrast to #DrawTileSprites this struct is for allocated
+ * layouts on the heap. It allocates data and frees them on destruction.
+ */
+struct NewGRFSpriteLayout : ZeroedMemoryAllocator, DrawTileSprites {
+ void Allocate(uint num_sprites);
+ void Clone(const DrawTileSeqStruct *source);
+
+ /**
+ * Clone a spritelayout.
+ * @param source The spritelayout to copy.
+ */
+ void Clone(const DrawTileSprites *source)
+ {
+ assert(source != NULL && this != source);
+ this->ground = source->ground;
+ this->Clone(source->seq);
+ }
+
+ virtual ~NewGRFSpriteLayout()
+ {
+ free(const_cast<DrawTileSeqStruct*>(this->seq));
+ }
+};
+
+/**
* Maps an entity id stored on the map to a GRF file.
* Entities are objects used ingame (houses, industries, industry tiles) for
* which we need to correlate the ids from the grf files with the ones in the