summaryrefslogtreecommitdiffstats
path: root/source/cChunkMap.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-26 17:15:09 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-26 17:15:09 +0100
commitb902546863c4b17c6d8ff3f198713aba7a8bbadd (patch)
tree35e67849dc70672b8ccfaf0aeb7e8d8293d639f4 /source/cChunkMap.h
parentAttempt at fixing crashes with disconnecting players (diff)
downloadcuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.gz
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.bz2
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.lz
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.xz
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.zst
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.zip
Diffstat (limited to '')
-rw-r--r--source/cChunkMap.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/cChunkMap.h b/source/cChunkMap.h
index 7de26ee28..21e52c5a8 100644
--- a/source/cChunkMap.h
+++ b/source/cChunkMap.h
@@ -15,6 +15,7 @@ class cWorld;
class cEntity;
class cItem;
class MTRand;
+class cChunkStay;
@@ -83,6 +84,9 @@ public:
void TouchChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
void UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
+
+ /// Marks (a_Stay == true) or unmarks (a_Stay == false) a chunk as non-unloadable; to be used only by cChunkStay!
+ void ChunkStay(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Stay = true);
void Tick( float a_Dt, MTRand & a_TickRand );
@@ -173,3 +177,29 @@ private:
+
+/** Makes chunks stay loaded until this object is cleared or destroyed
+Works by setting internal flags in the cChunk that it should not be unloaded
+*/
+class cChunkStay
+{
+public:
+ cChunkStay(cWorld * a_World);
+ ~cChunkStay();
+
+ void Clear(void);
+
+ void Add(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
+ void Remove(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
+
+protected:
+
+ cWorld * m_World;
+
+ cCriticalSection m_CS;
+ cChunkCoordsList m_Chunks;
+} ;
+
+
+
+