summaryrefslogtreecommitdiffstats
path: root/source/Item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Item.cpp')
-rw-r--r--source/Item.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/source/Item.cpp b/source/Item.cpp
index e2cacdac1..569d04980 100644
--- a/source/Item.cpp
+++ b/source/Item.cpp
@@ -90,23 +90,34 @@ bool cItem::IsStackableWith(const cItem & a_OtherStack) const
-void cItem::GetJson( Json::Value & a_OutValue ) const
+void cItem::GetJson(Json::Value & a_OutValue) const
{
a_OutValue["ID"] = m_ItemType;
- if( m_ItemType > 0 )
+ if (m_ItemType > 0)
{
a_OutValue["Count"] = m_ItemCount;
a_OutValue["Health"] = m_ItemDamage;
+ AString Enchantments(m_Enchantments.ToString());
+ if (!Enchantments.empty())
+ {
+ a_OutValue["ench"] = Enchantments;
+ }
}
}
-void cItem::FromJson( const Json::Value & a_Value )
+
+
+
+
+void cItem::FromJson(const Json::Value & a_Value)
{
m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1 ).asInt();
- if( m_ItemType > 0 )
+ if (m_ItemType > 0)
{
m_ItemCount = (char)a_Value.get("Count", -1 ).asInt();
m_ItemDamage = (short)a_Value.get("Health", -1 ).asInt();
+ m_Enchantments.Clear();
+ m_Enchantments.AddFromString(a_Value.get("ench", "").asString());
}
}