summaryrefslogtreecommitdiffstats
path: root/src/Generating/FinishGen.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-11-25 09:22:13 +0100
committerMattes D <github@xoft.cz>2015-11-25 09:22:20 +0100
commitf2a8d5c0472ee465edb1d2eed38f4e5454f037ab (patch)
tree4b355cc97ddf4b093e1acff47f858dfedb89af5d /src/Generating/FinishGen.h
parentMerge pull request #2687 from Gargaj/signfix (diff)
downloadcuberite-f2a8d5c0472ee465edb1d2eed38f4e5454f037ab.tar
cuberite-f2a8d5c0472ee465edb1d2eed38f4e5454f037ab.tar.gz
cuberite-f2a8d5c0472ee465edb1d2eed38f4e5454f037ab.tar.bz2
cuberite-f2a8d5c0472ee465edb1d2eed38f4e5454f037ab.tar.lz
cuberite-f2a8d5c0472ee465edb1d2eed38f4e5454f037ab.tar.xz
cuberite-f2a8d5c0472ee465edb1d2eed38f4e5454f037ab.tar.zst
cuberite-f2a8d5c0472ee465edb1d2eed38f4e5454f037ab.zip
Diffstat (limited to '')
-rw-r--r--src/Generating/FinishGen.h166
1 files changed, 166 insertions, 0 deletions
diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h
index aa2d0a12d..4541887ec 100644
--- a/src/Generating/FinishGen.h
+++ b/src/Generating/FinishGen.h
@@ -398,3 +398,169 @@ protected:
+
+/** Base class for generators that have an ore list attached to them.
+Provides the storage and parsing for the ore list, as well as the generic plumbing for generating individual ores.
+Descendants should override GenerateOre() to provide the specific ore generation technique.
+Note that this class uses the "Nest" terminology for individual packs of ore, it doesn't imply any shape or algorithm. */
+class cFinishGenOres:
+ public cFinishGen
+{
+ typedef cFinishGen Super;
+
+public:
+ struct OreInfo
+ {
+ BLOCKTYPE m_BlockType; // The type of the nest.
+ NIBBLETYPE m_BlockMeta; // The block meta
+ int m_MaxHeight; // The highest possible a nest can occur
+ int m_NumNests; // How many nests per chunk
+ int m_NestSize; // The amount of blocks a nest can have.
+
+ OreInfo() :
+ m_BlockType(0),
+ m_BlockMeta(0),
+ m_MaxHeight(0),
+ m_NumNests(0),
+ m_NestSize(0)
+ {
+ }
+
+ OreInfo(BLOCKTYPE a_OreType, NIBBLETYPE a_OreMeta, int a_MaxHeight, int a_NumNests, int a_NestSize) :
+ m_BlockType(a_OreType),
+ m_BlockMeta(a_OreMeta),
+ m_MaxHeight(a_MaxHeight),
+ m_NumNests(a_NumNests),
+ m_NestSize(a_NestSize)
+ {
+ }
+ };
+
+ typedef std::vector<OreInfo> OreInfos;
+
+ cFinishGenOres(int a_Seed, const OreInfos & a_OreInfos):
+ m_Noise(a_Seed),
+ m_Seed(a_Seed),
+ m_OreInfos(a_OreInfos)
+ {
+ }
+
+ // cFinishGen overrides:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
+
+ /** Returns a vector of OreInfo structures describing the default Overworld ores, usable in the constructor. */
+ static const OreInfos & DefaultOverworldOres(void);
+
+ /** Returns a vector of OreInfo structures describing the default Nether ores, usable in the constructor. */
+ static const OreInfos & DefaultNetherOres(void);
+
+ /** Returns a vector of OreInfo structures describing the default Overworld non-ore pockets (dirt, diorite etc), usable in the constructor. */
+ static const OreInfos & DefaultNaturalPatches(void);
+
+protected:
+ /** The noise used for generating. */
+ cNoise m_Noise;
+
+ /** The seed for the generating noise. */
+ int m_Seed;
+
+ /** All the ores enabled in this generator. */
+ OreInfos m_OreInfos;
+
+
+ /** Generates a single ore in the specified chunk image.
+ a_Seq is the sequencing number (used as a complement to seed to make each ore in the same chunk have different nests) */
+ virtual void GenerateOre(
+ cChunkDesc & a_ChunkDesc,
+ BLOCKTYPE a_OreType, NIBBLETYPE a_OreMeta,
+ int a_MaxHeight, int a_NumNests, int a_NestSize,
+ int a_Seq
+ ) = 0;
+
+ // TODO: Helper function to parse a config string into m_OreInfos
+};
+
+
+
+
+
+class cFinishGenOreNests :
+ public cFinishGenOres
+{
+ typedef cFinishGenOres Super;
+
+public:
+ cFinishGenOreNests(int a_Seed, const OreInfos & a_OreInfos):
+ Super(a_Seed, a_OreInfos)
+ {}
+
+protected:
+
+ // cFinishGenOreClumps overrides:
+ virtual void GenerateOre(
+ cChunkDesc & a_ChunkDesc,
+ BLOCKTYPE a_OreType, NIBBLETYPE a_OreMeta,
+ int a_MaxHeight, int a_NumNests, int a_NestSize,
+ int a_Seq
+ ) override;
+} ;
+
+
+
+
+
+class cFinishGenOrePockets:
+ public cFinishGenOres
+{
+ typedef cFinishGenOres Super;
+
+public:
+ cFinishGenOrePockets(int a_Seed, const OreInfos & a_OreInfos):
+ Super(a_Seed, a_OreInfos)
+ {}
+
+ /** Reads the configuration from the specified INI file.
+ Returns true on success, false and logs errors to console on failure. */
+ bool Initialize(cIniFile & a_IniFile);
+
+protected:
+
+ // cFinishGenOreClumps overrides:
+ virtual void GenerateOre(
+ cChunkDesc & a_ChunkDesc,
+ BLOCKTYPE a_OreType, NIBBLETYPE a_OreMeta,
+ int a_MaxNestHeight, int a_NumNests, int a_NestSize,
+ int a_Seq
+ ) override;
+
+ /** Calculates the pockets for the specified chunk and imprints them into the specified ChunkDesc (not necessarily the same chunk).
+ a_Seq is the sequence number of the ore, to provide another source of randomness. */
+ void imprintChunkOrePockets(
+ int a_ChunkX, int a_ChunkZ,
+ cChunkDesc & a_ChunkDesc,
+ BLOCKTYPE a_OreType, NIBBLETYPE a_OreMeta,
+ int a_MaxHeight, int a_NumNests, int a_NestSize,
+ int a_Seq
+ );
+
+ /** Imprints a single pocket of the specified ore at the specified coords into the chunk.
+ The pocket shape has its minimum X and Z coords specified, Y can be anywhere around the specified Y coord.
+ a_Seq is the sequence number of the ore, to provide another source of randomness. */
+ void imprintPocket(
+ cChunkDesc & a_ChunkDesc,
+ int a_MinPocketX, int a_PocketY, int a_MinPocketZ,
+ int a_NestSize, int a_Seq,
+ BLOCKTYPE a_OreType, NIBBLETYPE a_OreMeta
+ );
+
+ /** Imprints a single sphere of the specified ore at the specified coords. */
+ void imprintSphere(
+ cChunkDesc & a_ChunkDesc,
+ double a_SphereX, double a_SphereY, double a_SphereZ, double a_Radius,
+ BLOCKTYPE a_OreType, NIBBLETYPE a_OreMeta
+ );
+};
+
+
+
+