summaryrefslogtreecommitdiffstats
path: root/source/Generating/ComposableGenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Generating/ComposableGenerator.cpp')
-rw-r--r--source/Generating/ComposableGenerator.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/source/Generating/ComposableGenerator.cpp b/source/Generating/ComposableGenerator.cpp
index 1612d038b..178ed4537 100644
--- a/source/Generating/ComposableGenerator.cpp
+++ b/source/Generating/ComposableGenerator.cpp
@@ -19,6 +19,7 @@
#include "Caves.h"
#include "MineShafts.h"
+#include "Noise3DGenerator.h"
#include "Ravines.h"
@@ -34,7 +35,9 @@ cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) :
super(a_ChunkGenerator),
m_BiomeGen(NULL),
m_HeightGen(NULL),
- m_CompositionGen(NULL)
+ m_CompositionGen(NULL),
+ m_Noise3DComposable(NULL),
+ m_NumNoise3DComposableUses(0)
{
}
@@ -55,7 +58,13 @@ cComposableGenerator::~cComposableGenerator()
delete *itr;
}
m_StructureGens.clear();
- delete m_CompositionGen;
+
+ // CompositionGen must not be freed if it is shared between HeightGenCache and CompositionGen:
+ if ((m_NumNoise3DComposableUses < 2) || (m_CompositionGen != m_Noise3DComposable))
+ {
+ delete m_CompositionGen;
+ }
+
m_CompositionGen = NULL;
delete m_HeightGen;
m_HeightGen = NULL;
@@ -232,6 +241,16 @@ void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
float HeightAmp3 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp3", 0.5);
m_HeightGen = new cHeiGenClassic(Seed, HeightFreq1, HeightAmp1, HeightFreq2, HeightAmp2, HeightFreq3, HeightAmp3);
}
+ else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
+ {
+ if (m_Noise3DComposable == NULL)
+ {
+ m_Noise3DComposable = new cNoise3DComposable(Seed);
+ m_Noise3DComposable->Initialize(a_IniFile);
+ }
+ m_HeightGen = m_Noise3DComposable;
+ m_NumNoise3DComposableUses++;
+ }
else // "biomal" or <not found>
{
if (NoCaseCompare(HeightGenName, "biomal") != 0)
@@ -312,6 +331,16 @@ void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile)
{
m_CompositionGen = new cCompoGenNether(m_ChunkGenerator.GetSeed());
}
+ else if (NoCaseCompare(CompoGenName, "Noise3D") == 0)
+ {
+ if (m_Noise3DComposable == NULL)
+ {
+ m_Noise3DComposable = new cNoise3DComposable(m_ChunkGenerator.GetSeed());
+ m_Noise3DComposable->Initialize(a_IniFile);
+ }
+ m_CompositionGen = m_Noise3DComposable;
+ m_NumNoise3DComposableUses++;
+ }
else
{
if (NoCaseCompare(CompoGenName, "biomal") != 0)