summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-02-13 17:04:25 +0100
committermadmaxoft <github@xoft.cz>2014-02-13 17:04:25 +0100
commit9bb48a8fa4368d9cc5d9050a6a67f38891afc14e (patch)
treefcf8e28d0843c8a61990a146ff9643702a5ecc24 /src
parentMCADefrag: Implemented recompression. (diff)
parentFixed formatting issue in APIDesc.lua (diff)
downloadcuberite-9bb48a8fa4368d9cc5d9050a6a67f38891afc14e.tar
cuberite-9bb48a8fa4368d9cc5d9050a6a67f38891afc14e.tar.gz
cuberite-9bb48a8fa4368d9cc5d9050a6a67f38891afc14e.tar.bz2
cuberite-9bb48a8fa4368d9cc5d9050a6a67f38891afc14e.tar.lz
cuberite-9bb48a8fa4368d9cc5d9050a6a67f38891afc14e.tar.xz
cuberite-9bb48a8fa4368d9cc5d9050a6a67f38891afc14e.tar.zst
cuberite-9bb48a8fa4368d9cc5d9050a6a67f38891afc14e.zip
Diffstat (limited to 'src')
-rw-r--r--src/World.cpp22
-rw-r--r--src/World.h15
2 files changed, 36 insertions, 1 deletions
diff --git a/src/World.cpp b/src/World.cpp
index f8c1091f0..cb07caa5d 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -2213,6 +2213,15 @@ void cWorld::UnloadUnusedChunks(void)
+void cWorld::QueueUnloadUnusedChunks(void)
+{
+ QueueTask(new cWorld::cTaskUnloadUnusedChunks);
+}
+
+
+
+
+
void cWorld::CollectPickupsByPlayer(cPlayer * a_Player)
{
m_ChunkMap->CollectPickupsByPlayer(a_Player);
@@ -2945,6 +2954,7 @@ cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const c
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cWorld::cTaskSaveAllChunks:
@@ -2958,6 +2968,18 @@ void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cWorld::cTaskUnloadUnusedChunks
+
+void cWorld::cTaskUnloadUnusedChunks::Run(cWorld & a_World)
+{
+ a_World.UnloadUnusedChunks();
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cWorld::cChunkGeneratorCallbacks:
cWorld::cChunkGeneratorCallbacks::cChunkGeneratorCallbacks(cWorld & a_World) :
diff --git a/src/World.h b/src/World.h
index fa83fe73e..de4fa6ea6 100644
--- a/src/World.h
+++ b/src/World.h
@@ -99,6 +99,15 @@ public:
} ;
+ class cTaskUnloadUnusedChunks :
+ public cTask
+ {
+ protected:
+ // cTask overrides:
+ virtual void Run(cWorld & a_World) override;
+ };
+
+
static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
{
return "cWorld";
@@ -243,7 +252,8 @@ public:
bool IsChunkValid (int a_ChunkX, int a_ChunkZ) const;
bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const;
- void UnloadUnusedChunks(void); // tolua_export
+ /** Queues a task to unload unused chunks onto the tick thread. The prefferred way of unloading*/
+ void QueueUnloadUnusedChunks(void); // tolua_export
void CollectPickupsByPlayer(cPlayer * a_Player);
@@ -866,6 +876,9 @@ private:
/** Ticks all clients that are in this world */
void TickClients(float a_Dt);
+ /** Unloads all chunks immediately.*/
+ void UnloadUnusedChunks(void);
+
void UpdateSkyDarkness(void);
/** <summary>Generates a random spawnpoint on solid land by walking chunks and finding their biomes</summary> */