X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fcontent_nodemeta.cpp;h=fc2859d27ac0d891a8134c4a04f56925d7094a91;hb=0a83c42dfdf390cef75758096a481cdf8e2c828b;hp=a2a341ae0701742afa5c79ac0eb6f0af3ec4d9fb;hpb=d7447cdf9e4df3c345218886ab2bae0e0cc4fc55;p=minetest.git diff --git a/src/content_nodemeta.cpp b/src/content_nodemeta.cpp index a2a341ae0..fc2859d27 100644 --- a/src/content_nodemeta.cpp +++ b/src/content_nodemeta.cpp @@ -1,26 +1,32 @@ /* -Minetest-c55 -Copyright (C) 2010-2012 celeron55, Perttu Ahola +Minetest +Copyright (C) 2010-2013 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +GNU Lesser General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "content_nodemeta.h" +#include "nodemetadata.h" +#include "nodetimer.h" #include "inventory.h" #include "log.h" -#include "utility.h" +#include "serialization.h" +#include "util/serialize.h" +#include "util/string.h" +#include "constants.h" // MAP_BLOCKSIZE +#include #define NODEMETA_GENERIC 1 #define NODEMETA_SIGN 14 @@ -56,7 +62,7 @@ static bool content_nodemeta_deserialize_legacy_body( } else if(id == NODEMETA_SIGN) // SignNodeMetadata { - meta->setString("text", deSerializeLongString(is)); + meta->setString("text", deSerializeString(is)); //meta->setString("infotext","\"${text}\""); meta->setString("infotext", std::string("\"") + meta->getString("text") + "\""); @@ -70,12 +76,11 @@ 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;]" + meta->setString("formspec","size[8,9]" "list[current_name;main;0,0;8,4;]" "list[current_player;main;0,5;8,4;]"); return false; @@ -88,12 +93,11 @@ 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;]" + meta->setString("formspec","size[8,9]" "list[current_name;main;0,0;8,4;]" "list[current_player;main;0,5;8,4;]"); return false; @@ -114,7 +118,7 @@ static bool content_nodemeta_deserialize_legacy_body( is>>temp; meta->setString("src_time", ftos((float)temp/10)); - meta->setString("formspec","invsize[8,9;]" + meta->setString("formspec","size[8,9]" "list[current_name;fuel;2,3;1,1;]" "list[current_name;src;2,1;1,1;]" "list[current_name;dst;5,1;2,2;]" @@ -141,7 +145,7 @@ static bool content_nodemeta_deserialize_legacy_meta( void content_nodemeta_deserialize_legacy(std::istream &is, NodeMetadataList *meta, NodeTimerList *timers, - IGameDef *gamedef) + IItemDefManager *item_def_mgr) { meta->clear(); timers->clear(); @@ -150,9 +154,9 @@ void content_nodemeta_deserialize_legacy(std::istream &is, if(version > 1) { - infostream<<__FUNCTION_NAME<<": version "<get(p) != NULL) { - infostream<<"WARNING: "<<__FUNCTION_NAME<<": " + warningstream<set(p, data); if(need_timer) - timers->set(p, NodeTimer(1., 0.)); + timers->set(NodeTimer(1., 0., p)); } } - -void content_nodemeta_serialize_legacy(std::ostream &os, NodeMetadataList *meta) -{ - // Sorry, I was too lazy to implement this. --kahrl - writeU16(os, 1); // version - writeU16(os, 0); // count -} - -// END