]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/tool.cpp
Unify wield item handling (#8677)
[dragonfireclient.git] / src / tool.cpp
index 09b876ae0fa5d6aaf0bbd84bae9b048ec4293d1a..66bd84a8ee6110a2ce2525bf3f26fd08003e647a 100644 (file)
@@ -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;
+}