summaryrefslogtreecommitdiffstats
path: root/src/Generating/HeiGen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Generating/HeiGen.cpp')
-rw-r--r--src/Generating/HeiGen.cpp47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index 1d9f1e3aa..86f934c16 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -15,7 +15,6 @@
-
////////////////////////////////////////////////////////////////////////////////
// cHeiGenFlat:
@@ -133,15 +132,6 @@ void cHeiGenCache::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap
-void cHeiGenCache::InitializeHeightGen(cIniFile & a_IniFile)
-{
- m_HeiGenToCache->InitializeHeightGen(a_IniFile);
-}
-
-
-
-
-
bool cHeiGenCache::GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, HEIGHTTYPE & a_Height)
{
for (int i = 0; i < m_CacheSize; i++)
@@ -750,43 +740,51 @@ cTerrainHeightGenPtr cTerrainHeightGen::CreateHeightGen(cIniFile & a_IniFile, cB
}
a_CacheOffByDefault = false;
- cTerrainHeightGen * res = nullptr;
- if (NoCaseCompare(HeightGenName, "flat") == 0)
+ cTerrainHeightGenPtr res;
+ if (NoCaseCompare(HeightGenName, "Flat") == 0)
{
- res = new cHeiGenFlat;
+ res = std::make_shared<cHeiGenFlat>();
a_CacheOffByDefault = true; // We're generating faster than a cache would retrieve data
}
else if (NoCaseCompare(HeightGenName, "classic") == 0)
{
- res = new cHeiGenClassic(a_Seed);
+ res = std::make_shared<cHeiGenClassic>(a_Seed);
}
else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0)
{
- res = new cDistortedHeightmap(a_Seed, a_BiomeGen);
+ // Not a heightmap-based generator, but it used to be accessible via HeightGen, so we need to skip making the default out of it
+ // Return an empty pointer, the caller will create the proper generator:
+ return cTerrainHeightGenPtr();
}
else if (NoCaseCompare(HeightGenName, "End") == 0)
{
- res = new cEndGen(a_Seed);
+ // Not a heightmap-based generator, but it used to be accessible via HeightGen, so we need to skip making the default out of it
+ // Return an empty pointer, the caller will create the proper generator:
+ return cTerrainHeightGenPtr();
}
else if (NoCaseCompare(HeightGenName, "MinMax") == 0)
{
- res = new cHeiGenMinMax(a_Seed, a_BiomeGen);
+ res = std::make_shared<cHeiGenMinMax>(a_Seed, a_BiomeGen);
}
else if (NoCaseCompare(HeightGenName, "Mountains") == 0)
{
- res = new cHeiGenMountains(a_Seed);
+ res = std::make_shared<cHeiGenMountains>(a_Seed);
}
else if (NoCaseCompare(HeightGenName, "BiomalNoise3D") == 0)
{
- res = new cBiomalNoise3DComposable(a_Seed, a_BiomeGen);
+ // Not a heightmap-based generator, but it used to be accessible via HeightGen, so we need to skip making the default out of it
+ // Return an empty pointer, the caller will create the proper generator:
+ return cTerrainHeightGenPtr();
}
else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
{
- res = new cNoise3DComposable(a_Seed);
+ // Not a heightmap-based generator, but it used to be accessible via HeightGen, so we need to skip making the default out of it
+ // Return an empty pointer, the caller will create the proper generator:
+ return cTerrainHeightGenPtr();
}
- else if (NoCaseCompare(HeightGenName, "biomal") == 0)
+ else if (NoCaseCompare(HeightGenName, "Biomal") == 0)
{
- res = new cHeiGenBiomal(a_Seed, a_BiomeGen);
+ res = std::make_shared<cHeiGenBiomal>(a_Seed, a_BiomeGen);
/*
// Performance-testing:
@@ -805,15 +803,14 @@ cTerrainHeightGenPtr cTerrainHeightGen::CreateHeightGen(cIniFile & a_IniFile, cB
{
// No match found, force-set the default and retry
LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str());
- a_IniFile.DeleteValue("Generator", "HeightGen");
a_IniFile.SetValue("Generator", "HeightGen", "Biomal");
return CreateHeightGen(a_IniFile, a_BiomeGen, a_Seed, a_CacheOffByDefault);
}
// Read the settings:
res->InitializeHeightGen(a_IniFile);
-
- return cTerrainHeightGenPtr(res);
+
+ return res;
}