return m_env.getMap().getNode(p);
}
-NodeMetadata* Client::getNodeMetadataClone(v3s16 p)
+NodeMetadata* Client::getNodeMetadata(v3s16 p)
{
- //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
- return m_env.getMap().getNodeMetadataClone(p);
+ return m_env.getMap().getNodeMetadata(p);
}
v3f Client::getPlayerPosition()
// Returns InvalidPositionException if not found
MapNode getNode(v3s16 p);
// Wrapper to Map
- NodeMetadata* getNodeMetadataClone(v3s16 p);
+ NodeMetadata* getNodeMetadata(v3s16 p);
v3f getPlayerPosition();
hilightboxes.push_back(nodehilightbox);\r
\r
/*\r
- TODO:\r
Check information text of node\r
*/\r
\r
+ NodeMetadata *meta = client.getNodeMetadata(nodepos);\r
+ if(meta)\r
+ {\r
+ infotext = narrow_to_wide(meta->infoText());\r
+ }\r
+\r
/*\r
Handle digging\r
*/\r
*/
setNode(p, n);
+
+ /*
+ Add intial metadata
+ */
+
+ NodeMetadata *meta_proto = content_features(n.d).initial_metadata;
+ if(meta_proto)
+ {
+ NodeMetadata *meta = meta_proto->clone();
+ setNodeMetadata(p, meta);
+ }
/*
If node is under sunlight and doesn't let sunlight through,
light_sources, modified_blocks);
}
+ /*
+ Remove node metadata
+ */
+
+ removeNodeMetadata(p);
+
/*
Remove the node.
This also clears the lighting.
//dstream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl;
}
-NodeMetadata* Map::getNodeMetadataClone(v3s16 p)
+NodeMetadata* Map::getNodeMetadata(v3s16 p)
{
v3s16 blockpos = getNodeBlockPos(p);
v3s16 p_rel = p - blockpos*MAP_BLOCKSIZE;
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(block == NULL)
+ {
+ dstream<<"WARNING: Map::setNodeMetadata(): Block not found"
+ <<std::endl;
return NULL;
- NodeMetadata *meta = block->m_node_metadata.getClone(p_rel);
+ }
+ NodeMetadata *meta = block->m_node_metadata.get(p_rel);
return meta;
}
+void Map::setNodeMetadata(v3s16 p, NodeMetadata *meta)
+{
+ v3s16 blockpos = getNodeBlockPos(p);
+ v3s16 p_rel = p - blockpos*MAP_BLOCKSIZE;
+ MapBlock *block = getBlockNoCreateNoEx(blockpos);
+ if(block == NULL)
+ {
+ dstream<<"WARNING: Map::setNodeMetadata(): Block not found"
+ <<std::endl;
+ return;
+ }
+ block->m_node_metadata.set(p_rel, meta);
+}
+
+void Map::removeNodeMetadata(v3s16 p)
+{
+ v3s16 blockpos = getNodeBlockPos(p);
+ v3s16 p_rel = p - blockpos*MAP_BLOCKSIZE;
+ MapBlock *block = getBlockNoCreateNoEx(blockpos);
+ if(block == NULL)
+ {
+ dstream<<"WARNING: Map::removeNodeMetadata(): Block not found"
+ <<std::endl;
+ return;
+ }
+ block->m_node_metadata.remove(p_rel);
+}
+
/*
ServerMap
*/
These are basically coordinate wrappers to MapBlock
*/
- NodeMetadata* getNodeMetadataClone(v3s16 p);
+ NodeMetadata* getNodeMetadata(v3s16 p);
+ void setNodeMetadata(v3s16 p, NodeMetadata *meta);
+ void removeNodeMetadata(v3s16 p);
/*
Variables
f->walkable = false;
f->wall_mounted = true;
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
+ if(f->initial_metadata == NULL)
+ f->initial_metadata = new SignNodeMetadata();
}
#include "serialization.h"
#include "tile.h"
#include "iirrlichtwrapper.h"
+#include "nodemetadata.h"
/*
Initializes all kind of stuff in here.
// Inventory item string as which the node appears in inventory when dug.
// Mineral overrides this.
std::string dug_item;
+
+ // Initial metadata is cloned from this
+ NodeMetadata *initial_metadata;
//TODO: Move more properties here
liquid_type = LIQUID_NONE;
wall_mounted = false;
dug_item = "";
+ initial_metadata = NULL;
}
~ContentFeatures();