mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-24 08:28:49 -05:00
Store metadata as metadata name in node definition
This commit is contained in:
parent
704d8a62bf
commit
6a8f9135de
@ -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);
|
||||
|
||||
|
@ -995,10 +995,9 @@ 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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user