summaryrefslogtreecommitdiffstats
path: root/source/cChunkGenerator.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
commit4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c (patch)
treefebea3ecd89c0d4aa83924e430bf11366d754733 /source/cChunkGenerator.h
parentNew makefile with automatic *.cpp sourcefile import, automatic header file dependencies and switchable debug / release configuration. gnumake-specific :( (diff)
downloadcuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.gz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.bz2
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.lz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.xz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.zst
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.zip
Diffstat (limited to '')
-rw-r--r--source/cChunkGenerator.h62
1 files changed, 52 insertions, 10 deletions
diff --git a/source/cChunkGenerator.h b/source/cChunkGenerator.h
index bdba4da98..5de056572 100644
--- a/source/cChunkGenerator.h
+++ b/source/cChunkGenerator.h
@@ -1,20 +1,62 @@
+
+// cChunkGenerator.h
+
+// Interfaces to the cChunkGenerator class representing the thread that generates chunks
+
+// The object takes requests for generating chunks and processes them in a separate thread one by one.
+// The requests are not added to the queue if there is already a request with the same coords
+// Before generating, the thread checks if the chunk hasn't been already generated.
+// It is theoretically possible to have multiple generator threads by having multiple instances of this object (if the cChunkPtr is thread-safe)
+// If the generator queue is overloaded, the generator skips chunks with no clients in them
+
+
+
+
+
#pragma once
-class cChunk;
-class cChunkMap;
-class cChunkGenerator
+#include "cIsThread.h"
+#include "cChunk.h"
+
+
+
+
+
+class cWorld;
+class cWorldGenerator;
+
+
+
+
+
+class cChunkGenerator :
+ cIsThread
{
+ typedef cIsThread super;
+
public:
- cChunkGenerator( cChunkMap* a_pChunkMap );
+
+ cChunkGenerator (void);
~cChunkGenerator();
- void GenerateChunk( int a_X, int a_Z );
+ bool Start(cWorld * a_World, const AString & a_WorldGeneratorName);
+ void Stop(void);
+
+ void GenerateChunk(int a_ChunkX, int a_ChunkZ); // Queues the chunk for generation; removes duplicate requests
private:
- static void GenerateThread( void* a_Params );
- cChunkMap* m_pChunkMap;
+ // cIsThread override:
+ virtual void Execute(void) override;
+
+ cWorld * m_World;
+ cWorldGenerator * m_pWorldGenerator;
+
+ cCriticalSection m_CS;
+ cChunkCoordsList m_Queue;
+ cEvent m_Event; // Set when an item is added to the queue or the thread should terminate
+};
+
+
+
- struct sChunkGeneratorState;
- sChunkGeneratorState* m_pState;
-}; \ No newline at end of file