/*
-Minetest-c55
-Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
+Minetest
+Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
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 <sstream>
#define NODEMETA_GENERIC 1
#define NODEMETA_SIGN 14
deSerializeLongString(is); // m_text
deSerializeString(is); // m_owner
- meta->setInfoText(deSerializeString(is));
- meta->setInventoryDrawSpec(deSerializeString(is));
+ meta->setString("infotext",deSerializeString(is));
+ meta->setString("formspec",deSerializeString(is));
readU8(is); // m_allow_text_input
- meta->setAllowRemoval(readU8(is) == 0);
+ readU8(is); // m_allow_removal
readU8(is); // m_enforce_owner
int num_vars = readU32(is);
}
else if(id == NODEMETA_SIGN) // SignNodeMetadata
{
- meta->setString("text", deSerializeLongString(is));
- meta->setInfoText("\"${text}\"");
- meta->setFormSpec("field[text;;${text}]");
+ meta->setString("text", deSerializeString(is));
+ //meta->setString("infotext","\"${text}\"");
+ meta->setString("infotext",
+ std::string("\"") + meta->getString("text") + "\"");
+ meta->setString("formspec","field[text;;${text}]");
return false;
}
else if(id == NODEMETA_CHEST) // ChestNodeMetadata
{
meta->getInventory()->deSerialize(is);
- meta->setInventoryDrawSpec("invsize[8,9;]"
- "list[current_name;0;0,0;8,4;]"
+
+ // Rename inventory list "0" to "main"
+ Inventory *inv = meta->getInventory();
+ if(!inv->getList("main") && inv->getList("0")){
+ inv->getList("0")->setName("main");
+ }
+ assert(inv->getList("main") && !inv->getList("0"));
+
+ meta->setString("formspec","size[8,9]"
+ "list[current_name;main;0,0;8,4;]"
"list[current_player;main;0,5;8,4;]");
return false;
}
{
meta->setString("owner", deSerializeString(is));
meta->getInventory()->deSerialize(is);
- meta->setInventoryDrawSpec("invsize[8,9;]"
- "list[current_name;0;0,0;8,4;]"
+
+ // Rename inventory list "0" to "main"
+ Inventory *inv = meta->getInventory();
+ if(!inv->getList("main") && inv->getList("0")){
+ inv->getList("0")->setName("main");
+ }
+ assert(inv->getList("main") && !inv->getList("0"));
+
+ meta->setString("formspec","size[8,9]"
+ "list[current_name;main;0,0;8,4;]"
"list[current_player;main;0,5;8,4;]");
return false;
}
is>>temp;
meta->setString("src_time", ftos((float)temp/10));
- meta->setInventoryDrawSpec("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;]"
void content_nodemeta_deserialize_legacy(std::istream &is,
NodeMetadataList *meta, NodeTimerList *timers,
- IGameDef *gamedef)
+ IItemDefManager *item_def_mgr)
{
meta->clear();
timers->clear();
if(version > 1)
{
- infostream<<__FUNCTION_NAME<<": version "<<version<<" not supported"
+ infostream<<FUNCTION_NAME<<": version "<<version<<" not supported"
<<std::endl;
- throw SerializationError(__FUNCTION_NAME);
+ throw SerializationError(FUNCTION_NAME);
}
u16 count = readU16(is);
if(meta->get(p) != NULL)
{
- infostream<<"WARNING: "<<__FUNCTION_NAME<<": "
+ warningstream<<FUNCTION_NAME<<": "
<<"already set data at position"
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
<<std::endl;
continue;
}
- NodeMetadata *data = new NodeMetadata(gamedef);
+ NodeMetadata *data = new NodeMetadata(item_def_mgr);
bool need_timer = content_nodemeta_deserialize_legacy_meta(is, data);
meta->set(p, data);
if(need_timer)
- timers->set(p, NodeTimer(1., 0.));
+ timers->set(NodeTimer(1., 0., p));
}
}