summaryrefslogtreecommitdiffstats
path: root/source/WorldStorage.h
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/WorldStorage.h
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 'source/WorldStorage.h')
-rw-r--r--source/WorldStorage.h50
1 files changed, 44 insertions, 6 deletions
diff --git a/source/WorldStorage.h b/source/WorldStorage.h
index da78b69f2..047c358ba 100644
--- a/source/WorldStorage.h
+++ b/source/WorldStorage.h
@@ -22,8 +22,45 @@
-// fwd:
-class cWorld;
+/** Interface between cWorld and cWorldStorage, contains all calls into cWorld that cWorldStorage needs
+Defining this as an interface lets us re-use the cWorldStorage outside of MC-Server's main executable,
+for example for tools such as storage converters or chunk analytics
+*/
+class cWSInterface
+{
+public:
+ /// Asks the world if the chunk is fully valid
+ virtual bool WSIIsChunkValid(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Marks the chunk as being saved
+ virtual void WSIMarkChunkSaving(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Marks the chunk as having been saved (if there was no change since the last MarkSaving)
+ virtual void WSIMarkChunkSaved(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Marks the chunk as unable to load
+ virtual void WSIChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Called when chunk generation has been specified for a chunk that cannot be loaded
+ virtual void WSIGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Marks the chunk as having been saved (if there was no change since the last MarkSaving)
+ virtual bool WSIGetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback & a_Callback) = 0;
+
+ /// Gets the folder where the world is saved
+ virtual AString WSIGetFolder(void) = 0;
+
+ virtual void WSIChunkDataLoaded(
+ int a_ChunkX, int a_ChunkY, int a_ChunkZ,
+ const BLOCKTYPE * a_BlockTypes,
+ const BLOCKTYPE * a_BlockMeta,
+ const BLOCKTYPE * a_BlockLight,
+ const BLOCKTYPE * a_BlockSkyLight,
+ const cChunkDef::HeightMap * a_HeightMap,
+ cEntityList & a_Entities,
+ cBlockEntityList & a_BlockEntities
+ ) = 0;
+} ;
@@ -33,7 +70,7 @@ class cWorld;
class cWSSchema abstract
{
public:
- cWSSchema(cWorld * a_World) : m_World(a_World) {}
+ cWSSchema(cWSInterface * a_WSI) : m_WSI(a_WSI) {}
virtual ~cWSSchema() {} // Force the descendants' destructors to be virtual
virtual bool LoadChunk(const cChunkCoords & a_Chunk) = 0;
@@ -42,7 +79,7 @@ public:
protected:
- cWorld * m_World;
+ cWSInterface * m_WSI;
} ;
typedef std::list<cWSSchema *> cWSSchemaList;
@@ -103,7 +140,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(cWSInterface * a_WSI, const AString & a_StorageSchemaName); // Hide the cIsThread's Start() method, we need to provide args
void WaitForFinish(void);
void WaitForQueuesEmpty(void);
@@ -124,7 +161,8 @@ protected:
typedef std::list<sChunkLoad> sChunkLoadQueue;
- cWorld * m_World;
+ cWSInterface * m_WSI;
+
AString m_StorageSchemaName;
// Both queues are locked by the same CS