From 4b00d4d9d2158fc65da39179448c03390f094987 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 3 Dec 2011 23:50:31 +0200 Subject: Node definition aliases --- src/nodedef.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'src/nodedef.cpp') diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 9f2d4f0af..e2e5616f1 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -398,8 +398,18 @@ public: { return get(n.getContent()); } - virtual bool getId(const std::string &name, content_t &result) const + virtual bool getId(const std::string &name_, content_t &result) const { + std::string name = name_; + // Convert name according to possible alias + std::map::const_iterator i; + i = m_aliases.find(name); + if(i != m_aliases.end()){ + /*infostream<<"ndef: alias active: "< "<second + <second; + } + // Get id return m_name_id_mapping.getId(name, result); } virtual content_t getId(const std::string &name) const @@ -438,6 +448,12 @@ public: m_content_features[c] = def; if(def.name != "") m_name_id_mapping.set(c, def.name); + + // Remove conflicting alias if it exists + bool alias_removed = (m_aliases.erase(def.name) != 0); + if(alias_removed) + infostream<<"ndef: erased alias "< "< "< m_aliases; }; IWritableNodeDefManager* createNodeDefManager() -- cgit v1.2.3