From: Perttu Ahola Date: Fri, 25 Nov 2011 13:38:18 +0000 (+0200) Subject: Store metadata as metadata name in node definition X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=6a8f9135de448d805457e0b1f561c711d760565e;p=zefram%2Fminetest%2Fminetest_engine.git Store metadata as metadata name in node definition --- 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);