Skip to content

Commit

Permalink
Fix loading of legacy chests
Browse files Browse the repository at this point in the history
  • Loading branch information
celeron55 committed Jun 3, 2012
1 parent 9c3830d commit 81c5e52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/content_nodemeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sstream>

#define NODEMETA_GENERIC 1
#define NODEMETA_SIGN 14
Expand Down Expand Up @@ -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;]");
Expand All @@ -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;]");
Expand Down
5 changes: 5 additions & 0 deletions src/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
1 change: 1 addition & 0 deletions src/inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class InventoryList
~InventoryList();
void clearItems();
void setSize(u32 newsize);
void setName(const std::string &name);
void serialize(std::ostream &os) const;
void deSerialize(std::istream &is);

Expand Down

0 comments on commit 81c5e52

Please sign in to comment.