summaryrefslogtreecommitdiff
path: root/src/nodemetadata.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-11-25 16:34:12 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-29 19:13:51 +0200
commit18bb0ea1ead82406bcfb89ea14908a4d0063209e (patch)
tree2141a857259f68c0421ca4349d82711fef6c39e2 /src/nodemetadata.cpp
parent6a8f9135de448d805457e0b1f561c711d760565e (diff)
downloadminetest-18bb0ea1ead82406bcfb89ea14908a4d0063209e.tar.gz
minetest-18bb0ea1ead82406bcfb89ea14908a4d0063209e.tar.bz2
minetest-18bb0ea1ead82406bcfb89ea14908a4d0063209e.zip
Mode node definition loading from Lua (still not finished), fix metadata creation from name
Diffstat (limited to 'src/nodemetadata.cpp')
-rw-r--r--src/nodemetadata.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/nodemetadata.cpp b/src/nodemetadata.cpp
index 2f47aba22..7abf82426 100644
--- a/src/nodemetadata.cpp
+++ b/src/nodemetadata.cpp
@@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
core::map<u16, NodeMetadata::Factory> NodeMetadata::m_types;
-core::map<std::string, NodeMetadata::Factory> NodeMetadata::m_names;
+core::map<std::string, NodeMetadata::Factory2> NodeMetadata::m_names;
NodeMetadata::NodeMetadata(IGameDef *gamedef):
m_gamedef(gamedef)
@@ -45,7 +45,7 @@ NodeMetadata::~NodeMetadata()
NodeMetadata* NodeMetadata::create(const std::string &name, IGameDef *gamedef)
{
// Find factory function
- core::map<std::string, Factory>::Node *n;
+ core::map<std::string, Factory2>::Node *n;
n = m_names.find(name);
if(n == NULL)
{
@@ -58,10 +58,8 @@ NodeMetadata* NodeMetadata::create(const std::string &name, IGameDef *gamedef)
// Try to load the metadata. If it fails, just return.
try
{
- std::istringstream iss("", std::ios_base::binary);
-
- Factory f = n->getValue();
- NodeMetadata *meta = (*f)(iss, gamedef);
+ Factory2 f2 = n->getValue();
+ NodeMetadata *meta = (*f2)(gamedef);
return meta;
}
catch(SerializationError &e)
@@ -120,7 +118,8 @@ void NodeMetadata::serialize(std::ostream &os)
os<<serializeString(oss.str());
}
-void NodeMetadata::registerType(u16 id, const std::string &name, Factory f)
+void NodeMetadata::registerType(u16 id, const std::string &name, Factory f,
+ Factory2 f2)
{
{ // typeId
core::map<u16, Factory>::Node *n;
@@ -129,10 +128,10 @@ void NodeMetadata::registerType(u16 id, const std::string &name, Factory f)
m_types.insert(id, f);
}
{ // typeName
- core::map<std::string, Factory>::Node *n;
+ core::map<std::string, Factory2>::Node *n;
n = m_names.find(name);
if(!n)
- m_names.insert(name, f);
+ m_names.insert(name, f2);
}
}