1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Create framework for getting rid of global definitions of node/tool/item/whatever types

This commit is contained in:
Perttu Ahola 2011-11-14 00:19:48 +02:00
parent 5fc791ac9a
commit abceeee92f
60 changed files with 1017 additions and 743 deletions

View file

@ -32,7 +32,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
core::map<u16, NodeMetadata::Factory> 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;