diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-12-04 01:16:22 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-12-04 01:16:22 +0200 |
commit | 4ad8891e0586f60a642675cc4d04edc3cd84650b (patch) | |
tree | bd4e58f90572db689117543e02106e3ce6735b99 /src/craftitemdef.cpp | |
parent | 2b8b2a4f305352f485f726a3bb0ab2f85e711c75 (diff) | |
download | minetest-4ad8891e0586f60a642675cc4d04edc3cd84650b.tar.gz minetest-4ad8891e0586f60a642675cc4d04edc3cd84650b.tar.bz2 minetest-4ad8891e0586f60a642675cc4d04edc3cd84650b.zip |
Convert CraftItems directly to the name pointed by alias; necessary due to lua definition table
Diffstat (limited to 'src/craftitemdef.cpp')
-rw-r--r-- | src/craftitemdef.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/craftitemdef.cpp b/src/craftitemdef.cpp index 8d4cbea3c..4461e38a7 100644 --- a/src/craftitemdef.cpp +++ b/src/craftitemdef.cpp @@ -88,12 +88,7 @@ public: virtual const CraftItemDefinition* getCraftItemDefinition(const std::string &itemname_) const { // Convert name according to possible alias - std::string itemname = itemname_; - std::map<std::string, std::string>::const_iterator i; - i = m_aliases.find(itemname); - if(i != m_aliases.end()){ - itemname = i->second; - } + std::string itemname = getAlias(itemname_); // Get the definition core::map<std::string, CraftItemDefinition*>::Node *n; n = m_item_definitions.find(itemname); @@ -108,6 +103,14 @@ public: return ""; return def->imagename; } + 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; + } virtual bool registerCraftItem(std::string itemname, const CraftItemDefinition &def) { infostream<<"registerCraftItem: registering CraftItem \""<<itemname<<"\""<<std::endl; |