8 #include "../IniFile.h"
37 m_HeightGen->GenHeightMap(a_ChunkCoords, heightMap);
45 Byte * shapeColumn = &(a_Shape[(x + 16 * z) * 256]);
46 for (
int y = 0; y < height; y++)
82 bool & a_CacheOffByDefault
86 if (shapeGenName.empty())
88 LOGWARN(
"[Generator] ShapeGen value not set in world.ini, using \"BiomalNoise3D\".");
89 shapeGenName =
"BiomalNoise3D";
96 if (heightGen !=
nullptr)
98 return std::make_unique<cTerrainHeightToShapeGen>(std::move(heightGen));
102 shapeGenName = a_IniFile.
GetValue(
"Generator",
"HeightGen",
"");
103 if (shapeGenName.empty())
105 LOGWARNING(
"[Generator] ShapeGen set to HeightMap, but HeightGen not set. Reverting to \"BiomalNoise3D\".");
106 shapeGenName =
"BiomalNoise3D";
107 a_IniFile.
SetValue(
"Generator",
"ShapeGen", shapeGenName);
112 a_CacheOffByDefault =
false;
113 std::unique_ptr<cTerrainShapeGen> res;
116 res = std::make_unique<cDistortedHeightmap>(a_Seed, a_BiomeGen);
120 res = std::make_unique<cEndGen>(a_Seed);
124 res = std::make_unique<cBiomalNoise3DComposable>(a_Seed, a_BiomeGen);
128 res = std::make_unique<cNoise3DComposable>(a_Seed);
137 LOGWARN(
"Unknown ShapeGen \"%s\", using \"BiomalNoise3D\" instead.", shapeGenName.c_str());
138 a_IniFile.
SetValue(
"Generator",
"ShapeGen",
"BiomalNoise3D");
139 return CreateShapeGen(a_IniFile, a_BiomeGen, a_Seed, a_CacheOffByDefault);
143 res->InitializeShapeGen(a_IniFile);
std::shared_ptr< cTerrainHeightToShapeGen > cTerrainHeightToShapeGenPtr
std::unique_ptr< cTerrainShapeGen > CreateShapeGenTwoHeights(int a_Seed, cBiomeGen &a_BiomeGen)
Creates and returns a new instance of the cTwoHeights terrain shape generator.
void LOGWARNING(std::string_view a_Format, const Args &... args)
int NoCaseCompare(const AString &s1, const AString &s2)
Case-insensitive string comparison.
Wraps the chunk coords into a single structure.
HEIGHTTYPE HeightMap[Width *Width]
The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the hig...
static HEIGHTTYPE GetHeight(const HeightMap &a_HeightMap, int a_X, int a_Z)
Byte Shape[256 *16 *16]
The datatype used to represent the entire chunk worth of shape.
The interface that a biome generator must implement A biome generator takes chunk coords on input and...
The interface that a terrain shape generator must implement A terrain shape generator takes chunk coo...
static std::unique_ptr< cTerrainShapeGen > CreateShapeGen(cIniFile &a_IniFile, cBiomeGen &a_BiomeGen, int a_Seed, bool &a_CacheOffByDefault)
Creates the correct TerrainShapeGen descendant based on the ini file settings and the seed provided.
static std::unique_ptr< cTerrainHeightGen > CreateHeightGen(cIniFile &a_IniFile, cBiomeGen &a_BiomeGen, int a_Seed, bool &a_CacheOffByDefault)
Creates a cTerrainHeightGen descendant based on the INI file settings.
Converts old-style height-generators into new-style shape-generators.
cTerrainHeightToShapeGen(std::unique_ptr< cTerrainHeightGen > a_HeightGen)
virtual void GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape &a_Shape) override
Generates the shape for the given chunk.
virtual void InitializeShapeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
std::unique_ptr< cTerrainHeightGen > m_HeightGen
The height generator being converted.
AString GetValue(const AString &keyname, const AString &valuename, const AString &defValue="") const override
Get the value at the specified key and value, returns defValue on failure.
bool SetValue(const int keyID, const int valueID, const AString &value)