mirror of
https://github.com/minetest/minetest.git
synced 2024-12-03 13:03:45 +01:00
Fix loading of legacy chests
This commit is contained in:
parent
9c3830dd35
commit
81c5e5200b
@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "inventory.h"
|
#include "inventory.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#define NODEMETA_GENERIC 1
|
#define NODEMETA_GENERIC 1
|
||||||
#define NODEMETA_SIGN 14
|
#define NODEMETA_SIGN 14
|
||||||
@ -70,10 +71,9 @@ static bool content_nodemeta_deserialize_legacy_body(
|
|||||||
// Rename inventory list "0" to "main"
|
// Rename inventory list "0" to "main"
|
||||||
Inventory *inv = meta->getInventory();
|
Inventory *inv = meta->getInventory();
|
||||||
if(!inv->getList("main") && inv->getList("0")){
|
if(!inv->getList("main") && inv->getList("0")){
|
||||||
inv->addList("main", 8*4);
|
inv->getList("0")->setName("main");
|
||||||
*inv->getList("main") = *inv->getList("0");
|
|
||||||
inv->deleteList("0");
|
|
||||||
}
|
}
|
||||||
|
assert(inv->getList("main") && !inv->getList("0"));
|
||||||
|
|
||||||
meta->setString("formspec","invsize[8,9;]"
|
meta->setString("formspec","invsize[8,9;]"
|
||||||
"list[current_name;main;0,0;8,4;]"
|
"list[current_name;main;0,0;8,4;]"
|
||||||
@ -88,10 +88,9 @@ static bool content_nodemeta_deserialize_legacy_body(
|
|||||||
// Rename inventory list "0" to "main"
|
// Rename inventory list "0" to "main"
|
||||||
Inventory *inv = meta->getInventory();
|
Inventory *inv = meta->getInventory();
|
||||||
if(!inv->getList("main") && inv->getList("0")){
|
if(!inv->getList("main") && inv->getList("0")){
|
||||||
inv->addList("main", 8*4);
|
inv->getList("0")->setName("main");
|
||||||
*inv->getList("main") = *inv->getList("0");
|
|
||||||
inv->deleteList("0");
|
|
||||||
}
|
}
|
||||||
|
assert(inv->getList("main") && !inv->getList("0"));
|
||||||
|
|
||||||
meta->setString("formspec","invsize[8,9;]"
|
meta->setString("formspec","invsize[8,9;]"
|
||||||
"list[current_name;main;0,0;8,4;]"
|
"list[current_name;main;0,0;8,4;]"
|
||||||
|
@ -458,6 +458,11 @@ void InventoryList::setSize(u32 newsize)
|
|||||||
m_size = newsize;
|
m_size = newsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InventoryList::setName(const std::string &name)
|
||||||
|
{
|
||||||
|
m_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
void InventoryList::serialize(std::ostream &os) const
|
void InventoryList::serialize(std::ostream &os) const
|
||||||
{
|
{
|
||||||
//os.imbue(std::locale("C"));
|
//os.imbue(std::locale("C"));
|
||||||
|
@ -176,6 +176,7 @@ public:
|
|||||||
~InventoryList();
|
~InventoryList();
|
||||||
void clearItems();
|
void clearItems();
|
||||||
void setSize(u32 newsize);
|
void setSize(u32 newsize);
|
||||||
|
void setName(const std::string &name);
|
||||||
void serialize(std::ostream &os) const;
|
void serialize(std::ostream &os) const;
|
||||||
void deSerialize(std::istream &is);
|
void deSerialize(std::istream &is);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user