From: Perttu Ahola Date: Sat, 2 Jun 2012 21:32:49 +0000 (+0300) Subject: Fix loading of legacy chests X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=81c5e5200bcc20be6b1513a440b2c45985fe3c49;p=zefram%2Fminetest%2Fminetest_engine.git Fix loading of legacy chests --- diff --git a/src/content_nodemeta.cpp b/src/content_nodemeta.cpp index a2a341ae..2f32cf16 100644 --- a/src/content_nodemeta.cpp +++ b/src/content_nodemeta.cpp @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inventory.h" #include "log.h" #include "utility.h" +#include #define NODEMETA_GENERIC 1 #define NODEMETA_SIGN 14 @@ -70,11 +71,10 @@ static bool content_nodemeta_deserialize_legacy_body( // Rename inventory list "0" to "main" Inventory *inv = meta->getInventory(); if(!inv->getList("main") && inv->getList("0")){ - inv->addList("main", 8*4); - *inv->getList("main") = *inv->getList("0"); - inv->deleteList("0"); + inv->getList("0")->setName("main"); } - + assert(inv->getList("main") && !inv->getList("0")); + meta->setString("formspec","invsize[8,9;]" "list[current_name;main;0,0;8,4;]" "list[current_player;main;0,5;8,4;]"); @@ -88,11 +88,10 @@ static bool content_nodemeta_deserialize_legacy_body( // Rename inventory list "0" to "main" Inventory *inv = meta->getInventory(); if(!inv->getList("main") && inv->getList("0")){ - inv->addList("main", 8*4); - *inv->getList("main") = *inv->getList("0"); - inv->deleteList("0"); + inv->getList("0")->setName("main"); } - + assert(inv->getList("main") && !inv->getList("0")); + meta->setString("formspec","invsize[8,9;]" "list[current_name;main;0,0;8,4;]" "list[current_player;main;0,5;8,4;]"); diff --git a/src/inventory.cpp b/src/inventory.cpp index df75ebcd..7c31c85c 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -458,6 +458,11 @@ void InventoryList::setSize(u32 newsize) m_size = newsize; } +void InventoryList::setName(const std::string &name) +{ + m_name = name; +} + void InventoryList::serialize(std::ostream &os) const { //os.imbue(std::locale("C")); diff --git a/src/inventory.h b/src/inventory.h index 411eabb0..e280bbf7 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -176,6 +176,7 @@ public: ~InventoryList(); void clearItems(); void setSize(u32 newsize); + void setName(const std::string &name); void serialize(std::ostream &os) const; void deSerialize(std::istream &is);