summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-01-17 20:01:14 +0100
committerTycho <work.tycho+git@gmail.com>2014-01-17 20:01:14 +0100
commita54cbba0fdf697999e8ac4aff2f5ea436c98edc3 (patch)
tree7f1d8d463d0d70ba888c992f80681a1775a31b6b /src/WorldStorage
parentAPIDump: Updated cPluginManager:GetAllPlugins(). (diff)
downloadcuberite-a54cbba0fdf697999e8ac4aff2f5ea436c98edc3.tar
cuberite-a54cbba0fdf697999e8ac4aff2f5ea436c98edc3.tar.gz
cuberite-a54cbba0fdf697999e8ac4aff2f5ea436c98edc3.tar.bz2
cuberite-a54cbba0fdf697999e8ac4aff2f5ea436c98edc3.tar.lz
cuberite-a54cbba0fdf697999e8ac4aff2f5ea436c98edc3.tar.xz
cuberite-a54cbba0fdf697999e8ac4aff2f5ea436c98edc3.tar.zst
cuberite-a54cbba0fdf697999e8ac4aff2f5ea436c98edc3.zip
Diffstat (limited to '')
-rw-r--r--src/WorldStorage/WSSAnvil.cpp7
-rw-r--r--src/WorldStorage/WSSAnvil.h4
-rw-r--r--src/WorldStorage/WSSCompact.cpp11
-rw-r--r--src/WorldStorage/WSSCompact.h7
-rw-r--r--src/WorldStorage/WorldStorage.cpp10
-rw-r--r--src/WorldStorage/WorldStorage.h4
6 files changed, 25 insertions, 18 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 72c47aa14..16513cd1b 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -58,8 +58,9 @@ Since only the header is actually in the memory, this number can be high, but st
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cWSSAnvil:
-cWSSAnvil::cWSSAnvil(cWorld * a_World) :
- super(a_World)
+cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
+ super(a_World),
+ m_CompressionFactor(a_CompressionFactor)
{
// Create a level.dat file for mapping tools, if it doesn't already exist:
AString fnam;
@@ -272,7 +273,7 @@ bool cWSSAnvil::SaveChunkToData(const cChunkCoords & a_Chunk, AString & a_Data)
}
Writer.Finish();
- CompressString(Writer.GetResult().data(), Writer.GetResult().size(), a_Data);
+ CompressString(Writer.GetResult().data(), Writer.GetResult().size(), a_Data, m_CompressionFactor);
return true;
}
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index 0a7406267..e66e63b08 100644
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -47,7 +47,7 @@ class cWSSAnvil :
public:
- cWSSAnvil(cWorld * a_World);
+ cWSSAnvil(cWorld * a_World, int a_CompressionFactor);
virtual ~cWSSAnvil();
protected:
@@ -89,6 +89,8 @@ protected:
cCriticalSection m_CS;
cMCAFiles m_Files; // a MRU cache of MCA files
+
+ int m_CompressionFactor;
/// Gets chunk data from the correct file; locks file CS as needed
bool GetChunkData(const cChunkCoords & a_Chunk, AString & a_Data);
diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp
index e2556b96e..ea17a8ec1 100644
--- a/src/WorldStorage/WSSCompact.cpp
+++ b/src/WorldStorage/WSSCompact.cpp
@@ -193,7 +193,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 );
- cPAKFile * f = new cPAKFile(FileName, LayerX, LayerZ);
+ cPAKFile * f = new cPAKFile(FileName, LayerX, LayerZ, m_CompressionFactor);
if (f == NULL)
{
return NULL;
@@ -399,8 +399,9 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
return; \
}
-cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_LayerZ) :
+cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_LayerZ, int a_CompressionFactor) :
m_FileName(a_FileName),
+ m_CompressionFactor(a_CompressionFactor),
m_LayerX(a_LayerX),
m_LayerZ(a_LayerZ),
m_NumDirty(0),
@@ -648,7 +649,7 @@ void cWSSCompact::cPAKFile::UpdateChunk1To2()
// Re-compress data
AString CompressedData;
{
- int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData);
+ int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData,m_CompressionFactor);
if (errorcode != Z_OK)
{
LOGERROR("Error %d compressing data for chunk [%d, %d]",
@@ -786,7 +787,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
// Re-compress data
AString CompressedData;
{
- int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData);
+ int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData, m_CompressionFactor);
if (errorcode != Z_OK)
{
LOGERROR("Error %d compressing data for chunk [%d, %d]",
@@ -939,7 +940,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld
// Compress the data:
AString CompressedData;
- int errorcode = CompressString(Data.data(), Data.size(), CompressedData);
+ int errorcode = CompressString(Data.data(), Data.size(), CompressedData, m_CompressionFactor);
if ( errorcode != Z_OK )
{
LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ);
diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h
index 3223a986e..64b8d7f31 100644
--- a/src/WorldStorage/WSSCompact.h
+++ b/src/WorldStorage/WSSCompact.h
@@ -53,7 +53,7 @@ class cWSSCompact :
public cWSSchema
{
public:
- cWSSCompact(cWorld * a_World) : cWSSchema(a_World) {}
+ cWSSCompact(cWorld * a_World, int a_CompressionFactor) : cWSSchema(a_World), m_CompressionFactor(a_CompressionFactor) {}
virtual ~cWSSCompact();
protected:
@@ -74,7 +74,7 @@ protected:
{
public:
- cPAKFile(const AString & a_FileName, int a_LayerX, int a_LayerZ);
+ 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);
@@ -95,6 +95,7 @@ protected:
protected:
AString m_FileName;
+ int m_CompressionFactor;
int m_LayerX;
int m_LayerZ;
@@ -119,6 +120,8 @@ protected:
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);
diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp
index 6aec525a8..711c8612f 100644
--- a/src/WorldStorage/WorldStorage.cpp
+++ b/src/WorldStorage/WorldStorage.cpp
@@ -68,11 +68,11 @@ cWorldStorage::~cWorldStorage()
-bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName)
+bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor )
{
m_World = a_World;
m_StorageSchemaName = a_StorageSchemaName;
- InitSchemas();
+ InitSchemas(a_StorageCompressionFactor);
return super::Start();
}
@@ -197,11 +197,11 @@ void cWorldStorage::UnqueueSave(const cChunkCoords & a_Chunk)
-void cWorldStorage::InitSchemas(void)
+void cWorldStorage::InitSchemas(int a_StorageCompressionFactor)
{
// The first schema added is considered the default
- m_Schemas.push_back(new cWSSAnvil (m_World));
- m_Schemas.push_back(new cWSSCompact (m_World));
+ 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
diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h
index 06cae1717..bb189b6c9 100644
--- a/src/WorldStorage/WorldStorage.h
+++ b/src/WorldStorage/WorldStorage.h
@@ -76,7 +76,7 @@ public:
void UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
void UnqueueSave(const cChunkCoords & a_Chunk);
- bool Start(cWorld * a_World, const AString & a_StorageSchemaName); // Hide the cIsThread's Start() method, we need to provide args
+ bool Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor); // Hide the cIsThread's Start() method, we need to provide args
void Stop(void); // Hide the cIsThread's Stop() method, we need to signal the event
void WaitForFinish(void);
void WaitForLoadQueueEmpty(void);
@@ -126,7 +126,7 @@ protected:
/// The one storage schema used for saving
cWSSchema * m_SaveSchema;
- void InitSchemas(void);
+ void InitSchemas(int a_StorageCompressionFactor);
virtual void Execute(void) override;