summaryrefslogtreecommitdiffstats
path: root/src/Generating
diff options
context:
space:
mode:
Diffstat (limited to 'src/Generating')
-rw-r--r--src/Generating/BioGen.cpp28
-rw-r--r--src/Generating/BioGen.h8
-rw-r--r--src/Generating/CMakeLists.txt26
-rw-r--r--src/Generating/ChunkDesc.cpp12
-rw-r--r--src/Generating/ChunkDesc.h8
-rw-r--r--src/Generating/CompoGenBiomal.cpp22
-rw-r--r--src/Generating/ComposableGenerator.cpp4
-rw-r--r--src/Generating/DungeonRoomsFinisher.cpp4
-rw-r--r--src/Generating/FinishGen.cpp36
-rw-r--r--src/Generating/GridStructGen.cpp4
-rw-r--r--src/Generating/HeiGen.cpp31
-rw-r--r--src/Generating/HeiGen.h2
-rw-r--r--src/Generating/MineShafts.cpp28
-rw-r--r--src/Generating/NetherFortGen.cpp4
-rw-r--r--src/Generating/Noise3DGenerator.cpp7
-rw-r--r--src/Generating/POCPieceGenerator.cpp4
-rw-r--r--src/Generating/PieceGenerator.cpp16
-rw-r--r--src/Generating/Prefab.cpp10
-rw-r--r--src/Generating/PrefabPiecePool.cpp6
-rw-r--r--src/Generating/ProtIntGen.h288
-rw-r--r--src/Generating/RainbowRoadsGen.cpp2
-rw-r--r--src/Generating/Ravines.cpp16
-rw-r--r--src/Generating/RoughRavines.cpp16
-rw-r--r--src/Generating/StructGen.cpp28
-rw-r--r--src/Generating/TestRailsGen.cpp2
-rw-r--r--src/Generating/Trees.cpp44
-rw-r--r--src/Generating/UnderwaterBaseGen.cpp2
-rw-r--r--src/Generating/VillageGen.cpp12
28 files changed, 355 insertions, 315 deletions
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index 867155ad2..eb9129c60 100644
--- a/src/Generating/BioGen.cpp
+++ b/src/Generating/BioGen.cpp
@@ -49,16 +49,16 @@ void cBioGenConstant::InitializeBiomeGen(cIniFile & a_IniFile)
////////////////////////////////////////////////////////////////////////////////
// cBioGenCache:
-cBioGenCache::cBioGenCache(cBiomeGenPtr a_BioGenToCache, int a_CacheSize) :
+cBioGenCache::cBioGenCache(cBiomeGenPtr a_BioGenToCache, size_t a_CacheSize) :
m_BioGenToCache(a_BioGenToCache),
m_CacheSize(a_CacheSize),
- m_CacheOrder(new int[a_CacheSize]),
+ m_CacheOrder(new size_t[a_CacheSize]),
m_CacheData(new sCacheData[a_CacheSize]),
m_NumHits(0),
m_NumMisses(0),
m_TotalChain(0)
{
- for (int i = 0; i < m_CacheSize; i++)
+ for (size_t i = 0; i < m_CacheSize; i++)
{
m_CacheOrder[i] = i;
m_CacheData[i].m_ChunkX = 0x7fffffff;
@@ -90,7 +90,7 @@ void cBioGenCache::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a
LOGD("BioGenCache: Avg cache chain length: %.2f", (float)m_TotalChain / m_NumHits);
}
- for (int i = 0; i < m_CacheSize; i++)
+ for (size_t i = 0; i < m_CacheSize; i++)
{
if (
(m_CacheData[m_CacheOrder[i]].m_ChunkX != a_ChunkX) ||
@@ -100,10 +100,10 @@ void cBioGenCache::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a
continue;
}
// Found it in the cache
- int Idx = m_CacheOrder[i];
+ size_t Idx = m_CacheOrder[i];
// Move to front:
- for (int j = i; j > 0; j--)
+ for (size_t j = i; j > 0; j--)
{
m_CacheOrder[j] = m_CacheOrder[j - 1];
}
@@ -122,8 +122,8 @@ void cBioGenCache::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a
m_BioGenToCache->GenBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap);
// Insert it as the first item in the MRU order:
- int Idx = m_CacheOrder[m_CacheSize - 1];
- for (int i = m_CacheSize - 1; i > 0; i--)
+ size_t Idx = m_CacheOrder[m_CacheSize - 1];
+ for (size_t i = m_CacheSize - 1; i > 0; i--)
{
m_CacheOrder[i] = m_CacheOrder[i - 1];
} // for i - m_CacheOrder[]
@@ -278,7 +278,7 @@ void cBioGenCheckerboard::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::Biome
for (int x = 0; x < cChunkDef::Width; x++)
{
int Add = cChunkDef::Width * a_ChunkX + x;
- int BiomeIdx = (((Base + Add / m_BiomeSize) % m_BiomesCount) + m_BiomesCount) % m_BiomesCount; // Need to add and modulo twice because of negative numbers
+ size_t BiomeIdx = static_cast<size_t>((((Base + Add / m_BiomeSize) % m_BiomesCount) + m_BiomesCount) % m_BiomesCount); // Need to add and modulo twice because of negative numbers
a_BiomeMap[x + cChunkDef::Width * z] = m_Biomes[BiomeIdx];
}
}
@@ -314,7 +314,7 @@ void cBioGenVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap &
for (int x = 0; x < cChunkDef::Width; x++)
{
int VoronoiCellValue = m_Voronoi.GetValueAt(BaseX + x, AbsoluteZ) / 8;
- cChunkDef::SetBiome(a_BiomeMap, x, z, m_Biomes[VoronoiCellValue % m_BiomesCount]);
+ cChunkDef::SetBiome(a_BiomeMap, x, z, m_Biomes[static_cast<size_t>(VoronoiCellValue % m_BiomesCount)]);
} // for x
} // for z
}
@@ -363,7 +363,7 @@ void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::B
for (int x = 0; x < cChunkDef::Width; x++)
{
int VoronoiCellValue = m_Voronoi.GetValueAt(DistortX[x][z], DistortZ[x][z]) / 8;
- cChunkDef::SetBiome(a_BiomeMap, x, z, m_Biomes[VoronoiCellValue % m_BiomesCount]);
+ cChunkDef::SetBiome(a_BiomeMap, x, z, m_Biomes[static_cast<size_t>(VoronoiCellValue % m_BiomesCount)]);
} // for x
} // for z
}
@@ -785,7 +785,7 @@ void cBioGenTwoLevel::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap
{
int SeedX, SeedZ, MinDist2;
int BiomeGroup = m_VoronoiLarge.GetValueAt(DistortX[x][z], DistortZ[x][z], SeedX, SeedZ, MinDist2) / 7;
- int BiomeIdx = m_VoronoiSmall.GetValueAt(DistortX[x][z], DistortZ[x][z], SeedX, SeedZ, MinDist2) / 11;
+ size_t BiomeIdx = static_cast<size_t>(m_VoronoiSmall.GetValueAt(DistortX[x][z], DistortZ[x][z], SeedX, SeedZ, MinDist2) / 11);
int MinDist1 = (DistortX[x][z] - SeedX) * (DistortX[x][z] - SeedX) + (DistortZ[x][z] - SeedZ) * (DistortZ[x][z] - SeedZ);
cChunkDef::SetBiome(a_BiomeMap, x, z, SelectBiome(BiomeGroup, BiomeIdx, (MinDist1 < MinDist2 / 4) ? 1 : 0));
}
@@ -796,7 +796,7 @@ void cBioGenTwoLevel::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap
-EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, int a_BiomeIdx, int a_DistLevel)
+EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int a_DistLevel)
{
// TODO: Move this into settings
struct BiomeLevels
@@ -900,7 +900,7 @@ EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, int a_BiomeIdx, int a_D
{ bgMesa, ARRAYCOUNT(bgMesa), },
{ bgDenseTrees, ARRAYCOUNT(bgDenseTrees), },
} ;
- size_t Group = a_BiomeGroup % ARRAYCOUNT(BiomeGroups);
+ size_t Group = static_cast<size_t>(a_BiomeGroup) % ARRAYCOUNT(BiomeGroups);
size_t Index = a_BiomeIdx % BiomeGroups[Group].Count;
return (a_DistLevel > 0) ? BiomeGroups[Group].Biomes[Index].InnerBiome : BiomeGroups[Group].Biomes[Index].OuterBiome;
}
diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h
index 13fb40c5f..2580bf53a 100644
--- a/src/Generating/BioGen.h
+++ b/src/Generating/BioGen.h
@@ -48,7 +48,7 @@ class cBioGenCache :
typedef cBiomeGen super;
public:
- cBioGenCache(cBiomeGenPtr a_BioGenToCache, int a_CacheSize);
+ cBioGenCache(cBiomeGenPtr a_BioGenToCache, size_t a_CacheSize);
virtual ~cBioGenCache();
protected:
@@ -63,8 +63,8 @@ protected:
} ;
// To avoid moving large amounts of data for the MRU behavior, we MRU-ize indices to an array of the actual data
- int m_CacheSize;
- int * m_CacheOrder; // MRU-ized order, indices into m_CacheData array
+ size_t m_CacheSize;
+ size_t * m_CacheOrder; // MRU-ized order, indices into m_CacheData array
sCacheData * m_CacheData; // m_CacheData[m_CacheOrder[0]] is the most recently used
// Cache statistics
@@ -311,7 +311,7 @@ protected:
/// Selects biome from the specified biome group, based on the specified index.
/// Note that both params may overflow
/// a_DistLevel is either 0 or 1; zero when it is at the edge of the small Voronoi cell, 1 near the center
- EMCSBiome SelectBiome(int a_BiomeGroup, int a_BiomeIdx, int a_DistLevel);
+ EMCSBiome SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int a_DistLevel);
} ;
diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt
index a28510d40..ebba4cce8 100644
--- a/src/Generating/CMakeLists.txt
+++ b/src/Generating/CMakeLists.txt
@@ -72,6 +72,32 @@ SET (HDRS
VillageGen.h
)
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set_source_files_properties(BioGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast")
+ set_source_files_properties(Caves.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(ChunkGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(CompoGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(CompoGenBiomal.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=old-style-cast")
+ set_source_files_properties(ComposableGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast")
+ set_source_files_properties(DistortedHeightmap.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(EndGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(FinishGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch")
+ set_source_files_properties(HeiGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(NetherFortGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
+ set_source_files_properties(Noise3DGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(PieceGenerator.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
+ set_source_files_properties(Prefab.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
+ set_source_files_properties(RainbowRoadsGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
+ set_source_files_properties(Ravines.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(RoughRavines.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=float-equal -Wno-error=old-style-cast")
+ set_source_files_properties(StructGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch -Wno-error=old-style-cast")
+ set_source_files_properties(ShapeGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(TestRailsGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
+ set_source_files_properties(TwoHeights.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(UnderwaterBaseGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=switch-enum")
+ set_source_files_properties(VillageGen.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors -Wno-error=switch-enum")
+endif()
+
if(NOT MSVC)
add_library(Generating ${SRCS} ${HDRS})
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 4a5ac5a18..07855b1d0 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -134,7 +134,7 @@ EMCSBiome cChunkDesc::GetBiome(int a_RelX, int a_RelZ)
-void cChunkDesc::SetHeight(int a_RelX, int a_RelZ, int a_Height)
+void cChunkDesc::SetHeight(int a_RelX, int a_RelZ, HEIGHTTYPE a_Height)
{
cChunkDef::SetHeight(m_HeightMap, a_RelX, a_RelZ, a_Height);
}
@@ -143,7 +143,7 @@ void cChunkDesc::SetHeight(int a_RelX, int a_RelZ, int a_Height)
-int cChunkDesc::GetHeight(int a_RelX, int a_RelZ)
+HEIGHTTYPE cChunkDesc::GetHeight(int a_RelX, int a_RelZ)
{
return cChunkDef::GetHeight(m_HeightMap, a_RelX, a_RelZ);
}
@@ -158,7 +158,7 @@ void cChunkDesc::SetHeightFromShape(const Shape & a_Shape)
{
for (int x = 0; x < cChunkDef::Width; x++)
{
- for (int y = cChunkDef::Height - 1; y > 0; y--)
+ for (HEIGHTTYPE y = cChunkDef::Height - 1; y > 0; y--)
{
if (a_Shape[y + x * 256 + z * 16 * 256] != 0)
{
@@ -612,8 +612,8 @@ void cChunkDesc::UpdateHeightmap(void)
{
for (int z = 0; z < cChunkDef::Width; z++)
{
- int Height = 0;
- for (int y = cChunkDef::Height - 1; y > 0; y--)
+ HEIGHTTYPE Height = 0;
+ for (HEIGHTTYPE y = cChunkDef::Height - 1; y > 0; y--)
{
BLOCKTYPE BlockType = GetBlockType(x, y, z);
if (BlockType != E_BLOCK_AIR)
@@ -636,7 +636,7 @@ void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas();
for (size_t i = 0; i < ARRAYCOUNT(a_DestMetas); i++)
{
- a_DestMetas[i] = AreaMetas[2 * i] | (AreaMetas[2 * i + 1] << 4);
+ a_DestMetas[i] = static_cast<NIBBLETYPE>(AreaMetas[2 * i] | (AreaMetas[2 * i + 1] << 4));
}
}
diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h
index 480106fb5..1033242f8 100644
--- a/src/Generating/ChunkDesc.h
+++ b/src/Generating/ChunkDesc.h
@@ -65,8 +65,8 @@ public:
// These operate on the heightmap, so they could get out of sync with the data
// Use UpdateHeightmap() to re-calculate heightmap from the block data
- void SetHeight(int a_RelX, int a_RelZ, int a_Height);
- int GetHeight(int a_RelX, int a_RelZ);
+ void SetHeight(int a_RelX, int a_RelZ, HEIGHTTYPE a_Height);
+ HEIGHTTYPE GetHeight(int a_RelX, int a_RelZ);
// tolua_end
@@ -204,10 +204,10 @@ public:
// Accessors used by cChunkGenerator::Generator descendants:
inline cChunkDef::BiomeMap & GetBiomeMap (void) { return m_BiomeMap; }
- inline cChunkDef::BlockTypes & GetBlockTypes (void) { return *((cChunkDef::BlockTypes *)m_BlockArea.GetBlockTypes()); }
+ inline cChunkDef::BlockTypes & GetBlockTypes (void) { return *(reinterpret_cast<cChunkDef::BlockTypes *>(m_BlockArea.GetBlockTypes())); }
// CANNOT, different compression!
// inline cChunkDef::BlockNibbles & GetBlockMetas (void) { return *((cChunkDef::BlockNibbles *)m_BlockArea.GetBlockMetas()); }
- inline BlockNibbleBytes & GetBlockMetasUncompressed(void) { return *((BlockNibbleBytes *)m_BlockArea.GetBlockMetas()); }
+ inline BlockNibbleBytes & GetBlockMetasUncompressed(void) { return *(reinterpret_cast<BlockNibbleBytes *>(m_BlockArea.GetBlockMetas())); }
inline cChunkDef::HeightMap & GetHeightMap (void) { return m_HeightMap; }
inline cEntityList & GetEntities (void) { return m_Entities; }
inline cBlockEntityList & GetBlockEntities (void) { return m_BlockEntities; }
diff --git a/src/Generating/CompoGenBiomal.cpp b/src/Generating/CompoGenBiomal.cpp
index 3140bd754..60f7e7520 100644
--- a/src/Generating/CompoGenBiomal.cpp
+++ b/src/Generating/CompoGenBiomal.cpp
@@ -4,6 +4,9 @@
// Implements the cCompoGenBiomal class representing the biome-aware composition generator
#include "Globals.h"
+
+#include "CompoGenBiomal.h"
+
#include "ComposableGenerator.h"
#include "../IniFile.h"
#include "../Noise/Noise.h"
@@ -192,7 +195,7 @@ public:
protected:
/** The block height at which water is generated instead of air. */
- int m_SeaLevel;
+ HEIGHTTYPE m_SeaLevel;
/** The pattern used for mesa biomes. Initialized by seed on generator creation. */
cPattern::BlockInfo m_MesaPattern[2 * cChunkDef::Height];
@@ -221,7 +224,7 @@ protected:
virtual void InitializeCompoGen(cIniFile & a_IniFile) override
{
- m_SeaLevel = a_IniFile.GetValueSetI("Generator", "SeaLevel", m_SeaLevel);
+ m_SeaLevel = static_cast<HEIGHTTYPE>(a_IniFile.GetValueSetI("Generator", "SeaLevel", m_SeaLevel));
}
@@ -231,7 +234,7 @@ protected:
{
// In a loop, choose whether to use one, two or three layers of stained clay, then choose a color and width for each layer
// Separate each group with another layer of hardened clay
- cNoise patternNoise((unsigned)a_Seed);
+ cNoise patternNoise(a_Seed);
static NIBBLETYPE allowedColors[] =
{
E_META_STAINED_CLAY_YELLOW,
@@ -265,8 +268,8 @@ protected:
rnd /= 2;
for (int lay = 0; lay < numLayers; lay++)
{
- int numBlocks = layerSizes[(rnd % ARRAYCOUNT(layerSizes))];
- NIBBLETYPE Color = allowedColors[(rnd / 4) % ARRAYCOUNT(allowedColors)];
+ int numBlocks = layerSizes[(static_cast<size_t>(rnd) % ARRAYCOUNT(layerSizes))];
+ NIBBLETYPE Color = allowedColors[static_cast<size_t>(rnd / 4) % ARRAYCOUNT(allowedColors)];
if (
((numBlocks == 3) && (numLayers == 2)) || // In two-layer mode disallow the 3-high layers:
(Color == E_META_STAINED_CLAY_WHITE)) // White stained clay can ever be only 1 block high
@@ -411,7 +414,12 @@ protected:
FillColumnPattern(a_ChunkDesc, a_RelX, a_RelZ, Pattern, a_ShapeColumn);
return;
}
- default:
+ case biInvalidBiome:
+ case biHell:
+ case biSky:
+ case biNumBiomes:
+ case biVariant:
+ case biNumVariantBiomes:
{
ASSERT(!"Unhandled biome");
return;
@@ -427,7 +435,7 @@ protected:
{
bool HasHadWater = false;
int PatternIdx = 0;
- int top = std::max(m_SeaLevel, a_ChunkDesc.GetHeight(a_RelX, a_RelZ));
+ HEIGHTTYPE top = std::max(m_SeaLevel, a_ChunkDesc.GetHeight(a_RelX, a_RelZ));
for (int y = top; y > 0; y--)
{
if (a_ShapeColumn[y] > 0)
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index 6b7643ddb..f9a4d7609 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -221,11 +221,11 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile)
if (MultiCacheLength > 0)
{
LOGD("Enabling multicache for biomegen of length %d.", MultiCacheLength);
- m_BiomeGen = cBiomeGenPtr(new cBioGenMulticache(m_BiomeGen, CacheSize, MultiCacheLength));
+ m_BiomeGen = cBiomeGenPtr(new cBioGenMulticache(m_BiomeGen, static_cast<size_t>(CacheSize), static_cast<size_t>(MultiCacheLength)));
}
else
{
- m_BiomeGen = cBiomeGenPtr(new cBioGenCache(m_BiomeGen, CacheSize));
+ m_BiomeGen = cBiomeGenPtr(new cBioGenCache(m_BiomeGen, static_cast<size_t>(CacheSize)));
}
}
diff --git a/src/Generating/DungeonRoomsFinisher.cpp b/src/Generating/DungeonRoomsFinisher.cpp
index c4bf8839e..c62da7492 100644
--- a/src/Generating/DungeonRoomsFinisher.cpp
+++ b/src/Generating/DungeonRoomsFinisher.cpp
@@ -194,7 +194,7 @@ protected:
{
return;
}
- a_ChunkDesc.SetBlockTypeMeta(RelX, m_FloorHeight + 1, RelZ, E_BLOCK_CHEST, (NIBBLETYPE)a_Chest.y);
+ a_ChunkDesc.SetBlockTypeMeta(RelX, m_FloorHeight + 1, RelZ, E_BLOCK_CHEST, static_cast<NIBBLETYPE>(a_Chest.y));
// Fill the chest with random loot
static const cLootProbab LootProbab[] =
@@ -217,7 +217,7 @@ protected:
{ cItem(E_ITEM_NAME_TAG), 1, 1, 10 },
} ;
- cChestEntity * ChestEntity = (cChestEntity *)a_ChunkDesc.GetBlockEntity(RelX, m_FloorHeight + 1, RelZ);
+ cChestEntity * ChestEntity = static_cast<cChestEntity *>(a_ChunkDesc.GetBlockEntity(RelX, m_FloorHeight + 1, RelZ));
ASSERT((ChestEntity != nullptr) && (ChestEntity->GetBlockType() == E_BLOCK_CHEST));
cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ());
int NumSlots = 3 + ((Noise.IntNoise3DInt(a_Chest.x, a_Chest.y, a_Chest.z) / 11) % 4);
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index e96d959f9..59af0fd63 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -69,7 +69,7 @@ void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
}
// Choose what block to use.
- NOISE_DATATYPE BlockType = m_Noise.IntNoise3D((int) ChunkX, y, (int) ChunkZ);
+ NOISE_DATATYPE BlockType = m_Noise.IntNoise3D(static_cast<int>(ChunkX), y, static_cast<int>(ChunkZ));
if (BlockType < -0.7)
{
TryPlaceClump(a_ChunkDesc, PosX, y, PosZ, E_BLOCK_BROWN_MUSHROOM);
@@ -260,13 +260,13 @@ void cFinishGenGlowStone::TryPlaceGlowstone(cChunkDesc & a_ChunkDesc, int a_RelX
for (int j = 0; j < a_Size; j++)
{
- Vector3i Direction = AvailableDirections[m_Noise.IntNoise3DInt(CurrentPos.x, CurrentPos.y * i, CurrentPos.z) % ARRAYCOUNT(AvailableDirections)];
+ Vector3i Direction = AvailableDirections[static_cast<size_t>(m_Noise.IntNoise3DInt(CurrentPos.x, CurrentPos.y * i, CurrentPos.z)) % ARRAYCOUNT(AvailableDirections)];
int Attempts = 2; // multiply by 1 would make no difference, so multiply by 2 instead
while (Direction.Equals(PreviousDirection))
{
// To make the glowstone branches look better we want to make the direction change every time.
- Direction = AvailableDirections[m_Noise.IntNoise3DInt(CurrentPos.x, CurrentPos.y * i * Attempts, CurrentPos.z) % ARRAYCOUNT(AvailableDirections)];
+ Direction = AvailableDirections[static_cast<size_t>(m_Noise.IntNoise3DInt(CurrentPos.x, CurrentPos.y * i * Attempts, CurrentPos.z)) % ARRAYCOUNT(AvailableDirections)];
Attempts++;
}
@@ -438,7 +438,7 @@ void cFinishGenVines::GenFinish(cChunkDesc & a_ChunkDesc)
continue;
}
- NIBBLETYPE Meta = Places[m_Noise.IntNoise3DInt(xx, y, zz) % Places.size()];
+ NIBBLETYPE Meta = Places[static_cast<size_t>(m_Noise.IntNoise3DInt(xx, y, zz)) % Places.size()];
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_VINES, Meta);
}
}
@@ -507,7 +507,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
for (int z = 0; z < cChunkDef::Width; z++)
{
int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z;
- const float zz = (float)BlockZ;
+ const float zz = static_cast<float>(BlockZ);
for (int x = 0; x < cChunkDef::Width; x++)
{
int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width + x;
@@ -515,7 +515,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
{
continue;
}
- int Top = a_ChunkDesc.GetHeight(x, z);
+ HEIGHTTYPE Top = a_ChunkDesc.GetHeight(x, z);
if (Top > 250)
{
// Nothing grows above Y=250
@@ -528,7 +528,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
continue;
}
- const float xx = (float)BlockX;
+ const float xx = static_cast<float>(BlockX);
float val1 = m_Noise.CubicNoise2D(xx * 0.1f, zz * 0.1f);
float val2 = m_Noise.CubicNoise2D(xx * 0.01f, zz * 0.01f);
switch (a_ChunkDesc.GetBlockType(x, Top, z))
@@ -563,7 +563,7 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
}
else if ((val1 > 0.5) && (val2 < -0.5))
{
- a_ChunkDesc.SetBlockTypeMeta(x, ++Top, z, E_BLOCK_PUMPKIN, (int)(val3 * 8) % 4);
+ a_ChunkDesc.SetBlockTypeMeta(x, ++Top, z, E_BLOCK_PUMPKIN, static_cast<int>(val3 * 8) % 4);
}
break;
} // case E_BLOCK_GRASS
@@ -650,9 +650,9 @@ void cFinishGenSoulsandRims::GenFinish(cChunkDesc & a_ChunkDesc)
continue;
}
- NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(xx)) / 32;
- NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(zz)) / 32;
- NOISE_DATATYPE CompBlock = m_Noise.CubicNoise3D(NoiseX, (float) (y) / 4, NoiseY);
+ NOISE_DATATYPE NoiseX = (static_cast<NOISE_DATATYPE>(xx)) / 32;
+ NOISE_DATATYPE NoiseY = (static_cast<NOISE_DATATYPE>(zz)) / 32;
+ NOISE_DATATYPE CompBlock = m_Noise.CubicNoise3D(NoiseX, static_cast<float>(y) / 4, NoiseY);
if (CompBlock < 0)
{
a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SOULSAND);
@@ -676,7 +676,7 @@ void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc)
{
for (int x = 0; x < cChunkDef::Width; x++)
{
- int Height = a_ChunkDesc.GetHeight(x, z);
+ HEIGHTTYPE Height = a_ChunkDesc.GetHeight(x, z);
if (GetSnowStartHeight(a_ChunkDesc.GetBiome(x, z)) > Height)
{
// Height isn't high enough for snow to start forming.
@@ -775,7 +775,7 @@ void cFinishGenSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc)
continue;
}
- int Height = a_ChunkDesc.GetHeight(x, z);
+ HEIGHTTYPE Height = a_ChunkDesc.GetHeight(x, z);
if (Height >= cChunkDef::Height - 1)
{
// Too high up
@@ -918,7 +918,7 @@ void cFinishGenPreSimulator::CollapseSandGravel(
}
} // switch (GetBlock)
} // for y
- cChunkDef::SetHeight(a_HeightMap, x, z, HeightY);
+ cChunkDef::SetHeight(a_HeightMap, x, z, static_cast<HEIGHTTYPE>(HeightY));
} // for x
} // for z
}
@@ -1259,7 +1259,7 @@ bool cFinishGenPassiveMobs::TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int a_RelX
}
if (
(BlockUnderFeet != E_BLOCK_GRASS) &&
- ((AnimalToSpawn == mtRabbit) || (AnimalToSpawn == mtCow) || (AnimalToSpawn == mtSheep) || (AnimalToSpawn == mtChicken) || (AnimalToSpawn == mtPig))
+ ((AnimalToSpawn == mtWolf) || (AnimalToSpawn == mtRabbit) || (AnimalToSpawn == mtCow) || (AnimalToSpawn == mtSheep) || (AnimalToSpawn == mtChicken) || (AnimalToSpawn == mtPig))
)
{
return false;
@@ -1375,8 +1375,12 @@ eMonsterType cFinishGenPassiveMobs::GetRandomMob(cChunkDesc & a_ChunkDesc)
return mtInvalidType;
}
- int RandMob = (m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7) % ListOfSpawnables.size();
auto MobIter = ListOfSpawnables.begin();
+ using diff_type =
+ std::iterator_traits<decltype(MobIter)>::difference_type;
+ diff_type RandMob = static_cast<diff_type>
+ (static_cast<size_t>(m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7)
+ % ListOfSpawnables.size());
std::advance(MobIter, RandMob);
return *MobIter;
diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp
index 3c08c1a39..5adc60c4f 100644
--- a/src/Generating/GridStructGen.cpp
+++ b/src/Generating/GridStructGen.cpp
@@ -64,13 +64,13 @@ cGridStructGen::cGridStructGen(
LOG("Grid Size cannot be zero, setting to 1");
m_GridSizeZ = 1;
}
- size_t NumStructuresPerQuery = (size_t)(((m_MaxStructureSizeX + m_MaxOffsetX) / m_GridSizeX + 1) * ((m_MaxStructureSizeZ + m_MaxOffsetZ) / m_GridSizeZ + 1));
+ size_t NumStructuresPerQuery = static_cast<size_t>(((m_MaxStructureSizeX + m_MaxOffsetX) / m_GridSizeX + 1) * ((m_MaxStructureSizeZ + m_MaxOffsetZ) / m_GridSizeZ + 1));
if (NumStructuresPerQuery > m_MaxCacheSize)
{
m_MaxCacheSize = NumStructuresPerQuery * 4;
LOGINFO(
"cGridStructGen: The cache size is too small (%u), increasing the cache size to %u to avoid inefficiency.",
- (unsigned)a_MaxCacheSize, (unsigned)m_MaxCacheSize
+ static_cast<unsigned>(a_MaxCacheSize), static_cast<unsigned>(m_MaxCacheSize)
);
}
}
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index e34ffc57c..aa1c1893b 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -58,7 +58,7 @@ public:
virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override
{
int heights[cChunkDef::Width * cChunkDef::Width];
- m_Gen->GetInts(a_ChunkX * cChunkDef::Width, a_ChunkZ * cChunkDef::Width, cChunkDef::Width, cChunkDef::Width, heights);
+ m_Gen->GetInts(a_ChunkX * cChunkDef::Width, a_ChunkZ * cChunkDef::Width, static_cast<size_t>(cChunkDef::Width), static_cast<size_t>(cChunkDef::Width), heights);
for (size_t i = 0; i < ARRAYCOUNT(heights); i++)
{
a_HeightMap[i] = static_cast<HEIGHTTYPE>(std::max(std::min(60 + heights[i], cChunkDef::Height - 60), 40));
@@ -92,7 +92,7 @@ void cHeiGenFlat::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap
void cHeiGenFlat::InitializeHeightGen(cIniFile & a_IniFile)
{
- m_Height = a_IniFile.GetValueSetI("Generator", "FlatHeight", m_Height);
+ m_Height = static_cast<HEIGHTTYPE>(a_IniFile.GetValueSetI("Generator", "FlatHeight", m_Height));
}
@@ -300,15 +300,7 @@ void cHeiGenClassic::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightM
{
const float xx = (float)(a_ChunkX * cChunkDef::Width + x);
- int hei = 64 + (int)(GetNoise(xx * 0.05f, zz * 0.05f) * 16);
- if (hei < 10)
- {
- hei = 10;
- }
- if (hei > 250)
- {
- hei = 250;
- }
+ HEIGHTTYPE hei = static_cast<HEIGHTTYPE>(Clamp(static_cast<int>(64 + (GetNoise(xx * 0.05f, zz * 0.05f) * 16)), 10, 250));
cChunkDef::SetHeight(a_HeightMap, x, z, hei);
} // for x
} // for z
@@ -366,15 +358,7 @@ void cHeiGenMountains::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::Heigh
for (int x = 0; x < cChunkDef::Width; x++)
{
int idx = IdxZ + x;
- int hei = 100 - (int)((MountainNoise[idx] - DitchNoise[idx] + PerlinNoise[idx]) * 15);
- if (hei < 10)
- {
- hei = 10;
- }
- if (hei > 250)
- {
- hei = 250;
- }
+ HEIGHTTYPE hei = static_cast<HEIGHTTYPE>(Clamp(100 - static_cast<int>((MountainNoise[idx] - DitchNoise[idx] + PerlinNoise[idx]) * 15), 10, 250));
cChunkDef::SetHeight(a_HeightMap, x, z, hei);
} // for x
} // for z
@@ -536,7 +520,7 @@ void cHeiGenBiomal::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMa
{
for (int x = 0; x < cChunkDef::Width; x++)
{
- cChunkDef::SetHeight(a_HeightMap, x, z, (int)Height[x + 17 * z]);
+ cChunkDef::SetHeight(a_HeightMap, x, z, static_cast<HEIGHTTYPE>(Height[x + 17 * z]));
}
}
//*/
@@ -817,7 +801,10 @@ protected:
case biTaiga: a_Min = 63; a_Max = 75; break;
case biTaigaHills: a_Min = 63; a_Max = 90; break;
case biTaigaM: a_Min = 63; a_Max = 80; break;
- default:
+ case biInvalidBiome:
+ case biNumBiomes:
+ case biVariant:
+ case biNumVariantBiomes:
{
ASSERT(!"Unknown biome");
a_Min = 10;
diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h
index 62bb227c6..e2998bfb8 100644
--- a/src/Generating/HeiGen.h
+++ b/src/Generating/HeiGen.h
@@ -103,7 +103,7 @@ public:
protected:
- int m_Height;
+ HEIGHTTYPE m_Height;
// cTerrainHeightGen overrides:
virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp
index 65588ce4b..4ba896ef6 100644
--- a/src/Generating/MineShafts.cpp
+++ b/src/Generating/MineShafts.cpp
@@ -542,7 +542,7 @@ cMineShaft * cMineShaftCorridor::CreateAndFit(
{
cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ);
BoundingBox.p2.y += 3;
- int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
+ int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + static_cast<int>(a_ParentSystem.m_MineShafts.size()), a_PivotZ) / 7;
int NumSegments = 2 + (rnd) % (MAX_SEGMENTS - 1); // 2 .. MAX_SEGMENTS
switch (a_Direction)
{
@@ -564,14 +564,14 @@ cMineShaft * cMineShaftCorridor::CreateAndFit(
void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
{
- int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 7;
+ int Outerrnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 7;
// Prefer the same height, but allow for up to one block height displacement:
- int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2;
+ int OuterHeight = m_BoundingBox.p1.y + ((Outerrnd % 4) + ((Outerrnd >> 3) % 3)) / 2;
switch (m_Direction)
{
case dirXM:
{
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + 1, dirXM, a_Noise, a_RecursionLevel);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, OuterHeight, m_BoundingBox.p1.z + 1, dirXM, a_Noise, a_RecursionLevel);
for (int i = m_NumSegments; i >= 0; i--)
{
int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
@@ -586,7 +586,7 @@ void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
case dirXP:
{
- m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + 1, dirXP, a_Noise, a_RecursionLevel);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, OuterHeight, m_BoundingBox.p1.z + 1, dirXP, a_Noise, a_RecursionLevel);
for (int i = m_NumSegments; i >= 0; i--)
{
int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
@@ -601,7 +601,7 @@ void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
case dirZM:
{
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, OuterHeight, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
for (int i = m_NumSegments; i >= 0; i--)
{
int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
@@ -616,7 +616,7 @@ void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
case dirZP:
{
- m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
+ m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, OuterHeight, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
for (int i = m_NumSegments; i >= 0; i--)
{
int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11;
@@ -781,13 +781,19 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
case dirZM:
case dirZP:
- default:
{
x = m_BoundingBox.p1.x - BlockX;
z = m_BoundingBox.p1.z + m_ChestPosition - BlockZ;
Meta = E_META_CHEST_FACING_XP;
break;
}
+ #if !defined(__clang__)
+ default:
+ {
+ ASSERT(!"Unknown direction");
+ return;
+ }
+ #endif
} // switch (Dir)
if (
@@ -796,7 +802,7 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
)
{
a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, Meta);
- cChestEntity * ChestEntity = (cChestEntity *)a_ChunkDesc.GetBlockEntity(x, m_BoundingBox.p1.y + 1, z);
+ cChestEntity * ChestEntity = static_cast<cChestEntity *>(a_ChunkDesc.GetBlockEntity(x, m_BoundingBox.p1.y + 1, z));
ASSERT((ChestEntity != nullptr) && (ChestEntity->GetBlockType() == E_BLOCK_CHEST));
cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ());
int NumSlots = 3 + ((Noise.IntNoise3DInt(x, m_BoundingBox.p1.y, z) / 11) % 4);
@@ -986,7 +992,7 @@ cMineShaft * cMineShaftCrossing::CreateAndFit(
)
{
cCuboid BoundingBox(a_PivotX, a_PivotY - 1, a_PivotZ);
- int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
+ int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + static_cast<int>(a_ParentSystem.m_MineShafts.size()), a_PivotZ) / 7;
BoundingBox.p2.y += 3;
if ((rnd % 4) < 2)
{
@@ -1127,7 +1133,7 @@ cMineShaft * cMineShaftStaircase::CreateAndFit(
cNoise & a_Noise
)
{
- int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + (int)a_ParentSystem.m_MineShafts.size(), a_PivotZ) / 7;
+ int rnd = a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + static_cast<int>(a_ParentSystem.m_MineShafts.size()), a_PivotZ) / 7;
cCuboid Box;
switch (a_Direction)
{
diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp
index f35555efd..d29ab8cd1 100644
--- a/src/Generating/NetherFortGen.cpp
+++ b/src/Generating/NetherFortGen.cpp
@@ -36,7 +36,7 @@ public:
int BlockY = 64;
// Generate pieces:
- for (int i = 0; m_Pieces.size() < (size_t)(a_MaxDepth * a_MaxDepth / 8 + a_MaxDepth); i++)
+ for (int i = 0; m_Pieces.size() < static_cast<size_t>(a_MaxDepth * a_MaxDepth / 8 + a_MaxDepth); i++)
{
cBFSPieceGenerator pg(cNetherFortGen::m_PiecePool, a_Seed + i);
pg.PlacePieces(a_OriginX, BlockY, a_OriginZ, a_MaxDepth, m_Pieces);
@@ -55,7 +55,7 @@ public:
{
for (cPlacedPieces::const_iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
{
- const cPrefab & Prefab = (const cPrefab &)((*itr)->GetPiece());
+ const cPrefab & Prefab = static_cast<const cPrefab &>((*itr)->GetPiece());
Prefab.Draw(a_Chunk, *itr);
} // for itr - m_PlacedPieces[]
}
diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp
index 63e88c2a8..8163746f8 100644
--- a/src/Generating/Noise3DGenerator.cpp
+++ b/src/Generating/Noise3DGenerator.cpp
@@ -305,7 +305,7 @@ void cNoise3DGenerator::UpdateHeightmap(cChunkDesc & a_ChunkDesc)
{
for (int x = 0; x < cChunkDef::Width; x++)
{
- for (int y = cChunkDef::Height - 1; y > 0; y--)
+ for (HEIGHTTYPE y = cChunkDef::Height - 1; y > 0; y--)
{
if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR)
{
@@ -790,7 +790,10 @@ void cBiomalNoise3DComposable::GetBiomeParams(EMCSBiome a_Biome, NOISE_DATATYPE
case biTaiga: a_HeightAmp = 0.1f; a_MidPoint = 64; break;
case biTaigaM: a_HeightAmp = 0.1f; a_MidPoint = 70; break;
case biTaigaHills: a_HeightAmp = 0.075f; a_MidPoint = 68; break;
- default:
+ case biInvalidBiome:
+ case biNumBiomes:
+ case biVariant:
+ case biNumVariantBiomes:
{
// Make a crazy terrain so that it stands out
a_HeightAmp = 0.001f;
diff --git a/src/Generating/POCPieceGenerator.cpp b/src/Generating/POCPieceGenerator.cpp
index 6e7e74d7a..834e3887f 100644
--- a/src/Generating/POCPieceGenerator.cpp
+++ b/src/Generating/POCPieceGenerator.cpp
@@ -32,7 +32,7 @@ public:
/** Imprints the piece in the specified chunk. Assumes they intersect. */
- void ImprintInChunk(cChunkDesc & a_ChunkDesc, const Vector3i & a_Pos, int a_NumCCWRotations)
+ void ImprintInChunk(cChunkDesc & a_ChunkDesc, const Vector3i & a_Pos, int a_NumCCWRotations) const
{
int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
@@ -227,7 +227,7 @@ void cPOCPieceGenerator::GenFinish(cChunkDesc & a_ChunkDesc)
continue;
}
- ((cPOCPiece &)(*itr)->GetPiece()).ImprintInChunk(a_ChunkDesc, Pos, (*itr)->GetNumCCWRotations());
+ (static_cast<const cPOCPiece &>((*itr)->GetPiece())).ImprintInChunk(a_ChunkDesc, Pos, (*itr)->GetNumCCWRotations());
} // for itr - m_Pieces[]
a_ChunkDesc.UpdateHeightmap();
}
diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp
index 97aa646fc..14a9da39d 100644
--- a/src/Generating/PieceGenerator.cpp
+++ b/src/Generating/PieceGenerator.cpp
@@ -385,7 +385,7 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i
else
{
// All pieces returned zero weight, but we need one to start. Choose with equal chance:
- StartingPiece = StartingPieces[rnd % StartingPieces.size()];
+ StartingPiece = StartingPieces[static_cast<size_t>(rnd) % StartingPieces.size()];
}
rnd = rnd >> 16;
@@ -394,9 +394,9 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i
int NumRotations = 1;
for (size_t i = 1; i < ARRAYCOUNT(Rotations); i++)
{
- if (StartingPiece->CanRotateCCW((int)i))
+ if (StartingPiece->CanRotateCCW(static_cast<int>(i)))
{
- Rotations[NumRotations] = (int)i;
+ Rotations[NumRotations] = static_cast<int>(i);
NumRotations += 1;
}
}
@@ -561,7 +561,10 @@ void cPieceGenerator::DebugConnectorPool(const cPieceGenerator::cFreeConnectors
{
printf(" Connector pool: " SIZE_T_FMT " items\n", a_ConnectorPool.size() - a_NumProcessed);
size_t idx = 0;
- for (cPieceGenerator::cFreeConnectors::const_iterator itr = a_ConnectorPool.begin() + a_NumProcessed, end = a_ConnectorPool.end(); itr != end; ++itr, ++idx)
+
+ typedef cPieceGenerator::cFreeConnectors::difference_type difType;
+
+ for (auto itr = a_ConnectorPool.cbegin() + static_cast<difType>(a_NumProcessed), end = a_ConnectorPool.cend(); itr != end; ++itr, ++idx)
{
printf(" " SIZE_T_FMT ": {%d, %d, %d}, type %d, direction %s, depth %d\n",
idx,
@@ -672,7 +675,10 @@ void cBFSPieceGenerator::PlacePieces(int a_BlockX, int a_BlockY, int a_BlockZ, i
NumProcessed++;
if (NumProcessed > 1000)
{
- ConnectorPool.erase(ConnectorPool.begin(), ConnectorPool.begin() + NumProcessed);
+
+ typedef cPieceGenerator::cFreeConnectors::difference_type difType;
+
+ ConnectorPool.erase(ConnectorPool.begin(), ConnectorPool.begin() + static_cast<difType>(NumProcessed));
NumProcessed = 0;
}
}
diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp
index 761986690..1de0346bd 100644
--- a/src/Generating/Prefab.cpp
+++ b/src/Generating/Prefab.cpp
@@ -348,13 +348,13 @@ void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef)
LOGWARNING("Bad prefab CharMap definition line: \"%s\", skipping.", itr->c_str());
continue;
}
- unsigned char Src = (unsigned char)CharDef[0][0];
+ unsigned char Src = static_cast<unsigned char>(CharDef[0][0]);
ASSERT(a_CharMapOut[Src].m_BlockMeta == 16); // This letter has not been assigned yet?
- a_CharMapOut[Src].m_BlockType = (BLOCKTYPE)atoi(CharDef[1].c_str());
+ a_CharMapOut[Src].m_BlockType = static_cast<BLOCKTYPE>(atoi(CharDef[1].c_str()));
NIBBLETYPE BlockMeta = 0;
if ((NumElements >= 3) && !CharDef[2].empty())
{
- BlockMeta = (NIBBLETYPE)atoi(CharDef[2].c_str());
+ BlockMeta = static_cast<NIBBLETYPE>(atoi(CharDef[2].c_str()));
ASSERT((BlockMeta <= 15));
}
a_CharMapOut[Src].m_BlockMeta = BlockMeta;
@@ -372,7 +372,7 @@ void cPrefab::ParseBlockImage(const CharMap & a_CharMap, const char * a_BlockIma
{
for (int z = 0; z < m_Size.z; z++)
{
- const unsigned char * BlockImage = (const unsigned char *)a_BlockImage + y * m_Size.x * m_Size.z + z * m_Size.x;
+ const unsigned char * BlockImage = reinterpret_cast<const unsigned char *>(a_BlockImage + y * m_Size.x * m_Size.z + z * m_Size.x);
for (int x = 0; x < m_Size.x; x++)
{
const sBlockTypeDef & MappedValue = a_CharMap[BlockImage[x]];
@@ -424,7 +424,7 @@ void cPrefab::ParseConnectors(const char * a_ConnectorsDef)
m_Connectors.push_back(cPiece::cConnector(
atoi(Coords[0].c_str()), atoi(Coords[1].c_str()), atoi(Coords[2].c_str()), // Connector pos
atoi(Defs[0].c_str()), // Connector type
- (eBlockFace)BlockFace
+ static_cast<eBlockFace>(BlockFace)
));
} // for itr - Lines[]
}
diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp
index 895555ef8..e4df8efa8 100644
--- a/src/Generating/PrefabPiecePool.cpp
+++ b/src/Generating/PrefabPiecePool.cpp
@@ -85,7 +85,7 @@ void cPrefabPiecePool::AddStartingPieceDefs(const cPrefab::sDef * a_StartingPiec
void cPrefabPiecePool::AddToPerConnectorMap(cPrefab * a_Prefab)
{
- cPiece::cConnectors Connectors = ((const cPiece *)a_Prefab)->GetConnectors();
+ cPiece::cConnectors Connectors = (static_cast<const cPiece *>(a_Prefab))->GetConnectors();
for (cPiece::cConnectors::const_iterator itr = Connectors.begin(), end = Connectors.end(); itr != end; ++itr)
{
m_PiecesByConnector[itr->m_Type].push_back(a_Prefab);
@@ -122,7 +122,7 @@ cPieces cPrefabPiecePool::GetStartingPieces(void)
int cPrefabPiecePool::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece)
{
- return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector);
+ return (static_cast<const cPrefab &>(a_NewPiece)).GetPieceWeight(a_PlacedPiece, a_ExistingConnector);
}
@@ -131,7 +131,7 @@ int cPrefabPiecePool::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const c
int cPrefabPiecePool::GetStartingPieceWeight(const cPiece & a_NewPiece)
{
- return ((const cPrefab &)a_NewPiece).GetDefaultWeight();
+ return (static_cast<const cPrefab &>(a_NewPiece)).GetDefaultWeight();
}
diff --git a/src/Generating/ProtIntGen.h b/src/Generating/ProtIntGen.h
index 9e471e8bb..c0c7102d2 100644
--- a/src/Generating/ProtIntGen.h
+++ b/src/Generating/ProtIntGen.h
@@ -47,7 +47,7 @@ public:
virtual ~cProtIntGen() {}
/** Generates the array of specified size into a_Values, based on given min coords. */
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) = 0;
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) = 0;
};
@@ -109,14 +109,14 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int BaseZ = a_MinZ + z;
- for (int x = 0; x < a_SizeX; x++)
+ int BaseZ = a_MinZ + static_cast<int>(z);
+ for (size_t x = 0; x < a_SizeX; x++)
{
- a_Values[x + a_SizeX * z] = (super::m_Noise.IntNoise2DInt(a_MinX + x, BaseZ) / 7) % m_Range;
+ a_Values[x + a_SizeX * z] = (super::m_Noise.IntNoise2DInt(a_MinX + static_cast<int>(x), BaseZ) / 7) % m_Range;
}
} // for z
}
@@ -146,22 +146,22 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int BaseZ = a_MinZ + z;
- for (int x = 0; x < a_SizeX; x++)
+ int BaseZ = a_MinZ + static_cast<int>(z);
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int rnd = (super::m_Noise.IntNoise2DInt(a_MinX + x, BaseZ) / 7);
+ int rnd = (super::m_Noise.IntNoise2DInt(a_MinX + static_cast<int>(x), BaseZ) / 7);
a_Values[x + a_SizeX * z] = ((rnd % 100) < m_Threshold) ? ((rnd / 101) % bgLandOceanMax + 1) : 0;
}
}
// If the centerpoint of the world is within the area, set it to bgTemperate, always:
- if ((a_MinX <= 0) && (a_MinZ <= 0) && (a_MinX + a_SizeX > 0) && (a_MinZ + a_SizeZ > 0))
+ if ((a_MinX <= 0) && (a_MinZ <= 0) && (a_MinX + static_cast<int>(a_SizeX) > 0) && (a_MinZ + static_cast<int>(a_SizeZ) > 0))
{
- a_Values[-a_MinX - a_MinZ * a_SizeX] = bgTemperate;
+ a_Values[static_cast<size_t>(-a_MinX) - static_cast<size_t>(a_MinZ) * a_SizeX] = bgTemperate;
}
}
@@ -189,13 +189,13 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Get the coords for the lower generator:
int lowerMinX = a_MinX >> 1;
int lowerMinZ = a_MinZ >> 1;
- int lowerSizeX = a_SizeX / 2 + 2;
- int lowerSizeZ = a_SizeZ / 2 + 2;
+ size_t lowerSizeX = a_SizeX / 2 + 2;
+ size_t lowerSizeZ = a_SizeZ / 2 + 2;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
ASSERT(lowerSizeX > 0);
ASSERT(lowerSizeZ > 0);
@@ -203,22 +203,22 @@ public:
// Generate the underlying data with half the resolution:
int lowerData[m_BufferSize];
m_UnderlyingGen->GetInts(lowerMinX, lowerMinZ, lowerSizeX, lowerSizeZ, lowerData);
- const int lowStepX = (lowerSizeX - 1) * 2;
+ const size_t lowStepX = (lowerSizeX - 1) * 2;
int cache[m_BufferSize];
// Discreet-interpolate the values into twice the size:
- for (int z = 0; z < lowerSizeZ - 1; ++z)
+ for (size_t z = 0; z < lowerSizeZ - 1; ++z)
{
- int idx = (z * 2) * lowStepX;
+ size_t idx = (z * 2) * lowStepX;
int PrevZ0 = lowerData[z * lowerSizeX];
int PrevZ1 = lowerData[(z + 1) * lowerSizeX];
- for (int x = 0; x < lowerSizeX - 1; ++x)
+ for (size_t x = 0; x < lowerSizeX - 1; ++x)
{
int ValX1Z0 = lowerData[x + 1 + z * lowerSizeX];
int ValX1Z1 = lowerData[x + 1 + (z + 1) * lowerSizeX];
- int RndX = (x + lowerMinX) * 2;
- int RndZ = (z + lowerMinZ) * 2;
+ int RndX = (static_cast<int>(x) + lowerMinX) * 2;
+ int RndZ = (static_cast<int>(z) + lowerMinZ) * 2;
cache[idx] = PrevZ0;
cache[idx + lowStepX] = super::chooseRandomOne(RndX, RndZ + 1, PrevZ0, PrevZ1);
cache[idx + 1] = super::chooseRandomOne(RndX, RndZ - 1, PrevZ0, ValX1Z0);
@@ -230,7 +230,7 @@ public:
}
// Copy from Cache into a_Values; take into account the even / odd offsets in a_Min:
- for (int z = 0; z < a_SizeZ; ++z)
+ for (size_t z = 0; z < a_SizeZ; ++z)
{
memcpy(a_Values + z * a_SizeX, cache + (z + (a_MinZ & 1)) * lowStepX + (a_MinX & 1), a_SizeX * sizeof(int));
}
@@ -259,21 +259,21 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying values:
- int lowerSizeX = a_SizeX + 2;
- int lowerSizeZ = a_SizeZ + 2;
+ size_t lowerSizeX = a_SizeX + 2;
+ size_t lowerSizeZ = a_SizeZ + 2;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerData[m_BufferSize];
m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerData);
// Smooth - for each square check if the surroundings are the same, if so, expand them diagonally.
// Also get rid of single-pixel irregularities (A-B-A):
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int NoiseZ = a_MinZ + z;
- for (int x = 0; x < a_SizeX; x++)
+ int NoiseZ = a_MinZ + static_cast<int>(z);
+ for (size_t x = 0; x < a_SizeX; x++)
{
int val = lowerData[x + 1 + (z + 1) * lowerSizeX];
int above = lowerData[x + 1 + z * lowerSizeX];
@@ -283,7 +283,7 @@ public:
if ((left == right) && (above == below))
{
- if (((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ) / 7) % 2) == 0)
+ if (((super::m_Noise.IntNoise2DInt(a_MinX + static_cast<int>(x), NoiseZ) / 7) % 2) == 0)
{
val = left;
}
@@ -331,21 +331,21 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying values:
- int lowerSizeX = a_SizeX + 1;
- int lowerSizeZ = a_SizeZ + 1;
+ size_t lowerSizeX = a_SizeX + 1;
+ size_t lowerSizeZ = a_SizeZ + 1;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerData[m_BufferSize];
m_Underlying->GetInts(a_MinX, a_MinZ, lowerSizeX, lowerSizeZ, lowerData);
// Average - add all 4 "neighbors" and divide by 4:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int idxLower = x + lowerSizeX * z;
+ size_t idxLower = x + lowerSizeX * z;
a_Values[x + a_SizeX * z] = (
lowerData[idxLower] + lowerData[idxLower + 1] +
lowerData[idxLower + lowerSizeX] + lowerData[idxLower + lowerSizeX + 1]
@@ -375,24 +375,24 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying values:
- int lowerSizeX = a_SizeX + 4;
- int lowerSizeZ = a_SizeZ + 4;
+ size_t lowerSizeX = a_SizeX + 4;
+ size_t lowerSizeZ = a_SizeZ + 4;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerData[m_BufferSize];
m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerData);
// Calculate the weighted average of all 16 "neighbors":
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int idxLower1 = x + lowerSizeX * z;
- int idxLower2 = idxLower1 + lowerSizeX;
- int idxLower3 = idxLower1 + 2 * lowerSizeX;
- int idxLower4 = idxLower1 + 3 * lowerSizeX;
+ size_t idxLower1 = x + lowerSizeX * z;
+ size_t idxLower2 = idxLower1 + lowerSizeX;
+ size_t idxLower3 = idxLower1 + 2 * lowerSizeX;
+ size_t idxLower4 = idxLower1 + 3 * lowerSizeX;
a_Values[x + a_SizeX * z] = (
1 * lowerData[idxLower1] + 2 * lowerData[idxLower1 + 1] + 2 * lowerData[idxLower1 + 2] + 1 * lowerData[idxLower1 + 3] +
2 * lowerData[idxLower2] + 32 * lowerData[idxLower2 + 1] + 32 * lowerData[idxLower2 + 2] + 2 * lowerData[idxLower2 + 3] +
@@ -425,23 +425,23 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying values:
- int lowerSizeX = a_SizeX + 3;
- int lowerSizeZ = a_SizeZ + 3;
+ size_t lowerSizeX = a_SizeX + 3;
+ size_t lowerSizeZ = a_SizeZ + 3;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerData[m_BufferSize];
m_Underlying->GetInts(a_MinX, a_MinZ, lowerSizeX, lowerSizeZ, lowerData);
// Calculate the weighted average the neighbors:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int idxLower1 = x + lowerSizeX * z;
- int idxLower2 = idxLower1 + lowerSizeX;
- int idxLower3 = idxLower1 + 2 * lowerSizeX;
+ size_t idxLower1 = x + lowerSizeX * z;
+ size_t idxLower2 = idxLower1 + lowerSizeX;
+ size_t idxLower3 = idxLower1 + 2 * lowerSizeX;
a_Values[x + a_SizeX * z] = (
WeightDiagonal * lowerData[idxLower1] + WeightCardinal * lowerData[idxLower1 + 1] + WeightDiagonal * lowerData[idxLower1 + 2] +
WeightCardinal * lowerData[idxLower2] + WeightCenter * lowerData[idxLower2 + 1] + WeightCardinal * lowerData[idxLower2 + 2] +
@@ -476,20 +476,20 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying values:
m_Underlying->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
// Replace random values:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int BaseZ = a_MinZ + z;
- for (int x = 0; x < a_SizeX; x++)
+ int BaseZ = a_MinZ + static_cast<int>(z);
+ for (size_t x = 0; x < a_SizeX; x++)
{
- if (((super::m_Noise.IntNoise2DInt(BaseZ, a_MinX + x) / 13) % 101) < m_ChancePct)
+ if (((super::m_Noise.IntNoise2DInt(BaseZ, a_MinX + static_cast<int>(x)) / 13) % 101) < m_ChancePct)
{
- a_Values[x + a_SizeX * z] = m_Min + (super::m_Noise.IntNoise2DInt(a_MinX + x, BaseZ) / 7) % m_Range;
+ a_Values[x + a_SizeX * z] = m_Min + (super::m_Noise.IntNoise2DInt(a_MinX + static_cast<int>(x), BaseZ) / 7) % m_Range;
}
} // for x
} // for z
@@ -522,18 +522,18 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying values:
m_Underlying->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
// Add the random values:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int NoiseZ = a_MinZ + z;
- for (int x = 0; x < a_SizeX; x++)
+ int NoiseZ = a_MinZ + static_cast<int>(z);
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int noiseVal = ((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ) / 7) % m_Range) - m_HalfRange;
+ int noiseVal = ((super::m_Noise.IntNoise2DInt(a_MinX + static_cast<int>(x), NoiseZ) / 7) % m_Range) - m_HalfRange;
a_Values[x + z * a_SizeX] += noiseVal;
}
}
@@ -564,23 +564,23 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying values:
- int lowerSizeX = a_SizeX + 2;
- int lowerSizeZ = a_SizeZ + 2;
+ size_t lowerSizeX = a_SizeX + 2;
+ size_t lowerSizeZ = a_SizeZ + 2;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerData[m_BufferSize];
m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerData);
// Average random values:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int NoiseZ = a_MinZ + z;
- for (int x = 0; x < a_SizeX; x++)
+ int NoiseZ = a_MinZ + static_cast<int>(z);
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int idxLower = x + 1 + lowerSizeX * (z + 1);
- if (((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ) / 7) % 100) > m_AvgChancePct)
+ size_t idxLower = x + 1 + lowerSizeX * (z + 1);
+ if (((super::m_Noise.IntNoise2DInt(a_MinX + static_cast<int>(x), NoiseZ) / 7) % 100) > m_AvgChancePct)
{
// Average the 4 neighbors:
a_Values[x + z * a_SizeX] = (
@@ -621,28 +621,28 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying values:
- int lowerSizeX = a_SizeX + 2;
- int lowerSizeZ = a_SizeZ + 2;
+ size_t lowerSizeX = a_SizeX + 2;
+ size_t lowerSizeZ = a_SizeZ + 2;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerData[m_BufferSize];
m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerData);
// Average random values:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int NoiseZ = a_MinZ + z;
- for (int x = 0; x < a_SizeX; x++)
+ int NoiseZ = a_MinZ + static_cast<int>(z);
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int idxLower = x + 1 + lowerSizeX * (z + 1);
- if (((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ) / 7) % 100) > m_AvgChancePct)
+ size_t idxLower = x + 1 + lowerSizeX * (z + 1);
+ if (((super::m_Noise.IntNoise2DInt(a_MinX + static_cast<int>(x), NoiseZ) / 7) % 100) > m_AvgChancePct)
{
// Chose a value in between the min and max neighbor:
int min = std::min(std::min(lowerData[idxLower - 1], lowerData[idxLower + 1]), std::min(lowerData[idxLower - lowerSizeX], lowerData[idxLower + lowerSizeX]));
int max = std::max(std::max(lowerData[idxLower - 1], lowerData[idxLower + 1]), std::max(lowerData[idxLower - lowerSizeX], lowerData[idxLower + lowerSizeX]));
- a_Values[x + z * a_SizeX] = min + ((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ + 10) / 7) % (max - min + 1));
+ a_Values[x + z * a_SizeX] = min + ((super::m_Noise.IntNoise2DInt(a_MinX + static_cast<int>(x), NoiseZ + 10) / 7) % (max - min + 1));
}
else
{
@@ -675,7 +675,7 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Map for biome -> its beach:
static const int ToBeach[] =
@@ -723,16 +723,16 @@ public:
};
// Generate the underlying values:
- int lowerSizeX = a_SizeX + 2;
- int lowerSizeZ = a_SizeZ + 2;
+ size_t lowerSizeX = a_SizeX + 2;
+ size_t lowerSizeZ = a_SizeZ + 2;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerValues[m_BufferSize];
m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerValues);
// Add beaches between ocean and biomes:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
int val = lowerValues[x + 1 + (z + 1) * lowerSizeX];
int above = lowerValues[x + 1 + z * lowerSizeX];
@@ -779,16 +779,16 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
m_Underlying->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
if (a_Values[x + z * a_SizeX] == bgOcean)
{
- int rnd = super::m_Noise.IntNoise2DInt(a_MinX + x, a_MinZ + z) / 7;
+ int rnd = super::m_Noise.IntNoise2DInt(a_MinX + static_cast<int>(x), a_MinZ + static_cast<int>(z)) / 7;
if (rnd % 1000 < m_Chance)
{
a_Values[x + z * a_SizeX] = (rnd / 1003) % bgLandOceanMax;
@@ -822,19 +822,19 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values)
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values)
{
// Generate the underlying biome groups:
- int lowerSizeX = a_SizeX + 2;
- int lowerSizeZ = a_SizeZ + 2;
+ size_t lowerSizeX = a_SizeX + 2;
+ size_t lowerSizeZ = a_SizeZ + 2;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerValues[m_BufferSize];
m_Underlying->GetInts(a_MinX, a_MinZ, lowerSizeX, lowerSizeZ, lowerValues);
// Change the biomes on incompatible edges into an edge biome:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
int val = lowerValues[x + 1 + (z + 1) * lowerSizeX];
int Above = lowerValues[x + 1 + z * lowerSizeX];
@@ -920,7 +920,7 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Define the per-biome-group biomes:
static const int oceanBiomes[] =
@@ -998,16 +998,16 @@ public:
// Overwrite each biome group with a random biome from that group:
// Take care of the bgfRare flag
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int IdxZ = z * a_SizeX;
- for (int x = 0; x < a_SizeX; x++)
+ size_t IdxZ = z * a_SizeX;
+ for (size_t x = 0; x < a_SizeX; x++)
{
int val = a_Values[x + IdxZ];
const cBiomesInGroups & Biomes = (val > bgfRare) ?
rareBiomesInGroups[(val & (bgfRare - 1)) % ARRAYCOUNT(rareBiomesInGroups)] :
- biomesInGroups[val % ARRAYCOUNT(biomesInGroups)];
- int rnd = (super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7);
+ biomesInGroups[static_cast<size_t>(val) % ARRAYCOUNT(biomesInGroups)];
+ int rnd = (super::m_Noise.IntNoise2DInt(static_cast<int>(x) + a_MinX, static_cast<int>(z) + a_MinZ) / 7);
a_Values[x + IdxZ] = Biomes.Biomes[rnd % Biomes.Count];
}
}
@@ -1050,21 +1050,21 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying values:
m_Underlying->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
// Replace some of the values:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int idxZ = z * a_SizeX;
- for (int x = 0; x < a_SizeX; x++)
+ size_t idxZ = z * a_SizeX;
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int idx = x + idxZ;
+ size_t idx = x + idxZ;
if (a_Values[idx] == m_From)
{
- int rnd = super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7;
+ int rnd = super::m_Noise.IntNoise2DInt(static_cast<int>(x) + a_MinX, static_cast<int>(z) + a_MinZ) / 7;
if (rnd % 1000 < m_Chance)
{
a_Values[idx] = m_To;
@@ -1109,7 +1109,7 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying data:
ASSERT(a_SizeX * a_SizeZ <= m_BufferSize);
@@ -1118,12 +1118,12 @@ public:
m_Rivers->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, riverData);
// Mix the values:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int idxZ = z * a_SizeX;
- for (int x = 0; x < a_SizeX; x++)
+ size_t idxZ = z * a_SizeX;
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int idx = x + idxZ;
+ size_t idx = x + idxZ;
if (IsBiomeOcean(a_Values[idx]))
{
// Oceans are kept without any changes
@@ -1136,7 +1136,7 @@ public:
}
// There's a river, change the output to a river or a frozen river, based on the original biome:
- if (IsBiomeVeryCold((EMCSBiome)a_Values[idx]))
+ if (IsBiomeVeryCold(static_cast<EMCSBiome>(a_Values[idx])))
{
a_Values[idx] = biFrozenRiver;
}
@@ -1173,19 +1173,19 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying data:
- int lowerSizeX = a_SizeX + 2;
- int lowerSizeZ = a_SizeZ + 2;
+ size_t lowerSizeX = a_SizeX + 2;
+ size_t lowerSizeZ = a_SizeZ + 2;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerValues[m_BufferSize];
m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerValues);
// Detect the edges:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
int Above = lowerValues[x + 1 + z * lowerSizeX];
int Below = lowerValues[x + 1 + (z + 2) * lowerSizeX];
@@ -1231,19 +1231,19 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying data:
- int lowerSizeX = a_SizeX + 2;
- int lowerSizeZ = a_SizeZ + 2;
+ size_t lowerSizeX = a_SizeX + 2;
+ size_t lowerSizeZ = a_SizeZ + 2;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerValues[m_BufferSize];
m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerValues);
// Add the mushroom islands:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
int val = lowerValues[x + 1 + (z + 1) * lowerSizeX];
if (!IsBiomeOcean(val))
@@ -1278,7 +1278,7 @@ public:
// If at least 3 ocean neighbors and the chance is right, change:
if (
(NumOceanNeighbors >= 3) &&
- ((super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7) % 1000 < m_Chance)
+ ((super::m_Noise.IntNoise2DInt(static_cast<int>(x) + a_MinX, static_cast<int>(z) + a_MinZ) / 7) % 1000 < m_Chance)
)
{
a_Values[x + z * a_SizeX] = m_ToValue;
@@ -1321,17 +1321,17 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying data:
m_Underlying->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
// Change random pixels to bgOcean:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int rnd = super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7;
+ int rnd = super::m_Noise.IntNoise2DInt(static_cast<int>(x) + a_MinX, static_cast<int>(z) + a_MinZ) / 7;
if (rnd % 1000 < m_Chance)
{
a_Values[x + z * a_SizeX] = m_ToValue;
@@ -1370,20 +1370,20 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying data:
m_Underlying->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
// Change some of the biome groups into rare biome groups:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
- int rnd = super::m_Noise.IntNoise2DInt(x + a_MinX, z + a_MinZ) / 7;
+ int rnd = super::m_Noise.IntNoise2DInt(static_cast<int>(x) + a_MinX, static_cast<int>(z) + a_MinZ) / 7;
if (rnd % 1000 < m_Chance)
{
- int idx = x + a_SizeX * z;
+ size_t idx = x + a_SizeX * z;
a_Values[idx] = a_Values[idx] | bgfRare;
}
}
@@ -1418,7 +1418,7 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the base biomes and the alterations:
m_BaseBiomes->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
@@ -1426,8 +1426,8 @@ public:
m_Alterations->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, alterations);
// Change the biomes into their alternate versions:
- int len = a_SizeX * a_SizeZ;
- for (int idx = 0; idx < len; ++idx)
+ size_t len = a_SizeX * a_SizeZ;
+ for (size_t idx = 0; idx < len; ++idx)
{
if (alterations[idx] == 0)
{
@@ -1482,19 +1482,19 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying biomes:
- int lowerSizeX = a_SizeX + 2;
- int lowerSizeZ = a_SizeZ + 2;
+ size_t lowerSizeX = a_SizeX + 2;
+ size_t lowerSizeZ = a_SizeZ + 2;
ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
int lowerValues[m_BufferSize];
m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerValues);
// Convert incompatible edges into neutral biomes:
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
int biome = lowerValues[x + 1 + (z + 1) * lowerSizeX];
int above = lowerValues[x + 1 + z * lowerSizeX];
@@ -1642,7 +1642,7 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(int a_MinX, int a_MinZ, size_t a_SizeX, size_t a_SizeZ, int *a_Values) override
{
// Generate the underlying biomes and the alterations:
m_Underlying->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
@@ -1650,8 +1650,8 @@ public:
m_Alteration->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, alterations);
// Wherever alterations are nonzero, change into alternate biome, if available:
- int len = a_SizeX * a_SizeZ;
- for (int idx = 0; idx < len; ++idx)
+ size_t len = a_SizeX * a_SizeZ;
+ for (size_t idx = 0; idx < len; ++idx)
{
if (alterations[idx] == 0)
{
diff --git a/src/Generating/RainbowRoadsGen.cpp b/src/Generating/RainbowRoadsGen.cpp
index fd4a81692..03400556a 100644
--- a/src/Generating/RainbowRoadsGen.cpp
+++ b/src/Generating/RainbowRoadsGen.cpp
@@ -76,7 +76,7 @@ protected:
{
for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
{
- cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece());
+ const cPrefab & Prefab = static_cast<const cPrefab &>((*itr)->GetPiece());
Prefab.Draw(a_Chunk, *itr);
} // for itr - m_PlacedPieces[]
}
diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp
index 9f8f69139..8c6316273 100644
--- a/src/Generating/Ravines.cpp
+++ b/src/Generating/Ravines.cpp
@@ -135,17 +135,17 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block
// Get the base angle in which the ravine "axis" goes:
float Angle = (float)(((float)((a_Noise.IntNoise3DInt(20 * a_BlockX, 70 * a_BlockZ, 6000) / 9) % 16384)) / 16384.0 * M_PI);
- float xc = sin(Angle);
- float zc = cos(Angle);
+ float xc = sinf(Angle);
+ float zc = cosf(Angle);
// Calculate the definition points and radii:
int MaxRadius = (int)(sqrt(12.0 + ((a_Noise.IntNoise2DInt(61 * a_BlockX, 97 * a_BlockZ) / 13) % a_Size) / 16));
int Top = 32 + ((a_Noise.IntNoise2DInt(13 * a_BlockX, 17 * a_BlockZ) / 23) % 32);
int Bottom = 5 + ((a_Noise.IntNoise2DInt(17 * a_BlockX, 29 * a_BlockZ) / 13) % 32);
int Mid = (Top + Bottom) / 2;
- int PointX = CenterX - (int)(xc * a_Size / 2);
- int PointZ = CenterZ - (int)(zc * a_Size / 2);
- m_Points.push_back(cRavDefPoint(PointX, PointZ, 0, (Mid + Top) / 2, (Mid + Bottom) / 2));
+ int DefinitionPointX = CenterX - (int)(xc * a_Size / 2);
+ int DefinitionPointZ = CenterZ - (int)(zc * a_Size / 2);
+ m_Points.push_back(cRavDefPoint(DefinitionPointX, DefinitionPointZ, 0, (Mid + Top) / 2, (Mid + Bottom) / 2));
for (int i = 1; i < NUM_RAVINE_POINTS - 1; i++)
{
int LineX = CenterX + (int)(xc * a_Size * (i - NUM_RAVINE_POINTS / 2) / NUM_RAVINE_POINTS);
@@ -160,9 +160,9 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block
int ThisBottom = Bottom + ((a_Noise.IntNoise3DInt(19 * a_BlockX, 7 * a_BlockZ, i * 31) / 13) % 8) - 4;
m_Points.push_back(cRavDefPoint(PointX, PointZ, Radius, ThisTop, ThisBottom));
} // for i - m_Points[]
- PointX = CenterX + (int)(xc * a_Size / 2);
- PointZ = CenterZ + (int)(zc * a_Size / 2);
- m_Points.push_back(cRavDefPoint(PointX, PointZ, 0, Mid, Mid));
+ DefinitionPointX = CenterX + (int)(xc * a_Size / 2);
+ DefinitionPointZ = CenterZ + (int)(zc * a_Size / 2);
+ m_Points.push_back(cRavDefPoint(DefinitionPointX, DefinitionPointZ, 0, Mid, Mid));
}
diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp
index 2ee3704b3..c0397ee26 100644
--- a/src/Generating/RoughRavines.cpp
+++ b/src/Generating/RoughRavines.cpp
@@ -21,7 +21,7 @@ class cRoughRavine :
public:
cRoughRavine(
- int a_Seed, int a_Size,
+ int a_Seed, size_t a_Size,
float a_CenterWidth, float a_Roughness,
float a_FloorHeightEdge1, float a_FloorHeightEdge2, float a_FloorHeightCenter,
float a_CeilingHeightEdge1, float a_CeilingHeightEdge2, float a_CeilingHeightCenter,
@@ -33,14 +33,14 @@ public:
m_Roughness(a_Roughness)
{
// Create the basic structure - 2 lines meeting at the centerpoint:
- int Max = 2 * a_Size;
- int Half = a_Size; // m_DefPoints[Half] will be the centerpoint
+ size_t Max = 2 * a_Size;
+ size_t Half = a_Size; // m_DefPoints[Half] will be the centerpoint
m_DefPoints.resize(Max + 1);
int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 7;
float Len = (float)a_Size;
float Angle = (float)rnd; // Angle is in radians, will be wrapped in the "sin" and "cos" operations
- float OfsX = sin(Angle) * Len;
- float OfsZ = cos(Angle) * Len;
+ float OfsX = sinf(Angle) * Len;
+ float OfsZ = cosf(Angle) * Len;
m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, a_CeilingHeightEdge1, a_FloorHeightEdge1);
m_DefPoints[Half].Set((float)a_OriginX, (float)a_OriginZ, a_CenterWidth, a_CeilingHeightCenter, a_FloorHeightCenter);
m_DefPoints[Max].Set (a_OriginX + OfsX, a_OriginZ + OfsZ, 1, a_CeilingHeightEdge2, a_FloorHeightEdge2);
@@ -90,7 +90,7 @@ protected:
/** Recursively subdivides the line between the points of the specified index.
Sets the midpoint to the center of the line plus or minus a random offset, then calls itself for each half
of the new line. */
- void SubdivideLine(int a_Idx1, int a_Idx2)
+ void SubdivideLine(size_t a_Idx1, size_t a_Idx2)
{
// Calculate the midpoint:
const sRavineDefPoint & p1 = m_DefPoints[a_Idx1];
@@ -114,7 +114,7 @@ protected:
MidX -= dz * m_Roughness;
MidZ += dx * m_Roughness;
}
- int MidIdx = (a_Idx1 + a_Idx2) / 2;
+ size_t MidIdx = (a_Idx1 + a_Idx2) / 2;
m_DefPoints[MidIdx].Set(MidX, MidZ, MidR, MidT, MidB);
// Recurse the two halves, if they are worth recursing:
@@ -275,7 +275,7 @@ cRoughRavines::cRoughRavines(
cGridStructGen::cStructurePtr cRoughRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
// Pick a random value for each of the ravine's parameters:
- int Size = m_MinSize + (m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 7) % (m_MaxSize - m_MinSize); // Random int from m_MinSize to m_MaxSize
+ size_t Size = static_cast<size_t>(m_MinSize + (m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 7) % (m_MaxSize - m_MinSize)); // Random int from m_MinSize to m_MaxSize
float CenterWidth = m_Noise.IntNoise2DInRange(a_GridX + 10, a_GridZ, m_MinCenterWidth, m_MaxCenterWidth);
float Roughness = m_Noise.IntNoise2DInRange(a_GridX + 20, a_GridZ, m_MinRoughness, m_MaxRoughness);
float FloorHeightEdge1 = m_Noise.IntNoise2DInRange(a_GridX + 30, a_GridZ, m_MinFloorHeightEdge, m_MaxFloorHeightEdge);
diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp
index 7572cdcbf..fd911e7dc 100644
--- a/src/Generating/StructGen.cpp
+++ b/src/Generating/StructGen.cpp
@@ -72,7 +72,7 @@ void cStructGenTrees::GenFinish(cChunkDesc & a_ChunkDesc)
{
for (int z = 0; z < cChunkDef::Width; z++)
{
- for (int y = cChunkDef::Height - 1; y >= 0; y--)
+ for (HEIGHTTYPE y = cChunkDef::Height - 1; y >= 0; y--)
{
if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR)
{
@@ -304,14 +304,14 @@ void cStructGenOreNests::GenerateOre(int a_ChunkX, int a_ChunkZ, BLOCKTYPE a_Ore
for (int i = 0; i < a_NumNests; i++)
{
- int rnd = m_Noise.IntNoise3DInt(a_ChunkX + i, a_Seq, a_ChunkZ + 64 * i) / 8;
- int BaseX = rnd % cChunkDef::Width;
- rnd /= cChunkDef::Width;
- int BaseZ = rnd % cChunkDef::Width;
- rnd /= cChunkDef::Width;
- int BaseY = rnd % a_MaxHeight;
- rnd /= a_MaxHeight;
- int NestSize = a_NestSize + (rnd % (a_NestSize / 4)); // The actual nest size may be up to 1 / 4 larger
+ int Nestrnd = m_Noise.IntNoise3DInt(a_ChunkX + i, a_Seq, a_ChunkZ + 64 * i) / 8;
+ int BaseX = Nestrnd % cChunkDef::Width;
+ Nestrnd /= cChunkDef::Width;
+ int BaseZ = Nestrnd % cChunkDef::Width;
+ Nestrnd /= cChunkDef::Width;
+ int BaseY = Nestrnd % a_MaxHeight;
+ Nestrnd /= a_MaxHeight;
+ int NestSize = a_NestSize + (Nestrnd % (a_NestSize / 4)); // The actual nest size may be up to 1 / 4 larger
int Num = 0;
while (Num < NestSize)
{
@@ -436,14 +436,14 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, int a_MaxLakeH
BLOCKTYPE * BlockTypes = a_Lake.GetBlockTypes();
for (int i = 0; i < NumBubbles; i++)
{
- int Rnd = m_Noise.IntNoise3DInt(a_ChunkX, i, a_ChunkZ) / 13;
- const int BubbleR = 2 + (Rnd & 0x03); // 2 .. 5
+ int BubbleRnd = m_Noise.IntNoise3DInt(a_ChunkX, i, a_ChunkZ) / 13;
+ const int BubbleR = 2 + (BubbleRnd & 0x03); // 2 .. 5
const int Range = 16 - 2 * BubbleR;
- const int BubbleX = BubbleR + (Rnd % Range);
+ const int BubbleX = BubbleR + (BubbleRnd % Range);
Rnd >>= 4;
- const int BubbleY = 4 + (Rnd & 0x01); // 4 .. 5
+ const int BubbleY = 4 + (BubbleRnd & 0x01); // 4 .. 5
Rnd >>= 1;
- const int BubbleZ = BubbleR + (Rnd % Range);
+ const int BubbleZ = BubbleR + (BubbleRnd % Range);
const int HalfR = BubbleR / 2; // 1 .. 2
const int RSquared = BubbleR * BubbleR;
for (int y = -HalfR; y <= HalfR; y++)
diff --git a/src/Generating/TestRailsGen.cpp b/src/Generating/TestRailsGen.cpp
index 8256b55a0..72317eb67 100644
--- a/src/Generating/TestRailsGen.cpp
+++ b/src/Generating/TestRailsGen.cpp
@@ -76,7 +76,7 @@ protected:
{
for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
{
- cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece());
+ const cPrefab & Prefab = static_cast<const cPrefab &>((*itr)->GetPiece());
Prefab.Draw(a_Chunk, *itr);
} // for itr - m_PlacedPieces[]
}
diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp
index 72fe5f819..c8bbab12f 100644
--- a/src/Generating/Trees.cpp
+++ b/src/Generating/Trees.cpp
@@ -130,7 +130,7 @@ inline void PushSomeColumns(int a_BlockX, int a_Height, int a_BlockZ, int a_Colu
{
int x = a_BlockX + a_Coords[i].x;
int z = a_BlockZ + a_Coords[i].z;
- if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + (int)i, z + 64 * a_Seq) <= a_Chance)
+ if (a_Noise.IntNoise3DInt(x + 64 * a_Seq, a_Height + static_cast<int>(i), z + 64 * a_Seq) <= a_Chance)
{
for (int j = 0; j < a_ColumnHeight; j++)
{
@@ -321,12 +321,12 @@ void GetSmallAppleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a
int Random = a_Noise.IntNoise3DInt(a_BlockX + 64 * a_Seq, a_BlockY, a_BlockZ) >> 3;
- int Heights[] = {1, 2, 2, 3} ;
- int Height = 1 + Heights[Random & 3];
+ HEIGHTTYPE Heights[] = {1, 2, 2, 3} ;
+ HEIGHTTYPE Height = 1 + Heights[Random & 3];
Random >>= 2;
// Pre-alloc so that we don't realloc too often later:
- a_LogBlocks.reserve(Height + 5);
+ a_LogBlocks.reserve(static_cast<size_t>(Height + 5));
a_OtherBlocks.reserve(ARRAYCOUNT(BigO2) * 2 + ARRAYCOUNT(BigO1) + ARRAYCOUNT(Corners) * 3 + 3 + 5);
// Trunk:
@@ -396,8 +396,8 @@ void GetLargeAppleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a
for (int i = 4; i < Height; i++)
{
// Get a direction for the trunk to go to.
- Vector3d BranchStartDirection = AvailableDirections[a_Noise.IntNoise3DInt(a_BlockX, a_BlockY + i, a_BlockZ) % ARRAYCOUNT(AvailableDirections)];
- Vector3d BranchDirection = AvailableDirections[a_Noise.IntNoise3DInt(a_BlockX, a_BlockY / i, a_BlockZ) % ARRAYCOUNT(AvailableDirections)] / 3;
+ Vector3d BranchStartDirection = AvailableDirections[static_cast<size_t>(a_Noise.IntNoise3DInt(a_BlockX, a_BlockY + i, a_BlockZ)) % ARRAYCOUNT(AvailableDirections)];
+ Vector3d BranchDirection = AvailableDirections[static_cast<size_t>(a_Noise.IntNoise3DInt(a_BlockX, a_BlockY / i, a_BlockZ)) % ARRAYCOUNT(AvailableDirections)] / 3;
int BranchLength = 2 + a_Noise.IntNoise3DInt(a_BlockX * a_Seq, a_BlockY * a_Seq, a_BlockZ * a_Seq) % 3;
GetLargeAppleTreeBranch(a_BlockX, a_BlockY + i, a_BlockZ, BranchLength, BranchStartDirection, BranchDirection, a_BlockY + Height, a_Noise, a_LogBlocks);
@@ -476,10 +476,10 @@ NIBBLETYPE GetLogMetaFromDirection(NIBBLETYPE a_BlockMeta, Vector3d a_Direction)
void GetBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks)
{
- int Height = 5 + (a_Noise.IntNoise3DInt(a_BlockX + 64 * a_Seq, a_BlockY, a_BlockZ) % 3);
+ HEIGHTTYPE Height = 5 + (a_Noise.IntNoise3DInt(a_BlockX + 64 * a_Seq, a_BlockY, a_BlockZ) % 3);
// Prealloc, so that we don't realloc too often later:
- a_LogBlocks.reserve(Height);
+ a_LogBlocks.reserve(static_cast<size_t>(Height));
a_OtherBlocks.reserve(80);
// The entire trunk, out of logs:
@@ -650,10 +650,10 @@ void GetDarkoakTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No
void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks)
{
- int Height = 9 + (a_Noise.IntNoise3DInt(a_BlockX + 64 * a_Seq, a_BlockY, a_BlockZ) % 3);
+ HEIGHTTYPE Height = 9 + (a_Noise.IntNoise3DInt(a_BlockX + 64 * a_Seq, a_BlockY, a_BlockZ) % 3);
// Prealloc, so that we don't realloc too often later:
- a_LogBlocks.reserve(Height);
+ a_LogBlocks.reserve(static_cast<size_t>(Height));
a_OtherBlocks.reserve(80);
// The entire trunk, out of logs:
@@ -713,12 +713,12 @@ void GetSpruceTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noi
// (each of the mod8 remainders has a very different chance of occurrence) - that's why we divide by 8
int MyRandom = a_Noise.IntNoise3DInt(a_BlockX + 32 * a_Seq, a_BlockY + 32 * a_Seq, a_BlockZ) / 8;
- static const int sHeights[] = {1, 2, 2, 3};
- int Height = sHeights[MyRandom & 3];
+ static const HEIGHTTYPE sHeights[] = {1, 2, 2, 3};
+ HEIGHTTYPE Height = sHeights[MyRandom & 3];
MyRandom >>= 2;
// Prealloc, so that we don't realloc too often later:
- a_LogBlocks.reserve(Height);
+ a_LogBlocks.reserve(static_cast<size_t>(Height));
a_OtherBlocks.reserve(180);
// Clear trunk blocks:
@@ -816,8 +816,8 @@ void GetPineTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise
}
// Pre-allocate the vector:
- a_LogBlocks.reserve(TrunkHeight);
- a_OtherBlocks.reserve(NumLeavesLayers * 25);
+ a_LogBlocks.reserve(static_cast<size_t>(TrunkHeight));
+ a_OtherBlocks.reserve(static_cast<size_t>(NumLeavesLayers * 25));
// The entire trunk, out of logs:
for (int i = TrunkHeight; i >= 0; --i)
@@ -843,7 +843,7 @@ void GetPineTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise
{
break;
}
- ASSERT((size_t)LayerSize < ARRAYCOUNT(BigOs));
+ ASSERT(static_cast<size_t>(LayerSize) < ARRAYCOUNT(BigOs));
PushCoordBlocks(a_BlockX, h, a_BlockZ, a_OtherBlocks, BigOs[LayerSize].Coords, BigOs[LayerSize].Count, E_BLOCK_LEAVES, E_META_LEAVES_CONIFER);
h--;
}
@@ -866,8 +866,8 @@ void GetSwampTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Nois
int Height = 3 + (a_Noise.IntNoise3DInt(a_BlockX + 32 * a_Seq, a_BlockY, a_BlockZ + 32 * a_Seq) / 8) % 3;
- a_LogBlocks.reserve(Height);
- a_OtherBlocks.reserve(2 * ARRAYCOUNT(BigO2) + 2 * ARRAYCOUNT(BigO3) + Height * ARRAYCOUNT(Vines) + 20);
+ a_LogBlocks.reserve(static_cast<size_t>(Height));
+ a_OtherBlocks.reserve(2 * ARRAYCOUNT(BigO2) + 2 * ARRAYCOUNT(BigO3) + static_cast<size_t>(Height) * ARRAYCOUNT(Vines) + 20);
for (int i = 0; i < Height; i++)
{
@@ -952,8 +952,8 @@ void GetLargeJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise &
int Height = 24 + (a_Noise.IntNoise3DInt(a_BlockX + 32 * a_Seq, a_BlockY, a_BlockZ + 32 * a_Seq) / 11) % 24;
- a_LogBlocks.reserve(Height * 4);
- a_OtherBlocks.reserve(2 * ARRAYCOUNT(BigO4) + ARRAYCOUNT(BigO3) + Height * ARRAYCOUNT(Vines) + 50);
+ a_LogBlocks.reserve(static_cast<size_t>(Height) * 4);
+ a_OtherBlocks.reserve(2 * ARRAYCOUNT(BigO4) + ARRAYCOUNT(BigO3) + static_cast<size_t>(Height) * ARRAYCOUNT(Vines) + 50);
for (int i = 0; i < Height; i++)
{
@@ -999,12 +999,12 @@ void GetSmallJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise &
int Height = 7 + (a_Noise.IntNoise3DInt(a_BlockX + 5 * a_Seq, a_BlockY, a_BlockZ + 5 * a_Seq) / 5) % 3;
- a_LogBlocks.reserve(Height);
+ a_LogBlocks.reserve(static_cast<size_t>(Height));
a_OtherBlocks.reserve(
2 * ARRAYCOUNT(BigO3) + // O3 layer, 2x
2 * ARRAYCOUNT(BigO2) + // O2 layer, 2x
ARRAYCOUNT(BigO1) + 1 + // Plus on the top
- Height * ARRAYCOUNT(Vines) + // Vines
+ static_cast<size_t>(Height) * ARRAYCOUNT(Vines) + // Vines
50 // some safety
);
diff --git a/src/Generating/UnderwaterBaseGen.cpp b/src/Generating/UnderwaterBaseGen.cpp
index dbc4aef1b..c5066ca1b 100644
--- a/src/Generating/UnderwaterBaseGen.cpp
+++ b/src/Generating/UnderwaterBaseGen.cpp
@@ -76,7 +76,7 @@ protected:
{
for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
{
- cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece());
+ const cPrefab & Prefab = static_cast<const cPrefab &>((*itr)->GetPiece());
Prefab.Draw(a_Chunk, *itr);
} // for itr - m_PlacedPieces[]
}
diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp
index 27146e757..488497ac1 100644
--- a/src/Generating/VillageGen.cpp
+++ b/src/Generating/VillageGen.cpp
@@ -93,7 +93,7 @@ public:
return 0;
}
- return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector);
+ return static_cast<const cPrefab &>(a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector);
}
};
@@ -141,7 +141,7 @@ public:
// If the central piece should be moved to ground, move it, and
// check all of its dependents and move those that are strictly connector-driven based on its new Y coord:
- if (((cPrefab &)m_Pieces[0]->GetPiece()).ShouldMoveToGround())
+ if (static_cast<const cPrefab &>(m_Pieces[0]->GetPiece()).ShouldMoveToGround())
{
int OrigPosY = m_Pieces[0]->GetCoords().y;
PlacePieceOnGround(*m_Pieces[0]);
@@ -197,7 +197,7 @@ protected:
m_HeightGen->GenHeightMap(a_Chunk.GetChunkX(), a_Chunk.GetChunkZ(), HeightMap);
for (cPlacedPieces::iterator itr = m_Pieces.begin(), end = m_Pieces.end(); itr != end; ++itr)
{
- cPrefab & Prefab = (cPrefab &)((*itr)->GetPiece());
+ const cPrefab & Prefab = static_cast<const cPrefab &>((*itr)->GetPiece());
if ((*itr)->GetPiece().GetSize().y == 1)
{
// It's a road, special handling (change top terrain blocks to m_RoadBlock)
@@ -319,7 +319,7 @@ protected:
{
if (
(a_PlacedPieces[i]->GetParent() == Pivot) && // It is a direct dependant of the pivot
- !((const cPrefab &)a_PlacedPieces[i]->GetPiece()).ShouldMoveToGround() // It attaches strictly by connectors
+ !(static_cast<const cPrefab &>(a_PlacedPieces[i]->GetPiece())).ShouldMoveToGround() // It attaches strictly by connectors
)
{
a_PlacedPieces[i]->MoveToGroundBy(a_HeightDifference);
@@ -389,8 +389,8 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_GridX, int a_Gr
BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL;
BLOCKTYPE WaterRoadBlock = E_BLOCK_PLANKS;
int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11;
- cVillagePiecePool * PlainsVillage = g_PlainsVillagePools[rnd % ARRAYCOUNT(g_PlainsVillagePools)];
- cVillagePiecePool * DesertVillage = g_DesertVillagePools[rnd % ARRAYCOUNT(g_DesertVillagePools)];
+ cVillagePiecePool * PlainsVillage = g_PlainsVillagePools[static_cast<size_t>(rnd) % ARRAYCOUNT(g_PlainsVillagePools)];
+ cVillagePiecePool * DesertVillage = g_DesertVillagePools[static_cast<size_t>(rnd) % ARRAYCOUNT(g_DesertVillagePools)];
for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++)
{
switch (Biomes[i])