summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/content_mapnode.cpp13
-rw-r--r--src/map.cpp9
-rw-r--r--src/nodedef.cpp16
-rw-r--r--src/nodedef.h4
-rw-r--r--src/scriptapi.cpp5
-rw-r--r--src/server.cpp2
6 files changed, 16 insertions, 33 deletions
diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp
index cddc552d4..eda252dc1 100644
--- a/src/content_mapnode.cpp
+++ b/src/content_mapnode.cpp
@@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes.h"
#include "mapnode.h"
-#include "content_nodemeta.h"
#include "nodedef.h"
#include "utility.h"
#include "nameidmapping.h"
@@ -802,8 +801,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
f.wall_mounted = true;
f.air_equivalent = true;
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- if(f.initial_metadata == NULL)
- f.initial_metadata = new SignNodeMetadata(NULL, "Some sign");
+ f.metadata_name = "sign";
setConstantMaterialProperties(f.material, 0.5);
f.selection_box.type = NODEBOX_WALLMOUNTED;
f.furnace_burntime = 10;
@@ -820,8 +818,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
f.setInventoryTexture("chest_top.png");
//f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- if(f.initial_metadata == NULL)
- f.initial_metadata = new ChestNodeMetadata(NULL);
+ f.metadata_name = "chest";
setWoodLikeMaterialProperties(f.material, 1.0);
f.furnace_burntime = 30;
nodemgr->set(i, f);
@@ -837,8 +834,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
f.setInventoryTexture("chest_lock.png");
//f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- if(f.initial_metadata == NULL)
- f.initial_metadata = new LockingChestNodeMetadata(NULL);
+ f.metadata_name = "locked_chest";
setWoodLikeMaterialProperties(f.material, 1.0);
f.furnace_burntime = 30;
nodemgr->set(i, f);
@@ -852,8 +848,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
f.setInventoryTexture("furnace_front.png");
//f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f.dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 6";
- if(f.initial_metadata == NULL)
- f.initial_metadata = new FurnaceNodeMetadata(NULL);
+ f.metadata_name = "furnace";
setStoneLikeMaterialProperties(f.material, 3.0);
nodemgr->set(i, f);
diff --git a/src/map.cpp b/src/map.cpp
index 7d5bd700d..d27c6da12 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -994,11 +994,10 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
/*
Add intial metadata
*/
-
- NodeMetadata *meta_proto = nodemgr->get(n).initial_metadata;
- if(meta_proto)
- {
- NodeMetadata *meta = meta_proto->clone(m_gamedef);
+
+ std::string metadata_name = nodemgr->get(n).metadata_name;
+ if(metadata_name != ""){
+ NodeMetadata *meta = NodeMetadata::create(metadata_name, m_gamedef);
meta->setOwner(player_name);
setNodeMetadata(p, meta);
}
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index a32851974..956bc1a5f 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -89,7 +89,6 @@ ContentFeatures::ContentFeatures()
ContentFeatures::~ContentFeatures()
{
- delete initial_metadata;
#ifndef SERVER
for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
delete special_materials[j];
@@ -143,7 +142,7 @@ void ContentFeatures::reset()
dug_item = "";
extra_dug_item = "";
extra_dug_item_rarity = 2;
- initial_metadata = NULL;
+ metadata_name = "";
liquid_type = LIQUID_NONE;
liquid_alternative_flowing = CONTENT_IGNORE;
liquid_alternative_source = CONTENT_IGNORE;
@@ -191,12 +190,7 @@ void ContentFeatures::serialize(std::ostream &os)
os<<serializeString(dug_item);
os<<serializeString(extra_dug_item);
writeS32(os, extra_dug_item_rarity);
- if(initial_metadata){
- writeU8(os, true);
- initial_metadata->serialize(os);
- } else {
- writeU8(os, false);
- }
+ os<<serializeString(metadata_name);
writeU8(os, liquid_type);
writeU16(os, liquid_alternative_flowing);
writeU16(os, liquid_alternative_source);
@@ -248,11 +242,7 @@ void ContentFeatures::deSerialize(std::istream &is, IGameDef *gamedef)
dug_item = deSerializeString(is);
extra_dug_item = deSerializeString(is);
extra_dug_item_rarity = readS32(is);
- if(readU8(is)){
- initial_metadata = NodeMetadata::deSerialize(is, gamedef);
- } else {
- initial_metadata = NULL;
- }
+ metadata_name = deSerializeString(is);
liquid_type = (enum LiquidType)readU8(is);
liquid_alternative_flowing = readU16(is);
liquid_alternative_source = readU16(is);
diff --git a/src/nodedef.h b/src/nodedef.h
index 0804e0279..87f5fce83 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -188,8 +188,8 @@ struct ContentFeatures
std::string extra_dug_item;
// Usual get interval for extra dug item
s32 extra_dug_item_rarity;
- // Initial metadata is cloned from this
- NodeMetadata *initial_metadata;
+ // Metadata name of node (eg. "furnace")
+ std::string metadata_name;
// Whether the node is non-liquid, source liquid or flowing liquid
enum LiquidType liquid_type;
// If the content is liquid, this is the flowing version of the liquid.
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index aed4227c6..b4c79cd28 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -548,9 +548,8 @@ static int l_register_node(lua_State *L)
getstringfield(L, table0, "extra_dug_item", f.extra_dug_item);
// Usual get interval for extra dug item
getintfield(L, table0, "extra_dug_item_rarity", f.extra_dug_item_rarity);
- // Initial metadata is cloned from this
- // TODO: As metadata name
- // NodeMetadata *initial_metadata;
+ // Metadata name of node (eg. "furnace")
+ getstringfield(L, table0, "metadata_name", f.metadata_name);
// Whether the node is non-liquid, source liquid or flowing liquid
// TODO: Enum read
// enum LiquidType liquid_type;
diff --git a/src/server.cpp b/src/server.cpp
index cd67bc749..100497b61 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -3536,7 +3536,7 @@ void Server::inventoryModified(InventoryContext *c, std::string id)
if(meta)
meta->inventoryModified();
- MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(blockpos);
+ MapBlock *block = m_env->getMap().getBlockNoCreateNoEx(blockpos);
if(block)
block->raiseModified(MOD_STATE_WRITE_NEEDED);