mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Clean up Game::handleDigging() and some related parts
This commit is contained in:
parent
13a8948edd
commit
bbdb1929c6
3 changed files with 34 additions and 44 deletions
|
@ -48,8 +48,8 @@ struct ItemStack
|
|||
// Returns the string used for inventory
|
||||
std::string getItemString(bool include_meta = true) const;
|
||||
// Returns the tooltip
|
||||
std::string getDescription(IItemDefManager *itemdef) const;
|
||||
std::string getShortDescription(IItemDefManager *itemdef) const;
|
||||
std::string getDescription(const IItemDefManager *itemdef) const;
|
||||
std::string getShortDescription(const IItemDefManager *itemdef) const;
|
||||
|
||||
/*
|
||||
Quantity methods
|
||||
|
@ -82,13 +82,13 @@ struct ItemStack
|
|||
}
|
||||
|
||||
// Maximum size of a stack
|
||||
u16 getStackMax(IItemDefManager *itemdef) const
|
||||
u16 getStackMax(const IItemDefManager *itemdef) const
|
||||
{
|
||||
return itemdef->get(name).stack_max;
|
||||
}
|
||||
|
||||
// Number of items that can be added to this stack
|
||||
u16 freeSpace(IItemDefManager *itemdef) const
|
||||
u16 freeSpace(const IItemDefManager *itemdef) const
|
||||
{
|
||||
u16 max = getStackMax(itemdef);
|
||||
if (count >= max)
|
||||
|
@ -97,7 +97,7 @@ struct ItemStack
|
|||
}
|
||||
|
||||
// Returns false if item is not known and cannot be used
|
||||
bool isKnown(IItemDefManager *itemdef) const
|
||||
bool isKnown(const IItemDefManager *itemdef) const
|
||||
{
|
||||
return itemdef->isKnown(name);
|
||||
}
|
||||
|
@ -105,14 +105,14 @@ struct ItemStack
|
|||
// Returns a pointer to the item definition struct,
|
||||
// or a fallback one (name="unknown") if the item is unknown.
|
||||
const ItemDefinition& getDefinition(
|
||||
IItemDefManager *itemdef) const
|
||||
const IItemDefManager *itemdef) const
|
||||
{
|
||||
return itemdef->get(name);
|
||||
}
|
||||
|
||||
// Get tool digging properties, or those of the hand if not a tool
|
||||
const ToolCapabilities& getToolCapabilities(
|
||||
IItemDefManager *itemdef) const
|
||||
const IItemDefManager *itemdef) const
|
||||
{
|
||||
const ToolCapabilities *item_cap =
|
||||
itemdef->get(name).tool_capabilities;
|
||||
|
@ -127,7 +127,7 @@ struct ItemStack
|
|||
|
||||
// Wear out (only tools)
|
||||
// Returns true if the item is (was) a tool
|
||||
bool addWear(s32 amount, IItemDefManager *itemdef)
|
||||
bool addWear(s32 amount, const IItemDefManager *itemdef)
|
||||
{
|
||||
if(getDefinition(itemdef).type == ITEM_TOOL)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue