aboutsummaryrefslogtreecommitdiff
path: root/src/nodedef.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-12-04 02:12:45 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-12-04 02:12:45 +0200
commit6145a135bd71425c69d31e6c65112238e08349a5 (patch)
treedc1b839ebd4b35cb84a14b95d339843c11e75bf1 /src/nodedef.cpp
parent97c3bc408be0636b5821b7792957d18272e8f7bb (diff)
downloadhax-minetest-server-6145a135bd71425c69d31e6c65112238e08349a5.tar.gz
hax-minetest-server-6145a135bd71425c69d31e6c65112238e08349a5.zip
Make ToolItem and MaterialItem to convert names by aliases at creation time too (necessary for eg. crafting)
Diffstat (limited to 'src/nodedef.cpp')
-rw-r--r--src/nodedef.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index d76f9b8ac..d7769700b 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -403,15 +403,8 @@ public:
}
virtual bool getId(const std::string &name_, content_t &result) const
{
- std::string name = name_;
// Convert name according to possible alias
- std::map<std::string, std::string>::const_iterator i;
- i = m_aliases.find(name);
- if(i != m_aliases.end()){
- /*infostream<<"ndef: alias active: "<<name<<" -> "<<i->second
- <<std::endl;*/
- name = i->second;
- }
+ std::string name = getAlias(name_);
// Get id
return m_name_id_mapping.getId(name, result);
}
@@ -427,6 +420,14 @@ public:
getId(name, id);
return get(id);
}
+ virtual std::string getAlias(const std::string &name) const
+ {
+ std::map<std::string, std::string>::const_iterator i;
+ i = m_aliases.find(name);
+ if(i != m_aliases.end())
+ return i->second;
+ return name;
+ }
// IWritableNodeDefManager
virtual void set(content_t c, const ContentFeatures &def)
{