From 6a8f9135de448d805457e0b1f561c711d760565e Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 25 Nov 2011 15:38:18 +0200 Subject: [PATCH] Store metadata as metadata name in node definition --- src/content_mapnode.cpp | 13 ++++--------- src/map.cpp | 9 ++++----- src/nodedef.cpp | 16 +++------------- src/nodedef.h | 4 ++-- src/scriptapi.cpp | 5 ++--- src/server.cpp | 2 +- 6 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index cddc552d..eda252dc 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 7d5bd700..d27c6da1 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 a3285197..956bc1a5 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; jserialize(os); - } else { - writeU8(os, false); - } + os<inventoryModified(); - MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(blockpos); + MapBlock *block = m_env->getMap().getBlockNoCreateNoEx(blockpos); if(block) block->raiseModified(MOD_STATE_WRITE_NEEDED);