summaryrefslogtreecommitdiffstats
path: root/Tools/QtBiomeVisualiser/ChunkSource.h
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-26 23:56:20 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-26 23:56:20 +0200
commit033d16babb9390cea463eea61739f0ca2b1d315a (patch)
tree02a2afded18f202c62d2f3a87dce88428f63cb8b /Tools/QtBiomeVisualiser/ChunkSource.h
parentImplemented mob spawner. (diff)
parentMerge pull request #1456 from Howaner/Fixes (diff)
downloadcuberite-033d16babb9390cea463eea61739f0ca2b1d315a.tar
cuberite-033d16babb9390cea463eea61739f0ca2b1d315a.tar.gz
cuberite-033d16babb9390cea463eea61739f0ca2b1d315a.tar.bz2
cuberite-033d16babb9390cea463eea61739f0ca2b1d315a.tar.lz
cuberite-033d16babb9390cea463eea61739f0ca2b1d315a.tar.xz
cuberite-033d16babb9390cea463eea61739f0ca2b1d315a.tar.zst
cuberite-033d16babb9390cea463eea61739f0ca2b1d315a.zip
Diffstat (limited to 'Tools/QtBiomeVisualiser/ChunkSource.h')
-rw-r--r--Tools/QtBiomeVisualiser/ChunkSource.h43
1 files changed, 37 insertions, 6 deletions
diff --git a/Tools/QtBiomeVisualiser/ChunkSource.h b/Tools/QtBiomeVisualiser/ChunkSource.h
index 868e4a144..7bd1865ff 100644
--- a/Tools/QtBiomeVisualiser/ChunkSource.h
+++ b/Tools/QtBiomeVisualiser/ChunkSource.h
@@ -1,7 +1,8 @@
#pragma once
+#include "Globals.h"
#include <QString>
#include <QMutex>
-#include "Chunk.h"
+#include "QtChunk.h"
@@ -11,6 +12,7 @@
class cBiomeGen;
typedef std::shared_ptr<cBiomeGen> cBiomeGenPtr;
class cIniFile;
+typedef std::shared_ptr<cIniFile> cIniFilePtr;
@@ -40,15 +42,15 @@ class BioGenSource :
{
public:
/** Constructs a new BioGenSource based on the biome generator that is defined in the specified world.ini file. */
- BioGenSource(QString a_WorldIniPath);
+ BioGenSource(cIniFilePtr a_IniFile);
// ChunkSource overrides:
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
virtual void reload(void) override;
protected:
- /** Path to the world.ini file from which the m_WorldIni is regenerated on reload requests. */
- QString m_WorldIniPath;
+ /** The world.ini contents from which the generator is created and re-created on reload(). */
+ cIniFilePtr m_IniFile;
/** The generator used for generating biomes. */
std::unique_ptr<cBiomeGen> m_BiomeGen;
@@ -64,11 +66,40 @@ class AnvilSource :
public ChunkSource
{
public:
- // TODO
+ /** Constructs a new AnvilSource based on the world path. */
+ AnvilSource(QString a_WorldRegionFolder);
// ChunkSource overrides:
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
- virtual void reload() override {}
+ virtual void reload() override;
+
+protected:
+ class AnvilFile;
+ typedef std::shared_ptr<AnvilFile> AnvilFilePtr;
+
+
+ /** Folder where the individual Anvil Region files are located. */
+ QString m_WorldRegionFolder;
+
+ /** List of currently loaded files. Acts as a cache so that a file is not opened and closed over and over again.
+ Protected against multithreaded access by m_Mtx. */
+ std::list<AnvilFilePtr> m_Files;
+
+ /** Guards m_Files agains multithreaded access. */
+ QMutex m_Mtx;
+
+
+ /** Converts chunk coords to region coords. */
+ void chunkToRegion(int a_ChunkX, int a_ChunkZ, int & a_RegionX, int & a_RegionZ);
+
+ /** Returns the compressed data of the specified chunk.
+ Returns an empty string if the chunk is not available. */
+ AString getCompressedChunkData(int a_ChunkX, int a_ChunkZ);
+
+ /** Returns the file object that contains the specified chunk.
+ The file is taken from the cache if available there, otherwise it is created anew. */
+ AnvilFilePtr getAnvilFile(int a_ChunkX, int a_ChunkZ);
+
};