summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/BiomeDef.cpp14
-rw-r--r--src/BiomeDef.h9
-rw-r--r--src/Generating/BioGen.cpp10
-rw-r--r--src/Generating/ChunkDesc.cpp4
-rw-r--r--src/Generating/ChunkDesc.h2
-rw-r--r--src/Mobs/SnowGolem.cpp2
-rw-r--r--src/Simulator/FluidSimulator.cpp2
-rw-r--r--src/World.cpp4
-rw-r--r--src/World.h2
9 files changed, 31 insertions, 18 deletions
diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp
index 89a1cdefb..3fba93e8a 100644
--- a/src/BiomeDef.cpp
+++ b/src/BiomeDef.cpp
@@ -13,8 +13,16 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
int res = atoi(a_BiomeString.c_str());
if ((res != 0) || (a_BiomeString.compare("0") == 0))
{
- // It was a valid number
- return (EMCSBiome)res;
+ if ((res >= biFirstBiome) && (res < biNumBiomes))
+ {
+ return (EMCSBiome)res;
+ }
+ else if ((res >= biFirstVariantBiome) && (res < biNumVariantBiomes))
+ {
+ return (EMCSBiome)res;
+ }
+ // It was an invalid number
+ return biInvalidBiome;
}
// Convert using the built-in map:
@@ -100,7 +108,7 @@ EMCSBiome StringToBiome(const AString & a_BiomeString)
return BiomeMap[i].m_Biome;
}
} // for i - BiomeMap[]
- return (EMCSBiome)-1;
+ return biInvalidBiome;
}
diff --git a/src/BiomeDef.h b/src/BiomeDef.h
index df1e387f0..474d4df76 100644
--- a/src/BiomeDef.h
+++ b/src/BiomeDef.h
@@ -20,6 +20,9 @@ BiomeIDs over 255 are used by MCServer internally and are translated to MC biome
*/
enum EMCSBiome
{
+ biInvalidBiome = -1,
+
+ biFirstBiome = 0,
biOcean = 0,
biPlains = 1,
biDesert = 2,
@@ -74,6 +77,7 @@ enum EMCSBiome
biVariant = 128,
// Release 1.7 biome variants:
+ biFirstVariantBiome = 129,
biSunflowerPlains = 129,
biDesertM = 130,
biExtremeHillsM = 131,
@@ -95,9 +99,12 @@ enum EMCSBiome
biMesaBryce = 165,
biMesaPlateauFM = 166,
biMesaPlateauM = 167,
+ // Automatically capture the maximum consecutive biome value into biVarientMaxBiome:
+ biNumVariantBiomes, // True number of biomes, since they are zero-based
+ biMaxVariantBiome = biNumVariantBiomes - 1, // The maximum biome value
} ;
-/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure.
+/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns biInvalidBiome on failure.
extern EMCSBiome StringToBiome(const AString & a_BiomeString);
/// Returns true if the biome has no downfall - deserts and savannas
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index f89b1800d..967deba6a 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 == 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 != 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 : (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) != 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) != biInvalidBiome)
{
// Already set before
continue;
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 87566aa78..d9529b4b0 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -118,9 +118,9 @@ void cChunkDesc::SetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_B
-void cChunkDesc::SetBiome(int a_RelX, int a_RelZ, int a_BiomeID)
+void cChunkDesc::SetBiome(int a_RelX, int a_RelZ, EMCSBiome a_BiomeID)
{
- cChunkDef::SetBiome(m_BiomeMap, a_RelX, a_RelZ, (EMCSBiome)a_BiomeID);
+ cChunkDef::SetBiome(m_BiomeMap, a_RelX, a_RelZ, a_BiomeID);
}
diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h
index e258383d5..8edc2800b 100644
--- a/src/Generating/ChunkDesc.h
+++ b/src/Generating/ChunkDesc.h
@@ -53,7 +53,7 @@ public:
void SetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockMeta);
NIBBLETYPE GetBlockMeta(int a_RelX, int a_RelY, int a_RelZ);
- void SetBiome(int a_RelX, int a_RelZ, int a_BiomeID);
+ void SetBiome(int a_RelX, int a_RelZ, EMCSBiome a_BiomeID);
EMCSBiome GetBiome(int a_RelX, int a_RelZ);
// These operate on the heightmap, so they could get out of sync with the data
diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp
index 06021cca5..c60103055 100644
--- a/src/Mobs/SnowGolem.cpp
+++ b/src/Mobs/SnowGolem.cpp
@@ -29,7 +29,7 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (IsBiomeNoDownfall((EMCSBiome) m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())) ))
+ if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())) ))
{
TakeDamage(*this);
}
diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp
index 72b2eb628..61c93ed73 100644
--- a/src/Simulator/FluidSimulator.cpp
+++ b/src/Simulator/FluidSimulator.cpp
@@ -166,14 +166,12 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
{
LowestPoint = Meta;
X = Pos->x;
- Pos->y; //Remove if no side effects
Z = Pos->z;
}
}else if(BlockID == E_BLOCK_AIR)
{
LowestPoint = 9; //This always dominates
X = Pos->x;
- Pos->y; //Remove if no side effects
Z = Pos->z;
}
diff --git a/src/World.cpp b/src/World.cpp
index de2002b84..f9a6e7776 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1222,7 +1222,7 @@ void cWorld::GrowTreeByBiome(int a_X, int a_Y, int a_Z)
{
cNoise Noise(m_Generator.GetSeed());
sSetBlockVector Logs, Other;
- GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), (EMCSBiome)GetBiomeAt(a_X, a_Z), Logs, Other);
+ GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), GetBiomeAt(a_X, a_Z), Logs, Other);
Other.insert(Other.begin(), Logs.begin(), Logs.end());
Logs.clear();
GrowTreeImage(Other);
@@ -1475,7 +1475,7 @@ void cWorld::GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBl
-int cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ)
+EMCSBiome cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ)
{
return m_ChunkMap->GetBiomeAt(a_BlockX, a_BlockZ);
}
diff --git a/src/World.h b/src/World.h
index bf6a4ba28..afdc09788 100644
--- a/src/World.h
+++ b/src/World.h
@@ -526,7 +526,7 @@ public:
void GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow);
/** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */
- int GetBiomeAt(int a_BlockX, int a_BlockZ);
+ EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ);
/** Returns the name of the world */
const AString & GetName(void) const { return m_WorldName; }