1
0
cuberite-2a/source/cItem.cpp
faketruth c2b43f33da 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
2011-10-31 21:30:14 +00:00

22 lines
505 B
C++

#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();
}
}