Merge pull request #1490 from mc-server/removecompact
Removed WSSCompact
This commit is contained in:
commit
3ccda572b3
@ -303,68 +303,6 @@ void cBeaconEntity::UsedBy(cPlayer * a_Player)
|
||||
|
||||
|
||||
|
||||
bool cBeaconEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
Json::Value AllSlots = a_Value.get("Slots", 0);
|
||||
int SlotIdx = 0;
|
||||
for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
|
||||
{
|
||||
cItem Item;
|
||||
Item.FromJson(*itr);
|
||||
SetSlot(SlotIdx, Item);
|
||||
SlotIdx++;
|
||||
}
|
||||
|
||||
m_BeaconLevel = (char)a_Value.get("Level", 0).asInt();
|
||||
int PrimaryEffect = a_Value.get("PrimaryEffect", 0).asInt();
|
||||
int SecondaryEffect = a_Value.get("SecondaryEffect", 0).asInt();
|
||||
|
||||
if ((PrimaryEffect >= 0) && (PrimaryEffect <= (int)cEntityEffect::effSaturation))
|
||||
{
|
||||
m_PrimaryEffect = (cEntityEffect::eType)PrimaryEffect;
|
||||
}
|
||||
|
||||
if ((SecondaryEffect >= 0) && (SecondaryEffect <= (int)cEntityEffect::effSaturation))
|
||||
{
|
||||
m_SecondaryEffect = (cEntityEffect::eType)SecondaryEffect;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBeaconEntity::SaveToJson(Json::Value& a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
Json::Value AllSlots;
|
||||
int NumSlots = m_Contents.GetNumSlots();
|
||||
for (int i = 0; i < NumSlots; i++)
|
||||
{
|
||||
Json::Value Slot;
|
||||
m_Contents.GetSlot(i).GetJson(Slot);
|
||||
AllSlots.append(Slot);
|
||||
}
|
||||
a_Value["Slots"] = AllSlots;
|
||||
|
||||
a_Value["Level"] = m_BeaconLevel;
|
||||
a_Value["PrimaryEffect"] = (int)m_PrimaryEffect;
|
||||
a_Value["SecondaryEffect"] = (int)m_SecondaryEffect;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBeaconEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
a_Client.SendUpdateBlockEntity(*this);
|
||||
|
@ -34,9 +34,7 @@ public:
|
||||
|
||||
cBeaconEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
|
||||
bool LoadFromJson(const Json::Value & a_Value);
|
||||
// cBlockEntity overrides:
|
||||
virtual void SaveToJson(Json::Value& a_Value) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
|
@ -74,8 +74,6 @@ public:
|
||||
int GetRelZ(void) const { return m_RelZ; }
|
||||
|
||||
// tolua_end
|
||||
|
||||
virtual void SaveToJson (Json::Value & a_Value) = 0;
|
||||
|
||||
/// Called when a player uses this entity; should open the UI window
|
||||
virtual void UsedBy( cPlayer * a_Player) = 0;
|
||||
|
@ -33,48 +33,6 @@ cChestEntity::~cChestEntity()
|
||||
|
||||
|
||||
|
||||
bool cChestEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
Json::Value AllSlots = a_Value.get("Slots", 0);
|
||||
int SlotIdx = 0;
|
||||
for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
|
||||
{
|
||||
cItem Item;
|
||||
Item.FromJson(*itr);
|
||||
SetSlot(SlotIdx, Item);
|
||||
SlotIdx++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChestEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
Json::Value AllSlots;
|
||||
for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--)
|
||||
{
|
||||
Json::Value Slot;
|
||||
m_Contents.GetSlot(i).GetJson(Slot);
|
||||
AllSlots.append(Slot);
|
||||
}
|
||||
a_Value["Slots"] = AllSlots;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChestEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
// The chest entity doesn't need anything sent to the client when it's created / gets in the viewdistance
|
||||
|
@ -39,11 +39,8 @@ public:
|
||||
virtual ~cChestEntity();
|
||||
|
||||
static const char * GetClassStatic(void) { return "cChestEntity"; }
|
||||
|
||||
bool LoadFromJson(const Json::Value & a_Value);
|
||||
|
||||
// cBlockEntity overrides:
|
||||
virtual void SaveToJson(Json::Value & a_Value) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
|
||||
|
@ -152,38 +152,6 @@ void cCommandBlockEntity::SendTo(cClientHandle & a_Client)
|
||||
|
||||
|
||||
|
||||
bool cCommandBlockEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
m_Command = a_Value.get("Command", "").asString();
|
||||
m_LastOutput = a_Value.get("LastOutput", "").asString();
|
||||
m_Result = (NIBBLETYPE)a_Value.get("SuccessCount", 0).asInt();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cCommandBlockEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
a_Value["Command"] = m_Command;
|
||||
a_Value["LastOutput"] = m_LastOutput;
|
||||
a_Value["SuccessCount"] = m_Result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cCommandBlockEntity::Execute()
|
||||
{
|
||||
ASSERT(m_World != NULL); // Execute should not be called before the command block is attached to a world
|
||||
|
@ -39,9 +39,6 @@ public:
|
||||
/// Creates a new empty command block entity
|
||||
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
||||
|
||||
bool LoadFromJson( const Json::Value& a_Value);
|
||||
virtual void SaveToJson(Json::Value& a_Value) override;
|
||||
|
||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
|
@ -142,54 +142,6 @@ bool cDropSpenserEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
|
||||
|
||||
bool cDropSpenserEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
Json::Value AllSlots = a_Value.get("Slots", 0);
|
||||
int SlotIdx = 0;
|
||||
for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
|
||||
{
|
||||
cItem Contents;
|
||||
Contents.FromJson(*itr);
|
||||
m_Contents.SetSlot(SlotIdx, Contents);
|
||||
SlotIdx++;
|
||||
if (SlotIdx >= m_Contents.GetNumSlots())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cDropSpenserEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
Json::Value AllSlots;
|
||||
int NumSlots = m_Contents.GetNumSlots();
|
||||
for (int i = 0; i < NumSlots; i++)
|
||||
{
|
||||
Json::Value Slot;
|
||||
m_Contents.GetSlot(i).GetJson(Slot);
|
||||
AllSlots.append(Slot);
|
||||
}
|
||||
a_Value["Slots"] = AllSlots;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cDropSpenserEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
// Nothing needs to be sent
|
||||
|
@ -49,11 +49,8 @@ public:
|
||||
virtual ~cDropSpenserEntity();
|
||||
|
||||
static const char * GetClassStatic(void) { return "cDropSpenserEntity"; }
|
||||
|
||||
bool LoadFromJson(const Json::Value & a_Value);
|
||||
|
||||
// cBlockEntity overrides:
|
||||
virtual void SaveToJson(Json::Value & a_Value) override;
|
||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
|
@ -25,7 +25,6 @@ public:
|
||||
|
||||
// cBlockEntity overrides:
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
virtual void SaveToJson(Json::Value & a_Value) override { UNUSED(a_Value); }
|
||||
virtual void SendTo(cClientHandle & a_Client) override { UNUSED(a_Client); }
|
||||
|
||||
static void LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid);
|
||||
|
@ -72,37 +72,6 @@ void cFlowerPotEntity::Destroy(void)
|
||||
|
||||
|
||||
|
||||
bool cFlowerPotEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
m_Item = cItem();
|
||||
m_Item.FromJson(a_Value.get("Item", 0));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cFlowerPotEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
Json::Value Item;
|
||||
m_Item.GetJson(Item);
|
||||
a_Value["Item"] = Item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cFlowerPotEntity::IsFlower(short m_ItemType, short m_ItemData)
|
||||
{
|
||||
switch (m_ItemType)
|
||||
|
@ -38,9 +38,6 @@ public:
|
||||
|
||||
/** Creates a new flowerpot entity at the specified block coords. a_World may be NULL */
|
||||
cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
|
||||
bool LoadFromJson( const Json::Value& a_Value);
|
||||
virtual void SaveToJson(Json::Value& a_Value) override;
|
||||
|
||||
virtual void Destroy(void) override;
|
||||
|
||||
|
@ -129,60 +129,6 @@ bool cFurnaceEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
|
||||
|
||||
bool cFurnaceEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
Json::Value AllSlots = a_Value.get("Slots", 0);
|
||||
int SlotIdx = 0;
|
||||
for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
|
||||
{
|
||||
cItem Item;
|
||||
Item.FromJson(*itr);
|
||||
SetSlot(SlotIdx, Item);
|
||||
SlotIdx++;
|
||||
}
|
||||
|
||||
m_NeedCookTime = (int)(a_Value.get("CookTime", 0).asDouble() / 50);
|
||||
m_TimeCooked = (int)(a_Value.get("TimeCooked", 0).asDouble() / 50);
|
||||
m_FuelBurnTime = (int)(a_Value.get("BurnTime", 0).asDouble() / 50);
|
||||
m_TimeBurned = (int)(a_Value.get("TimeBurned", 0).asDouble() / 50);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cFurnaceEntity::SaveToJson( Json::Value& a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
Json::Value AllSlots;
|
||||
int NumSlots = m_Contents.GetNumSlots();
|
||||
for (int i = 0; i < NumSlots; i++)
|
||||
{
|
||||
Json::Value Slot;
|
||||
m_Contents.GetSlot(i).GetJson(Slot);
|
||||
AllSlots.append(Slot);
|
||||
}
|
||||
a_Value["Slots"] = AllSlots;
|
||||
|
||||
a_Value["CookTime"] = m_NeedCookTime * 50;
|
||||
a_Value["TimeCooked"] = m_TimeCooked * 50;
|
||||
a_Value["BurnTime"] = m_FuelBurnTime * 50;
|
||||
a_Value["TimeBurned"] = m_TimeBurned * 50;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cFurnaceEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
// Nothing needs to be sent
|
||||
|
@ -44,11 +44,8 @@ public:
|
||||
virtual ~cFurnaceEntity();
|
||||
|
||||
static const char * GetClassStatic() { return "cFurnaceEntity"; }
|
||||
|
||||
bool LoadFromJson(const Json::Value & a_Value);
|
||||
|
||||
// cBlockEntity overrides:
|
||||
virtual void SaveToJson(Json::Value & a_Value) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
|
@ -70,17 +70,6 @@ bool cHopperEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
|
||||
|
||||
void cHopperEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
UNUSED(a_Value);
|
||||
// TODO
|
||||
LOGWARNING("%s: Not implemented yet", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cHopperEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
// The hopper entity doesn't need anything sent to the client when it's created / gets in the viewdistance
|
||||
|
@ -49,7 +49,6 @@ protected:
|
||||
|
||||
// cBlockEntity overrides:
|
||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void SaveToJson(Json::Value & a_Value) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
|
||||
|
@ -117,31 +117,3 @@ void cJukeboxEntity::SetRecord(int a_Record)
|
||||
|
||||
|
||||
|
||||
|
||||
bool cJukeboxEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
m_Record = a_Value.get("Record", 0).asInt();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cJukeboxEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
a_Value["Record"] = m_Record;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -29,9 +29,6 @@ public:
|
||||
cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
virtual ~cJukeboxEntity();
|
||||
|
||||
bool LoadFromJson(const Json::Value & a_Value);
|
||||
virtual void SaveToJson(Json::Value & a_Value) override;
|
||||
|
||||
// tolua_begin
|
||||
|
||||
int GetRecord(void);
|
||||
|
@ -77,35 +77,3 @@ void cMobHeadEntity::SendTo(cClientHandle & a_Client)
|
||||
|
||||
|
||||
|
||||
|
||||
bool cMobHeadEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
m_Type = static_cast<eMobHeadType>(a_Value.get("Type", 0).asInt());
|
||||
m_Rotation = static_cast<eMobHeadRotation>(a_Value.get("Rotation", 0).asInt());
|
||||
m_Owner = a_Value.get("Owner", "").asString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cMobHeadEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
a_Value["Type"] = m_Type;
|
||||
a_Value["Rotation"] = m_Rotation;
|
||||
a_Value["Owner"] = m_Owner;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -37,9 +37,6 @@ public:
|
||||
/** Creates a new mob head entity at the specified block coords. a_World may be NULL */
|
||||
cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
|
||||
bool LoadFromJson( const Json::Value& a_Value);
|
||||
virtual void SaveToJson(Json::Value& a_Value) override;
|
||||
|
||||
// tolua_begin
|
||||
|
||||
/** Set the Type */
|
||||
|
@ -124,32 +124,3 @@ void cNoteEntity::IncrementPitch(void)
|
||||
|
||||
|
||||
|
||||
|
||||
bool cNoteEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
m_Pitch = (char)a_Value.get("p", 0).asInt();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cNoteEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
a_Value["p"] = m_Pitch;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -44,9 +44,6 @@ public:
|
||||
cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
||||
virtual ~cNoteEntity() {}
|
||||
|
||||
bool LoadFromJson(const Json::Value & a_Value);
|
||||
virtual void SaveToJson(Json::Value & a_Value) override;
|
||||
|
||||
// tolua_begin
|
||||
|
||||
char GetPitch(void);
|
||||
|
@ -22,7 +22,6 @@ cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorl
|
||||
|
||||
|
||||
|
||||
// It don't do anything when 'used'
|
||||
void cSignEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
UNUSED(a_Player);
|
||||
@ -80,37 +79,3 @@ void cSignEntity::SendTo(cClientHandle & a_Client)
|
||||
|
||||
|
||||
|
||||
|
||||
bool cSignEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
m_Line[0] = a_Value.get("Line1", "").asString();
|
||||
m_Line[1] = a_Value.get("Line2", "").asString();
|
||||
m_Line[2] = a_Value.get("Line3", "").asString();
|
||||
m_Line[3] = a_Value.get("Line4", "").asString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cSignEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
a_Value["Line1"] = m_Line[0];
|
||||
a_Value["Line2"] = m_Line[1];
|
||||
a_Value["Line3"] = m_Line[2];
|
||||
a_Value["Line4"] = m_Line[3];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -37,9 +37,6 @@ public:
|
||||
/// Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be NULL
|
||||
cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
|
||||
|
||||
bool LoadFromJson( const Json::Value& a_Value);
|
||||
virtual void SaveToJson(Json::Value& a_Value) override;
|
||||
|
||||
// tolua_begin
|
||||
|
||||
/// Sets all the sign's lines
|
||||
|
@ -14,7 +14,6 @@ SET (SRCS
|
||||
ScoreboardSerializer.cpp
|
||||
StatSerializer.cpp
|
||||
WSSAnvil.cpp
|
||||
WSSCompact.cpp
|
||||
WorldStorage.cpp)
|
||||
|
||||
SET (HDRS
|
||||
@ -27,7 +26,6 @@ SET (HDRS
|
||||
ScoreboardSerializer.h
|
||||
StatSerializer.h
|
||||
WSSAnvil.h
|
||||
WSSCompact.h
|
||||
WorldStorage.h)
|
||||
|
||||
if(NOT MSVC)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,157 +0,0 @@
|
||||
|
||||
// WSSCompact.h
|
||||
|
||||
// Interfaces to the cWSSCompact class representing the "Compact" storage schema (PAK-files)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
#ifndef WSSCOMPACT_H_INCLUDED
|
||||
#define WSSCOMPACT_H_INCLUDED
|
||||
|
||||
#include "WorldStorage.h"
|
||||
#include "../Vector3.h"
|
||||
#include "json/json.h"
|
||||
#include "ChunkDataCallback.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// Helper class for serializing a chunk into Json
|
||||
class cJsonChunkSerializer :
|
||||
public cChunkDataArrayCollector
|
||||
{
|
||||
public:
|
||||
|
||||
cJsonChunkSerializer(void);
|
||||
|
||||
Json::Value & GetRoot (void) {return m_Root; }
|
||||
BLOCKTYPE * GetBlockData(void) {return (BLOCKTYPE *)m_BlockData; }
|
||||
bool HasJsonData (void) const {return m_HasJsonData; }
|
||||
|
||||
protected:
|
||||
|
||||
// NOTE: block data is serialized into inherited cChunkDataCollector's m_BlockData[] array
|
||||
|
||||
// Entities and BlockEntities are serialized to Json
|
||||
Json::Value m_Root;
|
||||
bool m_HasJsonData;
|
||||
|
||||
// cChunkDataCollector overrides:
|
||||
virtual void Entity (cEntity * a_Entity) override;
|
||||
virtual void BlockEntity (cBlockEntity * a_Entity) override;
|
||||
virtual void LightIsValid (bool a_IsLightValid) override;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class cWSSCompact :
|
||||
public cWSSchema
|
||||
{
|
||||
public:
|
||||
cWSSCompact(cWorld * a_World, int a_CompressionFactor) : cWSSchema(a_World), m_CompressionFactor(a_CompressionFactor) {}
|
||||
virtual ~cWSSCompact();
|
||||
|
||||
protected:
|
||||
|
||||
enum
|
||||
{
|
||||
// Offsets to individual components in the joined blockdata array
|
||||
MetaOffset = cChunkDef::NumBlocks,
|
||||
LightOffset = MetaOffset + cChunkDef::NumBlocks / 2,
|
||||
SkyLightOffset = LightOffset + cChunkDef::NumBlocks / 2,
|
||||
} ;
|
||||
|
||||
struct sChunkHeader;
|
||||
typedef std::vector<sChunkHeader *> sChunkHeaders;
|
||||
|
||||
/// Implements a cache for a single PAK file; implements lazy-write in order to be able to write multiple chunks fast
|
||||
class cPAKFile
|
||||
{
|
||||
public:
|
||||
|
||||
cPAKFile(const AString & a_FileName, int a_LayerX, int a_LayerZ, int a_CompressionFactor);
|
||||
~cPAKFile();
|
||||
|
||||
bool GetChunkData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, AString & a_Data);
|
||||
bool SetChunkData(const cChunkCoords & a_Chunk, int a_UncompressedSize, const AString & a_Data);
|
||||
bool EraseChunkData(const cChunkCoords & a_Chunk);
|
||||
|
||||
bool SaveChunk(const cChunkCoords & a_Chunk, cWorld * a_World);
|
||||
|
||||
int GetLayerX(void) const {return m_LayerX; }
|
||||
int GetLayerZ(void) const {return m_LayerZ; }
|
||||
|
||||
static const int PAK_VERSION = 1;
|
||||
#if AXIS_ORDER == AXIS_ORDER_XZY
|
||||
static const int CHUNK_VERSION = 3;
|
||||
#elif AXIS_ORDER == AXIS_ORDER_YZX
|
||||
static const int CHUNK_VERSION = 2;
|
||||
#endif
|
||||
protected:
|
||||
|
||||
AString m_FileName;
|
||||
int m_CompressionFactor;
|
||||
int m_LayerX;
|
||||
int m_LayerZ;
|
||||
|
||||
sChunkHeaders m_ChunkHeaders;
|
||||
AString m_DataContents; // Data contents of the file, cached
|
||||
|
||||
int m_NumDirty; // Number of chunks that were written into m_DataContents but not into the file
|
||||
|
||||
Vector3i m_ChunkSize; // Is related to m_ChunkVersion
|
||||
char m_ChunkVersion;
|
||||
char m_PakVersion;
|
||||
|
||||
bool SaveChunkToData(const cChunkCoords & a_Chunk, cWorld * a_World); // Saves the chunk to m_DataContents, updates headers and m_NumDirty
|
||||
void SynchronizeFile(void); // Writes m_DataContents along with the headers to file, resets m_NumDirty
|
||||
|
||||
void UpdateChunk1To2(void); // Height from 128 to 256
|
||||
void UpdateChunk2To3(void); // Axis order from YZX to XZY
|
||||
} ;
|
||||
|
||||
typedef std::list<cPAKFile *> cPAKFiles;
|
||||
|
||||
cCriticalSection m_CS;
|
||||
cPAKFiles m_PAKFiles; // A MRU cache of PAK files
|
||||
|
||||
int m_CompressionFactor;
|
||||
|
||||
/// Loads the correct PAK file either from cache or from disk, manages the m_PAKFiles cache
|
||||
cPAKFile * LoadPAKFile(const cChunkCoords & a_Chunk);
|
||||
|
||||
/// Gets chunk data from the correct file; locks CS as needed
|
||||
bool GetChunkData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, AString & a_Data);
|
||||
|
||||
/// Sets chunk data to the correct file; locks CS as needed
|
||||
bool SetChunkData(const cChunkCoords & a_Chunk, int a_UncompressedSize, const AString & a_Data);
|
||||
|
||||
/// Erases chunk data from the correct file; locks CS as needed
|
||||
bool EraseChunkData(const cChunkCoords & a_Chunk);
|
||||
|
||||
/// Loads the chunk from the data (no locking needed)
|
||||
bool LoadChunkFromData(const cChunkCoords & a_Chunk, int a_UncompressedSize, const AString & a_Data, cWorld * a_World);
|
||||
|
||||
void LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, cWorld * a_World);
|
||||
|
||||
// cWSSchema overrides:
|
||||
virtual bool LoadChunk(const cChunkCoords & a_Chunk) override;
|
||||
virtual bool SaveChunk(const cChunkCoords & a_Chunk) override;
|
||||
virtual const AString GetName(void) const override {return "compact"; }
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // WSSCOMPACT_H_INCLUDED
|
||||
|
||||
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "Globals.h"
|
||||
#include "WorldStorage.h"
|
||||
#include "WSSCompact.h"
|
||||
#include "WSSAnvil.h"
|
||||
#include "../World.h"
|
||||
#include "../Generating/ChunkGenerator.h"
|
||||
@ -187,7 +186,6 @@ void cWorldStorage::InitSchemas(int a_StorageCompressionFactor)
|
||||
{
|
||||
// The first schema added is considered the default
|
||||
m_Schemas.push_back(new cWSSAnvil (m_World, a_StorageCompressionFactor));
|
||||
m_Schemas.push_back(new cWSSCompact (m_World, a_StorageCompressionFactor));
|
||||
m_Schemas.push_back(new cWSSForgetful(m_World));
|
||||
// Add new schemas here
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user