]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/tool.h
Night sky: Fix brightness threshold for applying night colours (#7859)
[dragonfireclient.git] / src / tool.h
index 083328d0604f3c0f7e597df18335cb42dfebab5a..00fae48815c865723d9dc33e07a786274f8d95a1 100644 (file)
@@ -17,24 +17,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef TOOL_HEADER
-#define TOOL_HEADER
+#pragma once
 
 #include "irrlichttypes.h"
 #include <string>
 #include <iostream>
 #include "itemgroup.h"
+#include <json/json.h>
 
 struct ToolGroupCap
 {
        std::unordered_map<int, float> times;
-       int maxlevel;
-       int uses;
+       int maxlevel = 1;
+       int uses = 20;
 
-       ToolGroupCap():
-               maxlevel(1),
-               uses(20)
-       {}
+       ToolGroupCap() = default;
 
        bool getTime(int rating, float *time) const
        {
@@ -46,6 +43,9 @@ struct ToolGroupCap
                *time = i->second;
                return true;
        }
+
+       void toJson(Json::Value &object) const;
+       void fromJson(const Json::Value &json);
 };
 
 
@@ -73,6 +73,8 @@ struct ToolCapabilities
 
        void serialize(std::ostream &os, u16 version) const;
        void deSerialize(std::istream &is);
+       void serializeJson(std::ostream &os) const;
+       void deserializeJson(std::istream &is);
 };
 
 struct DigParams
@@ -93,9 +95,6 @@ struct DigParams
        {}
 };
 
-DigParams getDigParams(const ItemGroupList &groups,
-               const ToolCapabilities *tp, float time_from_last_punch);
-
 DigParams getDigParams(const ItemGroupList &groups,
                const ToolCapabilities *tp);
 
@@ -118,15 +117,11 @@ HitParams getHitParams(const ItemGroupList &armor_groups,
 
 struct PunchDamageResult
 {
-       bool did_punch;
-       int damage;
-       int wear;
-
-       PunchDamageResult():
-               did_punch(false),
-               damage(0),
-               wear(0)
-       {}
+       bool did_punch = false;
+       int damage = 0;
+       int wear = 0;
+
+       PunchDamageResult() = default;
 };
 
 struct ItemStack;
@@ -137,6 +132,3 @@ PunchDamageResult getPunchDamage(
                const ItemStack *punchitem,
                float time_from_last_punch
 );
-
-#endif
-