From ff8d2bbc3682b12d40d1dfb212d39a50c498fb93 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 1 Jun 2012 19:51:45 +0300 Subject: Convert legacy chest inventory list "0" to "main" --- src/content_nodemeta.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/content_nodemeta.cpp b/src/content_nodemeta.cpp index 18690612d..ba4a0e513 100644 --- a/src/content_nodemeta.cpp +++ b/src/content_nodemeta.cpp @@ -64,8 +64,17 @@ static bool content_nodemeta_deserialize_legacy_body( else if(id == NODEMETA_CHEST) // ChestNodeMetadata { meta->getInventory()->deSerialize(is); + + // 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"); + } + meta->setString("formspec","invsize[8,9;]" - "list[current_name;0;0,0;8,4;]" + "list[current_name;main;0,0;8,4;]" "list[current_player;main;0,5;8,4;]"); return false; } @@ -73,8 +82,17 @@ static bool content_nodemeta_deserialize_legacy_body( { meta->setString("owner", deSerializeString(is)); meta->getInventory()->deSerialize(is); + + // 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"); + } + meta->setString("formspec","invsize[8,9;]" - "list[current_name;0;0,0;8,4;]" + "list[current_name;main;0,0;8,4;]" "list[current_player;main;0,5;8,4;]"); return false; } -- cgit v1.2.3