Files
cuberite-2a/Tools/QtBiomeVisualiser/ChunkSource.h
T

76 lines
1.5 KiB
C++
Raw Normal View History

2014-09-14 01:32:00 +02:00
#pragma once
2014-09-15 16:50:40 +02:00
#include <QString>
2014-09-14 01:32:00 +02:00
#include "Chunk.h"
// fwd:
class cBiomeGen;
2014-09-15 16:50:40 +02:00
typedef std::shared_ptr<cBiomeGen> cBiomeGenPtr;
class cIniFile;
2014-09-14 01:32:00 +02:00
/** Abstract interface for getting biome data for chunks. */
class ChunkSource
{
public:
virtual ~ChunkSource() {}
/** Fills the a_DestChunk with the biomes for the specified coords.
It is expected to be thread-safe and re-entrant. Usually QThread::idealThreadCount() threads are used. */
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) = 0;
2014-09-15 16:50:40 +02:00
/** Forces a fresh reload of the source. Useful mainly for the generator, whose underlying definition file may have been changed. */
virtual void reload() = 0;
2014-09-14 01:32:00 +02:00
};
class BioGenSource :
public ChunkSource
{
public:
2014-09-15 16:50:40 +02:00
/** Constructs a new BioGenSource based on the biome generator that is defined in the specified world.ini file. */
BioGenSource(QString a_WorldIniPath);
2014-09-14 01:32:00 +02:00
2014-09-15 16:50:40 +02:00
// ChunkSource overrides:
2014-09-14 01:32:00 +02:00
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
2014-09-15 16:50:40 +02:00
virtual void reload(void) override;
2014-09-14 01:32:00 +02:00
protected:
2014-09-15 16:50:40 +02:00
/** Path to the world.ini file from which the m_WorldIni is regenerated on reload requests. */
QString m_WorldIniPath;
2014-09-15 17:20:54 +02:00
/** The generator used for generating biomes. */
std::unique_ptr<cBiomeGen> m_BiomeGen;
2014-09-15 16:50:40 +02:00
2014-09-15 17:20:54 +02:00
/** Guards m_BiomeGen against multithreaded access. */
2014-09-14 01:32:00 +02:00
QMutex m_Mtx;
};
class AnvilSource :
public ChunkSource
{
public:
// TODO
2014-09-15 16:50:40 +02:00
// ChunkSource overrides:
2014-09-14 01:32:00 +02:00
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
2014-09-15 16:50:40 +02:00
virtual void reload() override {}
2014-09-14 01:32:00 +02:00
};