summaryrefslogtreecommitdiff
path: root/src/inventory.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/inventory.cpp
parent97c3bc408be0636b5821b7792957d18272e8f7bb (diff)
downloadminetest-6145a135bd71425c69d31e6c65112238e08349a5.tar.gz
minetest-6145a135bd71425c69d31e6c65112238e08349a5.tar.bz2
minetest-6145a135bd71425c69d31e6c65112238e08349a5.zip
Make ToolItem and MaterialItem to convert names by aliases at creation time too (necessary for eg. crafting)
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index e9600ece5..dd2713ca9 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -246,7 +246,9 @@ MaterialItem::MaterialItem(IGameDef *gamedef, std::string nodename, u16 count):
{
if(nodename == "")
nodename = "unknown_block";
- m_nodename = nodename;
+
+ // Convert directly to the correct name through aliases
+ m_nodename = gamedef->ndef()->getAlias(nodename);
}
// Legacy constructor
MaterialItem::MaterialItem(IGameDef *gamedef, content_t content, u16 count):
@@ -309,6 +311,15 @@ content_t MaterialItem::getMaterial() const
ToolItem
*/
+ToolItem::ToolItem(IGameDef *gamedef, std::string toolname, u16 wear):
+ InventoryItem(gamedef, 1)
+{
+ // Convert directly to the correct name through aliases
+ m_toolname = gamedef->tdef()->getAlias(toolname);
+
+ m_wear = wear;
+}
+
std::string ToolItem::getImageBasename() const
{
return m_gamedef->getToolDefManager()->getImagename(m_toolname);
@@ -357,9 +368,7 @@ bool ToolItem::isKnown() const
CraftItem::CraftItem(IGameDef *gamedef, std::string subname, u16 count):
InventoryItem(gamedef, count)
{
- // Convert directly to the correct name through aliases.
- // This is necessary because CraftItem callbacks are stored in
- // Lua refenced by their correct name
+ // Convert directly to the correct name through aliases
m_subname = gamedef->cidef()->getAlias(subname);
}