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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user