summaryrefslogtreecommitdiff
path: root/src/tool.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-08-07 19:16:31 +0200
committerGitHub <noreply@github.com>2019-08-07 19:16:31 +0200
commite462a9a5ef46776d974203bb44e0b89e8c980b29 (patch)
tree4562ef5587bd896890d843877031d5818de19bbc /src/tool.cpp
parent003af7421352ec1b8ba0d230b807862e1e4cc7e9 (diff)
downloadminetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.tar.gz
minetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.tar.bz2
minetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.zip
Unify wield item handling (#8677)
This moves the wield item functions to Player and the tool utils for range calculation Also 'local_inventory' was removed due to redundancy in Client
Diffstat (limited to 'src/tool.cpp')
-rw-r--r--src/tool.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tool.cpp b/src/tool.cpp
index 09b876ae0..66bd84a8e 100644
--- a/src/tool.cpp
+++ b/src/tool.cpp
@@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "tool.h"
+#include "itemdef.h"
#include "itemgroup.h"
#include "log.h"
#include "inventory.h"
@@ -277,4 +278,16 @@ PunchDamageResult getPunchDamage(
return result;
}
+f32 getToolRange(const ItemDefinition &def_selected, const ItemDefinition &def_hand)
+{
+ float max_d = def_selected.range;
+ float max_d_hand = def_hand.range;
+
+ if (max_d < 0 && max_d_hand >= 0)
+ max_d = max_d_hand;
+ else if (max_d < 0)
+ max_d = 4.0f;
+
+ return max_d;
+}