#include "inventory.h"
#include <sstream>
#include "content_mapnode.h"
+#include "log.h"
/*
NodeMetadata
core::map<u16, NodeMetadata::Factory> NodeMetadata::m_types;
-NodeMetadata::NodeMetadata()
+NodeMetadata::NodeMetadata(IGameDef *gamedef):
+ m_gamedef(gamedef)
{
}
{
}
-NodeMetadata* NodeMetadata::deSerialize(std::istream &is)
+NodeMetadata* NodeMetadata::deSerialize(std::istream &is, IGameDef *gamedef)
{
// Read id
u8 buf[2];
if(n == NULL)
{
// If factory is not found, just return.
- dstream<<"WARNING: NodeMetadata: No factory for typeId="
+ infostream<<"WARNING: NodeMetadata: No factory for typeId="
<<id<<std::endl;
return NULL;
}
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)
{
- dstream<<"WARNING: NodeMetadata: ignoring SerializationError"<<std::endl;
+ infostream<<"WARNING: NodeMetadata: ignoring SerializationError"<<std::endl;
return NULL;
}
}
}
}
-void NodeMetadataList::deSerialize(std::istream &is)
+void NodeMetadataList::deSerialize(std::istream &is, IGameDef *gamedef)
{
m_data.clear();
if(version > 1)
{
- dstream<<__FUNCTION_NAME<<": version "<<version<<" not supported"
+ infostream<<__FUNCTION_NAME<<": version "<<version<<" not supported"
<<std::endl;
throw SerializationError("NodeMetadataList::deSerialize");
}
p16 -= p.Y * MAP_BLOCKSIZE;
p.X += p16;
- NodeMetadata *data = NodeMetadata::deSerialize(is);
+ NodeMetadata *data = NodeMetadata::deSerialize(is, gamedef);
if(data == NULL)
continue;
if(m_data.find(p))
{
- dstream<<"WARNING: NodeMetadataList::deSerialize(): "
+ infostream<<"WARNING: NodeMetadataList::deSerialize(): "
<<"already set data at position"
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
<<std::endl;