X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftool.h;h=00fae48815c865723d9dc33e07a786274f8d95a1;hb=85b01eacd22060e332fada4895ac2cafd04b106a;hp=083328d0604f3c0f7e597df18335cb42dfebab5a;hpb=a98baef5e4fedca36c8c8755ad7c8233469f6a3f;p=dragonfireclient.git diff --git a/src/tool.h b/src/tool.h index 083328d06..00fae4881 100644 --- a/src/tool.h +++ b/src/tool.h @@ -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 #include #include "itemgroup.h" +#include struct ToolGroupCap { std::unordered_map 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 -