summaryrefslogtreecommitdiffstats
path: root/source/Generating/ComposableGenerator.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-27 21:46:25 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-27 21:46:25 +0200
commitac8db4d16b7c097d31a7952428a499c5cd6ef849 (patch)
treefd88aa0355091567e7cc22caa25c232bc2d524d0 /source/Generating/ComposableGenerator.cpp
parentFixed a few possible crashes upon server stop (diff)
downloadcuberite-ac8db4d16b7c097d31a7952428a499c5cd6ef849.tar
cuberite-ac8db4d16b7c097d31a7952428a499c5cd6ef849.tar.gz
cuberite-ac8db4d16b7c097d31a7952428a499c5cd6ef849.tar.bz2
cuberite-ac8db4d16b7c097d31a7952428a499c5cd6ef849.tar.lz
cuberite-ac8db4d16b7c097d31a7952428a499c5cd6ef849.tar.xz
cuberite-ac8db4d16b7c097d31a7952428a499c5cd6ef849.tar.zst
cuberite-ac8db4d16b7c097d31a7952428a499c5cd6ef849.zip
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)