summaryrefslogtreecommitdiffstats
path: root/src/Enchantments.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-01-19 16:38:59 +0100
committerTycho <work.tycho+git@gmail.com>2014-01-19 16:38:59 +0100
commite14ddff1c00919f1416bfa6da9568e2dff419559 (patch)
treee05c7c0e5219c165f0f9335726e00ebadab4440c /src/Enchantments.cpp
parentMerge pull request #552 from worktycho/c++11 (diff)
downloadcuberite-e14ddff1c00919f1416bfa6da9568e2dff419559.tar
cuberite-e14ddff1c00919f1416bfa6da9568e2dff419559.tar.gz
cuberite-e14ddff1c00919f1416bfa6da9568e2dff419559.tar.bz2
cuberite-e14ddff1c00919f1416bfa6da9568e2dff419559.tar.lz
cuberite-e14ddff1c00919f1416bfa6da9568e2dff419559.tar.xz
cuberite-e14ddff1c00919f1416bfa6da9568e2dff419559.tar.zst
cuberite-e14ddff1c00919f1416bfa6da9568e2dff419559.zip
Diffstat (limited to 'src/Enchantments.cpp')
-rw-r--r--src/Enchantments.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp
index 95ca201f0..1d8188e96 100644
--- a/src/Enchantments.cpp
+++ b/src/Enchantments.cpp
@@ -213,87 +213,8 @@ bool cEnchantments::operator !=(const cEnchantments & a_Other) const
-void cEnchantments::WriteToNBTCompound(cFastNBTWriter & a_Writer, const AString & a_ListTagName) const
-{
- // Write the enchantments into the specified NBT writer
- // begin with the LIST tag of the specified name ("ench" or "StoredEnchantments")
-
- a_Writer.BeginList(a_ListTagName, TAG_Compound);
- for (cMap::const_iterator itr = m_Enchantments.begin(), end = m_Enchantments.end(); itr != end; ++itr)
- {
- a_Writer.BeginCompound("");
- a_Writer.AddShort("id", itr->first);
- a_Writer.AddShort("lvl", itr->second);
- a_Writer.EndCompound();
- } // for itr - m_Enchantments[]
- a_Writer.EndList();
-}
-
-void cEnchantments::ParseFromNBT(const cParsedNBT & a_NBT, int a_EnchListTagIdx)
-{
- // Read the enchantments from the specified NBT list tag (ench or StoredEnchantments)
-
- // Verify that the tag is a list:
- if (a_NBT.GetType(a_EnchListTagIdx) != TAG_List)
- {
- LOGWARNING("%s: Invalid EnchListTag type: exp %d, got %d. Enchantments not parsed",
- __FUNCTION__, TAG_List, a_NBT.GetType(a_EnchListTagIdx)
- );
- ASSERT(!"Bad EnchListTag type");
- return;
- }
-
- // Verify that the list is of Compounds:
- if (a_NBT.GetChildrenType(a_EnchListTagIdx) != TAG_Compound)
- {
- LOGWARNING("%s: Invalid NBT list children type: exp %d, got %d. Enchantments not parsed",
- __FUNCTION__, TAG_Compound, a_NBT.GetChildrenType(a_EnchListTagIdx)
- );
- ASSERT(!"Bad EnchListTag children type");
- return;
- }
-
- Clear();
-
- // Iterate over all the compound children, parse an enchantment from each:
- for (int tag = a_NBT.GetFirstChild(a_EnchListTagIdx); tag >= 0; tag = a_NBT.GetNextSibling(tag))
- {
- // tag is the compound inside the "ench" list tag
- ASSERT(a_NBT.GetType(tag) == TAG_Compound);
-
- // Search for the id and lvl tags' values:
- int id = -1, lvl = -1;
- for (int ch = a_NBT.GetFirstChild(tag); ch >= 0; ch = a_NBT.GetNextSibling(ch))
- {
- if (a_NBT.GetType(ch) != TAG_Short)
- {
- continue;
- }
- if (a_NBT.GetName(ch) == "id")
- {
- id = a_NBT.GetShort(ch);
- }
- else if (a_NBT.GetName(ch) == "lvl")
- {
- lvl = a_NBT.GetShort(ch);
- }
- } // for ch - children of the compound tag
-
- if ((id == -1) || (lvl <= 0))
- {
- // Failed to parse either the id or the lvl, skip this compound
- continue;
- }
-
- // Store the enchantment:
- m_Enchantments[id] = lvl;
- } // for tag - children of the ench list tag
-}
-
-
-