summaryrefslogtreecommitdiffstats
path: root/source/cChestEntity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/cChestEntity.cpp')
-rw-r--r--source/cChestEntity.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/source/cChestEntity.cpp b/source/cChestEntity.cpp
index 54a06fcb9..9ec46014d 100644
--- a/source/cChestEntity.cpp
+++ b/source/cChestEntity.cpp
@@ -111,14 +111,8 @@ bool cChestEntity::LoadFromJson( const Json::Value& a_Value )
int SlotIdx = 0;
for( Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr )
{
- Json::Value & Slot = *itr;
cItem Item;
- Item.m_ItemID = (ENUM_ITEM_ID)Slot.get("ID", -1 ).asInt();
- if( Item.m_ItemID > 0 )
- {
- Item.m_ItemCount = (char)Slot.get("Count", -1 ).asInt();
- Item.m_ItemHealth = (short)Slot.get("Health", -1 ).asInt();
- }
+ Item.FromJson( *itr );
SetSlot( SlotIdx, Item );
SlotIdx++;
}
@@ -137,15 +131,7 @@ void cChestEntity::SaveToJson( Json::Value& a_Value )
{
Json::Value Slot;
cItem* Item = GetSlot( i );
- if( Item )
- {
- Slot["ID"] = Item->m_ItemID;
- if( Item->m_ItemID > 0 )
- {
- Slot["Count"] = Item->m_ItemCount;
- Slot["Health"] = Item->m_ItemHealth;
- }
- }
+ if( Item ) Item->GetJson( Slot );
AllSlots.append( Slot );
}
a_Value["Slots"] = AllSlots;