From e14ddff1c00919f1416bfa6da9568e2dff419559 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 19 Jan 2014 07:38:59 -0800 Subject: Spilt Writing of Enchantments to seperate class Created a new class cEnchantmentSerializer to serilize Enchantments to NBT. This breaks a dependecy chain between cChunkGenerator and cWorld. cEnchantmentSerializer is seperate from NBTWriter as it needs to access private members of cEnchantments so having it seperate reduces the spread of the frein modifier --- src/Enchantments.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index 7581b87b5..0f23f8657 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -31,6 +31,7 @@ Serialization will never put zero-level enchantments into the stringspec and wil */ class cEnchantments { +friend class cEnchantmentSerializer; public: /// Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs ) enum @@ -96,11 +97,7 @@ public: /// Returns true if a_Other doesn't contain exactly the same enchantments and levels bool operator !=(const cEnchantments & a_Other) const; - /// Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments") - void WriteToNBTCompound(cFastNBTWriter & a_Writer, const AString & a_ListTagName) const; - - /// Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) - void ParseFromNBT(const cParsedNBT & a_NBT, int a_EnchListTagIdx); + protected: /// Maps enchantment ID -> enchantment level -- cgit v1.2.3 From f13a14d2cf4a7858c22fe003acff6753d0d50ba1 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 19 Jan 2014 08:52:45 -0800 Subject: Switched EnchantmentSerilizer to namespace --- src/Enchantments.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Enchantments.h') diff --git a/src/Enchantments.h b/src/Enchantments.h index 0f23f8657..e984df92e 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -8,6 +8,7 @@ #pragma once +#include "WorldStorage/EnchantmentSerializer.h" @@ -20,7 +21,6 @@ class cParsedNBT; -// tolua_begin /** Class that stores item enchantments or stored-enchantments The enchantments may be serialized to a stringspec and read back from such stringspec. @@ -29,11 +29,12 @@ mapping each enchantment's id onto its level. ID may be either a number or the e Level value of 0 means no such enchantment, and it will not be stored in the m_Enchantments. Serialization will never put zero-level enchantments into the stringspec and will always use numeric IDs. */ +// tolua_begin class cEnchantments { -friend class cEnchantmentSerializer; public: /// Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs ) + enum { enchProtection = 0, @@ -97,7 +98,11 @@ public: /// Returns true if a_Other doesn't contain exactly the same enchantments and levels bool operator !=(const cEnchantments & a_Other) const; - + /// Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments") + friend void EnchantmentSerializer::WriteToNBTCompound(cEnchantments const& a_Enchantments, cFastNBTWriter & a_Writer, const AString & a_ListTagName); + + /// Reads the enchantments from the specified NBT list tag (ench or StoredEnchantments) + friend void EnchantmentSerializer::ParseFromNBT(cEnchantments& a_Enchantments, const cParsedNBT & a_NBT, int a_EnchListTagIdx); protected: /// Maps enchantment ID -> enchantment level -- cgit v1.2.3