From abceeee92f99b84ebb79968269835a4f509bfb90 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 14 Nov 2011 00:19:48 +0200 Subject: Create framework for getting rid of global definitions of node/tool/item/whatever types --- src/nodemetadata.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/nodemetadata.cpp') diff --git a/src/nodemetadata.cpp b/src/nodemetadata.cpp index 6fbfc2dba..ef6ea1cd2 100644 --- a/src/nodemetadata.cpp +++ b/src/nodemetadata.cpp @@ -32,7 +32,8 @@ with this program; if not, write to the Free Software Foundation, Inc., core::map NodeMetadata::m_types; -NodeMetadata::NodeMetadata() +NodeMetadata::NodeMetadata(IGameDef *gamedef): + m_gamedef(gamedef) { } @@ -40,7 +41,7 @@ NodeMetadata::~NodeMetadata() { } -NodeMetadata* NodeMetadata::deSerialize(std::istream &is) +NodeMetadata* NodeMetadata::deSerialize(std::istream &is, IGameDef *gamedef) { // Read id u8 buf[2]; @@ -67,7 +68,7 @@ NodeMetadata* NodeMetadata::deSerialize(std::istream &is) std::istringstream iss(data, std::ios_base::binary); Factory f = n->getValue(); - NodeMetadata *meta = (*f)(iss); + NodeMetadata *meta = (*f)(iss, gamedef); return meta; } catch(SerializationError &e) @@ -128,7 +129,7 @@ void NodeMetadataList::serialize(std::ostream &os) } } -void NodeMetadataList::deSerialize(std::istream &is) +void NodeMetadataList::deSerialize(std::istream &is, IGameDef *gamedef) { m_data.clear(); @@ -159,7 +160,7 @@ void NodeMetadataList::deSerialize(std::istream &is) p16 -= p.Y * MAP_BLOCKSIZE; p.X += p16; - NodeMetadata *data = NodeMetadata::deSerialize(is); + NodeMetadata *data = NodeMetadata::deSerialize(is, gamedef); if(data == NULL) continue; -- cgit v1.2.3