forked from Mirrorlandia_minetest/minetest
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 "irrlichttypes.h"
|
||||||
#include "mapnode.h"
|
#include "mapnode.h"
|
||||||
#include "content_nodemeta.h"
|
|
||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "nameidmapping.h"
|
#include "nameidmapping.h"
|
||||||
@ -802,8 +801,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
|
|||||||
f.wall_mounted = true;
|
f.wall_mounted = true;
|
||||||
f.air_equivalent = true;
|
f.air_equivalent = true;
|
||||||
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
if(f.initial_metadata == NULL)
|
f.metadata_name = "sign";
|
||||||
f.initial_metadata = new SignNodeMetadata(NULL, "Some sign");
|
|
||||||
setConstantMaterialProperties(f.material, 0.5);
|
setConstantMaterialProperties(f.material, 0.5);
|
||||||
f.selection_box.type = NODEBOX_WALLMOUNTED;
|
f.selection_box.type = NODEBOX_WALLMOUNTED;
|
||||||
f.furnace_burntime = 10;
|
f.furnace_burntime = 10;
|
||||||
@ -820,8 +818,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
|
|||||||
f.setInventoryTexture("chest_top.png");
|
f.setInventoryTexture("chest_top.png");
|
||||||
//f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
|
//f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
|
||||||
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
if(f.initial_metadata == NULL)
|
f.metadata_name = "chest";
|
||||||
f.initial_metadata = new ChestNodeMetadata(NULL);
|
|
||||||
setWoodLikeMaterialProperties(f.material, 1.0);
|
setWoodLikeMaterialProperties(f.material, 1.0);
|
||||||
f.furnace_burntime = 30;
|
f.furnace_burntime = 30;
|
||||||
nodemgr->set(i, f);
|
nodemgr->set(i, f);
|
||||||
@ -837,8 +834,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
|
|||||||
f.setInventoryTexture("chest_lock.png");
|
f.setInventoryTexture("chest_lock.png");
|
||||||
//f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
|
//f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
|
||||||
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
if(f.initial_metadata == NULL)
|
f.metadata_name = "locked_chest";
|
||||||
f.initial_metadata = new LockingChestNodeMetadata(NULL);
|
|
||||||
setWoodLikeMaterialProperties(f.material, 1.0);
|
setWoodLikeMaterialProperties(f.material, 1.0);
|
||||||
f.furnace_burntime = 30;
|
f.furnace_burntime = 30;
|
||||||
nodemgr->set(i, f);
|
nodemgr->set(i, f);
|
||||||
@ -852,8 +848,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
|
|||||||
f.setInventoryTexture("furnace_front.png");
|
f.setInventoryTexture("furnace_front.png");
|
||||||
//f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
//f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
f.dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 6";
|
f.dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 6";
|
||||||
if(f.initial_metadata == NULL)
|
f.metadata_name = "furnace";
|
||||||
f.initial_metadata = new FurnaceNodeMetadata(NULL);
|
|
||||||
setStoneLikeMaterialProperties(f.material, 3.0);
|
setStoneLikeMaterialProperties(f.material, 3.0);
|
||||||
nodemgr->set(i, f);
|
nodemgr->set(i, f);
|
||||||
|
|
||||||
|
@ -995,10 +995,9 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
|||||||
Add intial metadata
|
Add intial metadata
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NodeMetadata *meta_proto = nodemgr->get(n).initial_metadata;
|
std::string metadata_name = nodemgr->get(n).metadata_name;
|
||||||
if(meta_proto)
|
if(metadata_name != ""){
|
||||||
{
|
NodeMetadata *meta = NodeMetadata::create(metadata_name, m_gamedef);
|
||||||
NodeMetadata *meta = meta_proto->clone(m_gamedef);
|
|
||||||
meta->setOwner(player_name);
|
meta->setOwner(player_name);
|
||||||
setNodeMetadata(p, meta);
|
setNodeMetadata(p, meta);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,6 @@ ContentFeatures::ContentFeatures()
|
|||||||
|
|
||||||
ContentFeatures::~ContentFeatures()
|
ContentFeatures::~ContentFeatures()
|
||||||
{
|
{
|
||||||
delete initial_metadata;
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
|
for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
|
||||||
delete special_materials[j];
|
delete special_materials[j];
|
||||||
@ -143,7 +142,7 @@ void ContentFeatures::reset()
|
|||||||
dug_item = "";
|
dug_item = "";
|
||||||
extra_dug_item = "";
|
extra_dug_item = "";
|
||||||
extra_dug_item_rarity = 2;
|
extra_dug_item_rarity = 2;
|
||||||
initial_metadata = NULL;
|
metadata_name = "";
|
||||||
liquid_type = LIQUID_NONE;
|
liquid_type = LIQUID_NONE;
|
||||||
liquid_alternative_flowing = CONTENT_IGNORE;
|
liquid_alternative_flowing = CONTENT_IGNORE;
|
||||||
liquid_alternative_source = CONTENT_IGNORE;
|
liquid_alternative_source = CONTENT_IGNORE;
|
||||||
@ -191,12 +190,7 @@ void ContentFeatures::serialize(std::ostream &os)
|
|||||||
os<<serializeString(dug_item);
|
os<<serializeString(dug_item);
|
||||||
os<<serializeString(extra_dug_item);
|
os<<serializeString(extra_dug_item);
|
||||||
writeS32(os, extra_dug_item_rarity);
|
writeS32(os, extra_dug_item_rarity);
|
||||||
if(initial_metadata){
|
os<<serializeString(metadata_name);
|
||||||
writeU8(os, true);
|
|
||||||
initial_metadata->serialize(os);
|
|
||||||
} else {
|
|
||||||
writeU8(os, false);
|
|
||||||
}
|
|
||||||
writeU8(os, liquid_type);
|
writeU8(os, liquid_type);
|
||||||
writeU16(os, liquid_alternative_flowing);
|
writeU16(os, liquid_alternative_flowing);
|
||||||
writeU16(os, liquid_alternative_source);
|
writeU16(os, liquid_alternative_source);
|
||||||
@ -248,11 +242,7 @@ void ContentFeatures::deSerialize(std::istream &is, IGameDef *gamedef)
|
|||||||
dug_item = deSerializeString(is);
|
dug_item = deSerializeString(is);
|
||||||
extra_dug_item = deSerializeString(is);
|
extra_dug_item = deSerializeString(is);
|
||||||
extra_dug_item_rarity = readS32(is);
|
extra_dug_item_rarity = readS32(is);
|
||||||
if(readU8(is)){
|
metadata_name = deSerializeString(is);
|
||||||
initial_metadata = NodeMetadata::deSerialize(is, gamedef);
|
|
||||||
} else {
|
|
||||||
initial_metadata = NULL;
|
|
||||||
}
|
|
||||||
liquid_type = (enum LiquidType)readU8(is);
|
liquid_type = (enum LiquidType)readU8(is);
|
||||||
liquid_alternative_flowing = readU16(is);
|
liquid_alternative_flowing = readU16(is);
|
||||||
liquid_alternative_source = readU16(is);
|
liquid_alternative_source = readU16(is);
|
||||||
|
@ -188,8 +188,8 @@ struct ContentFeatures
|
|||||||
std::string extra_dug_item;
|
std::string extra_dug_item;
|
||||||
// Usual get interval for extra dug item
|
// Usual get interval for extra dug item
|
||||||
s32 extra_dug_item_rarity;
|
s32 extra_dug_item_rarity;
|
||||||
// Initial metadata is cloned from this
|
// Metadata name of node (eg. "furnace")
|
||||||
NodeMetadata *initial_metadata;
|
std::string metadata_name;
|
||||||
// Whether the node is non-liquid, source liquid or flowing liquid
|
// Whether the node is non-liquid, source liquid or flowing liquid
|
||||||
enum LiquidType liquid_type;
|
enum LiquidType liquid_type;
|
||||||
// If the content is liquid, this is the flowing version of the liquid.
|
// 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);
|
getstringfield(L, table0, "extra_dug_item", f.extra_dug_item);
|
||||||
// Usual get interval for extra dug item
|
// Usual get interval for extra dug item
|
||||||
getintfield(L, table0, "extra_dug_item_rarity", f.extra_dug_item_rarity);
|
getintfield(L, table0, "extra_dug_item_rarity", f.extra_dug_item_rarity);
|
||||||
// Initial metadata is cloned from this
|
// Metadata name of node (eg. "furnace")
|
||||||
// TODO: As metadata name
|
getstringfield(L, table0, "metadata_name", f.metadata_name);
|
||||||
// NodeMetadata *initial_metadata;
|
|
||||||
// Whether the node is non-liquid, source liquid or flowing liquid
|
// Whether the node is non-liquid, source liquid or flowing liquid
|
||||||
// TODO: Enum read
|
// TODO: Enum read
|
||||||
// enum LiquidType liquid_type;
|
// enum LiquidType liquid_type;
|
||||||
|
@ -3536,7 +3536,7 @@ void Server::inventoryModified(InventoryContext *c, std::string id)
|
|||||||
if(meta)
|
if(meta)
|
||||||
meta->inventoryModified();
|
meta->inventoryModified();
|
||||||
|
|
||||||
MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(blockpos);
|
MapBlock *block = m_env->getMap().getBlockNoCreateNoEx(blockpos);
|
||||||
if(block)
|
if(block)
|
||||||
block->raiseModified(MOD_STATE_WRITE_NEEDED);
|
block->raiseModified(MOD_STATE_WRITE_NEEDED);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user