2014-09-13 19:32:00 -04:00
|
|
|
#pragma once
|
2014-09-15 10:50:40 -04:00
|
|
|
#include <QString>
|
2014-09-18 04:24:52 -04:00
|
|
|
#include <QMutex>
|
2014-09-13 19:32:00 -04:00
|
|
|
#include "Chunk.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fwd:
|
|
|
|
class cBiomeGen;
|
2014-09-15 10:50:40 -04:00
|
|
|
typedef std::shared_ptr<cBiomeGen> cBiomeGenPtr;
|
|
|
|
class cIniFile;
|
2014-09-13 19:32:00 -04: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 10:50:40 -04: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-13 19:32:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BioGenSource :
|
|
|
|
public ChunkSource
|
|
|
|
{
|
|
|
|
public:
|
2014-09-15 10:50:40 -04: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-13 19:32:00 -04:00
|
|
|
|
2014-09-15 10:50:40 -04:00
|
|
|
// ChunkSource overrides:
|
2014-09-13 19:32:00 -04:00
|
|
|
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
|
2014-09-15 10:50:40 -04:00
|
|
|
virtual void reload(void) override;
|
2014-09-13 19:32:00 -04:00
|
|
|
|
|
|
|
protected:
|
2014-09-15 10:50:40 -04:00
|
|
|
/** Path to the world.ini file from which the m_WorldIni is regenerated on reload requests. */
|
|
|
|
QString m_WorldIniPath;
|
|
|
|
|
2014-09-15 11:20:54 -04:00
|
|
|
/** The generator used for generating biomes. */
|
|
|
|
std::unique_ptr<cBiomeGen> m_BiomeGen;
|
2014-09-15 10:50:40 -04:00
|
|
|
|
2014-09-15 11:20:54 -04:00
|
|
|
/** Guards m_BiomeGen against multithreaded access. */
|
2014-09-13 19:32:00 -04:00
|
|
|
QMutex m_Mtx;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AnvilSource :
|
|
|
|
public ChunkSource
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// TODO
|
|
|
|
|
2014-09-15 10:50:40 -04:00
|
|
|
// ChunkSource overrides:
|
2014-09-13 19:32:00 -04:00
|
|
|
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
|
2014-09-15 10:50:40 -04:00
|
|
|
virtual void reload() override {}
|
2014-09-13 19:32:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|