summaryrefslogtreecommitdiff
path: root/src/inventory.h
diff options
context:
space:
mode:
authorraymoo <uguu@installgentoo.com>2017-04-18 16:30:27 -0700
committerparamat <mat.gregory@virginmedia.com>2017-10-29 11:57:38 +0000
commita637107a4e81be88938d68df4deae50e68cf2cd8 (patch)
tree2d35b9bf380af88bb7618a6b4efbca6f55c338d3 /src/inventory.h
parent610ea6f21629933be3b38c2b5fce53a35c5aac3a (diff)
downloadminetest-a637107a4e81be88938d68df4deae50e68cf2cd8.tar.gz
minetest-a637107a4e81be88938d68df4deae50e68cf2cd8.tar.bz2
minetest-a637107a4e81be88938d68df4deae50e68cf2cd8.zip
Allow overriding tool capabilities through itemstack metadata
This makes it possible to modify the tool capabilities of individual itemstacks by calling a method on itemstack metadata references.
Diffstat (limited to 'src/inventory.h')
-rw-r--r--src/inventory.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/inventory.h b/src/inventory.h
index d04dc1e69..465aa66db 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -111,12 +111,15 @@ struct ItemStack
const ToolCapabilities& getToolCapabilities(
IItemDefManager *itemdef) const
{
- ToolCapabilities *cap;
- cap = itemdef->get(name).tool_capabilities;
- if(cap == NULL)
- cap = itemdef->get("").tool_capabilities;
- assert(cap != NULL);
- return *cap;
+ const ToolCapabilities *item_cap =
+ itemdef->get(name).tool_capabilities;
+
+ if (item_cap == NULL)
+ // Fall back to the hand's tool capabilities
+ item_cap = itemdef->get("").tool_capabilities;
+
+ assert(item_cap != NULL);
+ return metadata.getToolCapabilities(*item_cap); // Check for override
}
// Wear out (only tools)