summaryrefslogtreecommitdiffstats
path: root/source/WSSCompact.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-23 22:12:48 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-23 22:12:48 +0100
commitbe31652c40af10b0410c76c6bd37b60717c385be (patch)
treea84e138bc4d0c1cd4b298dc807f3a196e9a78e3d /source/WSSCompact.cpp
parentFixed a deadlock by removing clients from all chunks upon their exit, not using the clients chunklists. (diff)
downloadcuberite-be31652c40af10b0410c76c6bd37b60717c385be.tar
cuberite-be31652c40af10b0410c76c6bd37b60717c385be.tar.gz
cuberite-be31652c40af10b0410c76c6bd37b60717c385be.tar.bz2
cuberite-be31652c40af10b0410c76c6bd37b60717c385be.tar.lz
cuberite-be31652c40af10b0410c76c6bd37b60717c385be.tar.xz
cuberite-be31652c40af10b0410c76c6bd37b60717c385be.tar.zst
cuberite-be31652c40af10b0410c76c6bd37b60717c385be.zip
Diffstat (limited to '')
-rw-r--r--source/WSSCompact.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/source/WSSCompact.cpp b/source/WSSCompact.cpp
index 8c27dba51..86c92e7ed 100644
--- a/source/WSSCompact.cpp
+++ b/source/WSSCompact.cpp
@@ -5,7 +5,6 @@
#include "Globals.h"
#include "WSSCompact.h"
-#include "cWorld.h"
#include "zlib.h"
#include <json/json.h>
#include "StringCompression.h"
@@ -68,7 +67,7 @@ bool cWSSCompact::LoadChunk(const cChunkCoords & a_Chunk)
return false;
}
- return LoadChunkFromData(a_Chunk, UncompressedSize, ChunkData, m_World);
+ return LoadChunkFromData(a_Chunk, UncompressedSize, ChunkData, m_WSI);
}
@@ -86,7 +85,7 @@ bool cWSSCompact::SaveChunk(const cChunkCoords & a_Chunk)
LOG("Cannot locate a proper PAK file for chunk [%d, %d]", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
return false;
}
- return f->SaveChunk(a_Chunk, m_World);
+ return f->SaveChunk(a_Chunk, m_WSI);
}
@@ -119,7 +118,7 @@ cWSSCompact::cPAKFile * cWSSCompact::LoadPAKFile(const cChunkCoords & a_Chunk)
// Load it anew:
AString FileName;
- Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ );
+ Printf(FileName, "%s/X%i_Z%i.pak", m_WSI->WSIGetFolder().c_str(), LayerX, LayerZ );
cPAKFile * f = new cPAKFile(FileName, LayerX, LayerZ);
if (f == NULL)
{
@@ -188,7 +187,7 @@ bool cWSSCompact::EraseChunkData(const cChunkCoords & a_Chunk)
-void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, cWorld * a_World)
+void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, cWSInterface * a_WSI)
{
// Load chests
Json::Value AllChests = a_Value.get("Chests", Json::nullValue);
@@ -197,7 +196,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr )
{
Json::Value & Chest = *itr;
- cChestEntity * ChestEntity = new cChestEntity(0,0,0, a_World);
+ cChestEntity * ChestEntity = new cChestEntity(0, 0, 0);
if (!ChestEntity->LoadFromJson( Chest ) )
{
LOGERROR("ERROR READING CHEST FROM JSON!" );
@@ -217,7 +216,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
for( Json::Value::iterator itr = AllFurnaces.begin(); itr != AllFurnaces.end(); ++itr )
{
Json::Value & Furnace = *itr;
- cFurnaceEntity * FurnaceEntity = new cFurnaceEntity(0,0,0, a_World);
+ cFurnaceEntity * FurnaceEntity = new cFurnaceEntity(0, 0, 0);
if( !FurnaceEntity->LoadFromJson( Furnace ) )
{
LOGERROR("ERROR READING FURNACE FROM JSON!" );
@@ -237,7 +236,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
for( Json::Value::iterator itr = AllSigns.begin(); itr != AllSigns.end(); ++itr )
{
Json::Value & Sign = *itr;
- cSignEntity * SignEntity = new cSignEntity( E_BLOCK_SIGN_POST, 0,0,0, a_World);
+ cSignEntity * SignEntity = new cSignEntity( E_BLOCK_SIGN_POST, 0, 0, 0);
if ( !SignEntity->LoadFromJson( Sign ) )
{
LOGERROR("ERROR READING SIGN FROM JSON!" );
@@ -382,7 +381,7 @@ bool cWSSCompact::cPAKFile::GetChunkData(const cChunkCoords & a_Chunk, int & a_U
-bool cWSSCompact::cPAKFile::SaveChunk(const cChunkCoords & a_Chunk, cWorld * a_World)
+bool cWSSCompact::cPAKFile::SaveChunk(const cChunkCoords & a_Chunk, cWSInterface * a_World)
{
if (!SaveChunkToData(a_Chunk, a_World))
{
@@ -681,7 +680,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
-bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, const AString & a_Data, cWorld * a_World)
+bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, const AString & a_Data, cWSInterface * a_WSI)
{
// Crude data integrity check:
if (a_UncompressedSize < cChunkDef::BlockDataSize)
@@ -730,13 +729,13 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_Uncomp
}
else
{
- LoadEntitiesFromJson(root, Entities, BlockEntities, a_World);
+ LoadEntitiesFromJson(root, Entities, BlockEntities, a_WSI);
}
}
BLOCKTYPE * BlockData = (BLOCKTYPE *)UncompressedData.data();
- a_World->ChunkDataLoaded(
+ a_WSI->WSIChunkDataLoaded(
a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ,
BlockData,
BlockData + cChunkDef::MetaOffset,
@@ -778,11 +777,11 @@ bool cWSSCompact::cPAKFile::EraseChunkData(const cChunkCoords & a_Chunk)
-bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld * a_World)
+bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWSInterface * a_WSI)
{
// Serialize the chunk:
cJsonChunkSerializer Serializer;
- if (!a_World->GetChunkData(a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ, Serializer))
+ if (!a_WSI->WSIGetChunkData(a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ, Serializer))
{
// Chunk not valid
LOG("cWSSCompact: Trying to save chunk [%d, %d, %d] that has no data, ignoring request.", a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ);