From c2b43f33da1461939df43657752ffd3651933b6e Mon Sep 17 00:00:00 2001 From: faketruth Date: Mon, 31 Oct 2011 21:30:14 +0000 Subject: Player data is saved and loaded as human readable JSON now. cFileFormatUpdate will loop through old files and convert them to new files (should replace legacy old format loading code) cItem has two new functions to load from Json and output Json, this will keep the items in Json standard ChestEntity and FurnaceEntity use the new functions in cItem git-svn-id: http://mc-server.googlecode.com/svn/trunk@35 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cChestEntity.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'source/cChestEntity.cpp') 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; -- cgit v1.2.3