Fix loading of legacy MaterialItems (was loaded as a quite random type)
authorPerttu Ahola <celeron55@gmail.com>
Thu, 1 Dec 2011 10:50:32 +0000 (12:50 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Thu, 1 Dec 2011 10:50:32 +0000 (12:50 +0200)
src/inventory.cpp

index e8475b741b0e6740ad7f5a0b59f7e7df6886cb7e..0600729c6ba1b9344ff52a53bf59be29a993d922 100644 (file)
@@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "gamedef.h"
 #include "scriptapi.h"
 #include "strfnd.h"
+#include "nameidmapping.h" // For loading legacy MaterialItems
 
 /*
        InventoryItem
@@ -250,8 +251,10 @@ MaterialItem::MaterialItem(IGameDef *gamedef, std::string nodename, u16 count):
 MaterialItem::MaterialItem(IGameDef *gamedef, content_t content, u16 count):
        InventoryItem(gamedef, count)
 {
-       INodeDefManager *ndef = m_gamedef->ndef();
-       std::string nodename = ndef->get(content).name;
+       NameIdMapping legacy_nimap;
+       content_mapnode_get_name_id_mapping(&legacy_nimap);
+       std::string nodename;
+       legacy_nimap.getName(content, nodename);
        if(nodename == "")
                nodename = "unknown_block";
        m_nodename = nodename;