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:
22
source/cItem.cpp
Normal file
22
source/cItem.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "cItem.h"
|
||||
#include <json/json.h>
|
||||
|
||||
void cItem::GetJson( Json::Value & a_OutValue )
|
||||
{
|
||||
a_OutValue["ID"] = m_ItemID;
|
||||
if( m_ItemID > 0 )
|
||||
{
|
||||
a_OutValue["Count"] = m_ItemCount;
|
||||
a_OutValue["Health"] = m_ItemHealth;
|
||||
}
|
||||
}
|
||||
|
||||
void cItem::FromJson( const Json::Value & a_Value )
|
||||
{
|
||||
m_ItemID = (ENUM_ITEM_ID)a_Value.get("ID", -1 ).asInt();
|
||||
if( m_ItemID > 0 )
|
||||
{
|
||||
m_ItemCount = (char)a_Value.get("Count", -1 ).asInt();
|
||||
m_ItemHealth = (short)a_Value.get("Health", -1 ).asInt();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user