Metadata* NodeMetaRef::getmeta(bool auto_create)
{
if (m_is_local)
- return m_meta;
+ return m_local_meta;
NodeMetadata *meta = m_env->getMap().getNodeMetadata(m_p);
if (meta == NULL && auto_create) {
void NodeMetaRef::reportMetadataChange(const std::string *name)
{
SANITY_CHECK(!m_is_local);
- // NOTE: This same code is in rollback_interface.cpp
// Inform other things that the metadata has changed
- NodeMetadata *meta = dynamic_cast<NodeMetadata*>(m_meta);
+ NodeMetadata *meta = dynamic_cast<NodeMetadata*>(getmeta(false));
+
+ // If the metadata is now empty, get rid of it
+ if (meta && meta->empty())
+ clearMeta();
MapEditEvent event;
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
}
NodeMetaRef::NodeMetaRef(Metadata *meta):
- m_meta(meta),
- m_is_local(true)
+ m_is_local(true),
+ m_local_meta(meta)
{
}