diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-11-14 00:19:48 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-11-29 19:13:41 +0200 |
commit | abceeee92f99b84ebb79968269835a4f509bfb90 (patch) | |
tree | 669edeca68fae4eb086ac4e4c1846b55d3aa779d /src/nodemetadata.h | |
parent | 5fc791ac9a15ea6f234ca2d23041c83679255746 (diff) | |
download | minetest-abceeee92f99b84ebb79968269835a4f509bfb90.tar.gz minetest-abceeee92f99b84ebb79968269835a4f509bfb90.tar.bz2 minetest-abceeee92f99b84ebb79968269835a4f509bfb90.zip |
Create framework for getting rid of global definitions of node/tool/item/whatever types
Diffstat (limited to 'src/nodemetadata.h')
-rw-r--r-- | src/nodemetadata.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/nodemetadata.h b/src/nodemetadata.h index 5b2f129a1..9eb08678a 100644 --- a/src/nodemetadata.h +++ b/src/nodemetadata.h @@ -34,21 +34,22 @@ with this program; if not, write to the Free Software Foundation, Inc., */ class Inventory; +class IGameDef; class NodeMetadata { public: - typedef NodeMetadata* (*Factory)(std::istream&); + typedef NodeMetadata* (*Factory)(std::istream&, IGameDef *gamedef); - NodeMetadata(); + NodeMetadata(IGameDef *gamedef); virtual ~NodeMetadata(); - static NodeMetadata* deSerialize(std::istream &is); + static NodeMetadata* deSerialize(std::istream &is, IGameDef *gamedef); void serialize(std::ostream &os); // This usually is the CONTENT_ value virtual u16 typeId() const = 0; - virtual NodeMetadata* clone() = 0; + virtual NodeMetadata* clone(IGameDef *gamedef) = 0; virtual void serializeBody(std::ostream &os) = 0; virtual std::string infoText() {return "";} virtual Inventory* getInventory() {return NULL;} @@ -69,6 +70,7 @@ public: virtual void setText(const std::string &t){} protected: static void registerType(u16 id, Factory f); + IGameDef *m_gamedef; private: static core::map<u16, Factory> m_types; }; @@ -83,7 +85,7 @@ public: ~NodeMetadataList(); void serialize(std::ostream &os); - void deSerialize(std::istream &is); + void deSerialize(std::istream &is, IGameDef *gamedef); // Get pointer to data NodeMetadata* get(v3s16 p); |