From 80807eec2cc1c497c4766a0c7cddb9c3ddc29e45 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 3 Feb 2014 12:26:17 -0800 Subject: Increased Type safety of Biomes Changed a number of funcictions from using integers to store biomes to using EMCSBiome Note that switching from an int to an Enum is a non-breaking chang to the lua bindings --- src/Generating/BioGen.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Generating/BioGen.cpp') diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index f89b1800d..1a18f53f1 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -97,7 +97,7 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile) { AString Biome = a_IniFile.GetValueSet("Generator", "ConstantBiome", "Plains"); m_Biome = StringToBiome(Biome); - if (m_Biome == -1) + if (m_Biome == EMCSBiome::biInvalidBiome) { LOGWARN("[Generator]::ConstantBiome value \"%s\" not recognized, using \"Plains\".", Biome.c_str()); m_Biome = biPlains; @@ -233,7 +233,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) } } EMCSBiome Biome = StringToBiome(Split2[0]); - if (Biome != -1) + if (Biome != EMCSBiome::biInvalidBiome) { for (int i = 0; i < Count; i++) { @@ -500,7 +500,7 @@ void cBioGenMultiStepMap::DecideOceanLandMushroom(int a_ChunkX, int a_ChunkZ, cC int OffsetZ = (m_Noise4.IntNoise3DInt(RealCellX, 32 * RealCellX - 16 * RealCellZ, RealCellZ) / 8) % m_OceanCellSize; SeedX[xc][zc] = CellBlockX + OffsetX; SeedZ[xc][zc] = CellBlockZ + OffsetZ; - SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : ((EMCSBiome)(-1)); + SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : (EMCSBiome::biInvalidBiome); } // for z } // for x @@ -573,7 +573,7 @@ void cBioGenMultiStepMap::AddRivers(int a_ChunkX, int a_ChunkZ, cChunkDef::Biome float NoiseCoordZ = (float)(a_ChunkZ * cChunkDef::Width + z) / m_RiverCellSize; for (int x = 0; x < cChunkDef::Width; x++) { - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != -1) + if (cChunkDef::GetBiome(a_BiomeMap, x, z) != EMCSBiome::biInvalidBiome) { // Biome already set, skip this column continue; @@ -693,7 +693,7 @@ void cBioGenMultiStepMap::DecideLandBiomes(cChunkDef::BiomeMap & a_BiomeMap, con int idxZ = 17 * z; for (int x = 0; x < cChunkDef::Width; x++) { - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != -1) + if (cChunkDef::GetBiome(a_BiomeMap, x, z) != EMCSBiome::biInvalidBiome) { // Already set before continue; -- cgit v1.2.3 From d9fb83300cf831ea31a74d509f9be9f2ed4f1189 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 3 Feb 2014 13:01:12 -0800 Subject: Fixed Compile errors c++11 introduces scoped enums, so the code didn't fail in clang --- src/Generating/BioGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Generating/BioGen.cpp') diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 1a18f53f1..20f269fc8 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -97,7 +97,7 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile) { AString Biome = a_IniFile.GetValueSet("Generator", "ConstantBiome", "Plains"); m_Biome = StringToBiome(Biome); - if (m_Biome == EMCSBiome::biInvalidBiome) + if (m_Biome == biInvalidBiome) { LOGWARN("[Generator]::ConstantBiome value \"%s\" not recognized, using \"Plains\".", Biome.c_str()); m_Biome = biPlains; -- cgit v1.2.3 From 4b1924730502c26519202c9fa8ea9e77976475e5 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 3 Feb 2014 13:07:38 -0800 Subject: Fogot to save Biogen --- src/Generating/BioGen.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Generating/BioGen.cpp') diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 20f269fc8..967deba6a 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -233,7 +233,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) } } EMCSBiome Biome = StringToBiome(Split2[0]); - if (Biome != EMCSBiome::biInvalidBiome) + if (Biome != biInvalidBiome) { for (int i = 0; i < Count; i++) { @@ -500,7 +500,7 @@ void cBioGenMultiStepMap::DecideOceanLandMushroom(int a_ChunkX, int a_ChunkZ, cC int OffsetZ = (m_Noise4.IntNoise3DInt(RealCellX, 32 * RealCellX - 16 * RealCellZ, RealCellZ) / 8) % m_OceanCellSize; SeedX[xc][zc] = CellBlockX + OffsetX; SeedZ[xc][zc] = CellBlockZ + OffsetZ; - SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : (EMCSBiome::biInvalidBiome); + SeedV[xc][zc] = (((m_Noise6.IntNoise3DInt(RealCellX, RealCellX - RealCellZ + 1000, RealCellZ) / 11) % 256) > 90) ? biOcean : (biInvalidBiome); } // for z } // for x @@ -573,7 +573,7 @@ void cBioGenMultiStepMap::AddRivers(int a_ChunkX, int a_ChunkZ, cChunkDef::Biome float NoiseCoordZ = (float)(a_ChunkZ * cChunkDef::Width + z) / m_RiverCellSize; for (int x = 0; x < cChunkDef::Width; x++) { - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != EMCSBiome::biInvalidBiome) + if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biInvalidBiome) { // Biome already set, skip this column continue; @@ -693,7 +693,7 @@ void cBioGenMultiStepMap::DecideLandBiomes(cChunkDef::BiomeMap & a_BiomeMap, con int idxZ = 17 * z; for (int x = 0; x < cChunkDef::Width; x++) { - if (cChunkDef::GetBiome(a_BiomeMap, x, z) != EMCSBiome::biInvalidBiome) + if (cChunkDef::GetBiome(a_BiomeMap, x, z) != biInvalidBiome) { // Already set before continue; -- cgit v1.2.3