summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockAnvil.h8
-rw-r--r--src/Blocks/BlockButton.h2
-rw-r--r--src/Blocks/BlockCocoaPod.h4
-rw-r--r--src/Blocks/BlockHopper.h2
-rw-r--r--src/Blocks/BlockLadder.h7
-rw-r--r--src/Blocks/BlockLeaves.h2
-rw-r--r--src/Blocks/BlockWallSign.h12
-rw-r--r--src/ChunkDef.h4
-rw-r--r--src/Defines.h21
-rw-r--r--src/Generating/BioGen.cpp32
-rw-r--r--src/Generating/BioGen.h8
-rw-r--r--src/Generating/ChunkDesc.cpp12
-rw-r--r--src/Generating/ChunkDesc.h4
-rw-r--r--src/Generating/CompoGenBiomal.cpp15
-rw-r--r--src/Generating/ComposableGenerator.cpp4
-rw-r--r--src/Generating/FinishGen.cpp16
-rw-r--r--src/Generating/HeiGen.cpp26
-rw-r--r--src/Generating/HeiGen.h2
-rw-r--r--src/Generating/MineShafts.cpp1
-rw-r--r--src/Generating/ProtIntGen.h286
-rw-r--r--src/HTTPServer/HTTPFormParser.cpp7
-rw-r--r--src/HTTPServer/HTTPServer.cpp4
-rw-r--r--src/Noise/Noise.cpp32
-rw-r--r--src/Noise/Noise.h4
-rw-r--r--src/OSSupport/File.cpp26
-rw-r--r--src/OSSupport/File.h6
-rw-r--r--src/Protocol/Packetizer.h2
-rw-r--r--src/Protocol/Protocol17x.cpp4
-rw-r--r--src/StringUtils.h4
-rw-r--r--src/World.h2
30 files changed, 286 insertions, 273 deletions
diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h
index abfa0f782..154394550 100644
--- a/src/Blocks/BlockAnvil.h
+++ b/src/Blocks/BlockAnvil.h
@@ -46,10 +46,10 @@ public:
switch (Direction)
{
- case 0: a_BlockMeta = 0x2 | Meta << 2; break;
- case 1: a_BlockMeta = 0x3 | Meta << 2; break;
- case 2: a_BlockMeta = 0x0 | Meta << 2; break;
- case 3: a_BlockMeta = 0x1 | Meta << 2; break;
+ case 0: a_BlockMeta = static_cast<NIBBLETYPE>(0x2 | Meta << 2); break;
+ case 1: a_BlockMeta = static_cast<NIBBLETYPE>(0x3 | Meta << 2); break;
+ case 2: a_BlockMeta = static_cast<NIBBLETYPE>(0x0 | Meta << 2); break;
+ case 3: a_BlockMeta = static_cast<NIBBLETYPE>(0x1 | Meta << 2); break;
default:
{
return false;
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index d24c7d952..d65d9722d 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -67,7 +67,7 @@ public:
case BLOCK_FACE_XM: return 0x2;
case BLOCK_FACE_XP: return 0x1;
case BLOCK_FACE_YM: return 0x0;
- default:
+ case BLOCK_FACE_NONE:
{
ASSERT(!"Unhandled block face!");
return 0x0;
diff --git a/src/Blocks/BlockCocoaPod.h b/src/Blocks/BlockCocoaPod.h
index 1b659d48f..50552c788 100644
--- a/src/Blocks/BlockCocoaPod.h
+++ b/src/Blocks/BlockCocoaPod.h
@@ -81,7 +81,9 @@ public:
case BLOCK_FACE_XM: return 3;
case BLOCK_FACE_XP: return 1;
case BLOCK_FACE_ZP: return 2;
- default:
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
{
ASSERT(!"Unknown face");
return 0;
diff --git a/src/Blocks/BlockHopper.h b/src/Blocks/BlockHopper.h
index 4a5d32dd5..06e2b0e9f 100644
--- a/src/Blocks/BlockHopper.h
+++ b/src/Blocks/BlockHopper.h
@@ -35,7 +35,7 @@ public:
case BLOCK_FACE_NORTH: a_BlockMeta = E_META_HOPPER_FACING_ZP; break;
case BLOCK_FACE_SOUTH: a_BlockMeta = E_META_HOPPER_FACING_ZM; break;
case BLOCK_FACE_WEST: a_BlockMeta = E_META_HOPPER_FACING_XP; break;
- default: a_BlockMeta = E_META_HOPPER_UNATTACHED; break;
+ case BLOCK_FACE_NONE: a_BlockMeta = E_META_HOPPER_UNATTACHED; break;
}
return true;
}
diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h
index ab3f55439..f49f1adc7 100644
--- a/src/Blocks/BlockLadder.h
+++ b/src/Blocks/BlockLadder.h
@@ -57,7 +57,12 @@ public:
case BLOCK_FACE_ZP: return 0x3;
case BLOCK_FACE_XM: return 0x4;
case BLOCK_FACE_XP: return 0x5;
- default: return 0x2;
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
+ {
+ return 0x2;
+ }
}
}
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index 4d4610fd8..5c9283979 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -59,7 +59,7 @@ public:
cItem(
E_BLOCK_SAPLING,
1,
- (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (4 + (a_BlockMeta & 0x01))
+ (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : static_cast<short>(4 + (a_BlockMeta & 0x01))
)
);
}
diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h
index b6599d033..9b90b78bf 100644
--- a/src/Blocks/BlockWallSign.h
+++ b/src/Blocks/BlockWallSign.h
@@ -55,11 +55,13 @@ public:
{
switch (a_Direction)
{
- case 0x2: return 0x2;
- case 0x3: return 0x3;
- case 0x4: return 0x4;
- case 0x5: return 0x5;
- default:
+ case BLOCK_FACE_ZM: return 0x2;
+ case BLOCK_FACE_ZP: return 0x3;
+ case BLOCK_FACE_XM: return 0x4;
+ case BLOCK_FACE_XP: return 0x5;
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YP:
+ case BLOCK_FACE_YM:
{
break;
}
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index 2bfa2949c..b03a03bff 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -190,7 +190,7 @@ public:
}
- inline static int GetHeight(const HeightMap & a_HeightMap, int a_X, int a_Z)
+ inline static HEIGHTTYPE GetHeight(const HeightMap & a_HeightMap, int a_X, int a_Z)
{
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width));
@@ -198,7 +198,7 @@ public:
}
- inline static void SetHeight(HeightMap & a_HeightMap, int a_X, int a_Z, unsigned char a_Height)
+ inline static void SetHeight(HeightMap & a_HeightMap, int a_X, int a_Z, HEIGHTTYPE a_Height)
{
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width));
diff --git a/src/Defines.h b/src/Defines.h
index 787eacab8..71288b430 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -238,7 +238,10 @@ inline eBlockFace MirrorBlockFaceY(eBlockFace a_BlockFace)
case BLOCK_FACE_XP: return BLOCK_FACE_XM;
case BLOCK_FACE_ZM: return BLOCK_FACE_ZP;
case BLOCK_FACE_ZP: return BLOCK_FACE_ZM;
- default: return a_BlockFace;
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
+ return a_BlockFace;
}
}
@@ -255,7 +258,10 @@ inline eBlockFace RotateBlockFaceCCW(eBlockFace a_BlockFace)
case BLOCK_FACE_XP: return BLOCK_FACE_ZM;
case BLOCK_FACE_ZM: return BLOCK_FACE_XM;
case BLOCK_FACE_ZP: return BLOCK_FACE_XP;
- default: return a_BlockFace;
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
+ return a_BlockFace;
}
}
@@ -271,7 +277,10 @@ inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace)
case BLOCK_FACE_XP: return BLOCK_FACE_ZP;
case BLOCK_FACE_ZM: return BLOCK_FACE_XP;
case BLOCK_FACE_ZP: return BLOCK_FACE_XM;
- default: return a_BlockFace;
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
+ return a_BlockFace;
}
}
@@ -285,7 +294,7 @@ inline eBlockFace ReverseBlockFace(eBlockFace a_BlockFace)
case BLOCK_FACE_YM: return BLOCK_FACE_YP;
case BLOCK_FACE_XM: return BLOCK_FACE_XP;
case BLOCK_FACE_ZM: return BLOCK_FACE_ZP;
- default: return a_BlockFace;
+ case BLOCK_FACE_NONE: return a_BlockFace;
}
}
@@ -436,7 +445,7 @@ inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBl
case BLOCK_FACE_ZP: a_BlockZ++; break;
case BLOCK_FACE_XP: a_BlockX++; break;
case BLOCK_FACE_XM: a_BlockX--; break;
- default:
+ case BLOCK_FACE_NONE:
{
LOGWARNING("%s: Unknown face: %d", __FUNCTION__, a_BlockFace);
ASSERT(!"AddFaceDirection(): Unknown face");
@@ -454,7 +463,7 @@ inline void AddFaceDirection(int & a_BlockX, int & a_BlockY, int & a_BlockZ, eBl
case BLOCK_FACE_ZP: a_BlockZ--; break;
case BLOCK_FACE_XP: a_BlockX--; break;
case BLOCK_FACE_XM: a_BlockX++; break;
- default:
+ case BLOCK_FACE_NONE:
{
LOGWARNING("%s: Unknown inv face: %d", __FUNCTION__, a_BlockFace);
ASSERT(!"AddFaceDirection(): Unknown face");
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index 867155ad2..2c6af27a4 100644
--- a/src/Generating/BioGen.cpp
+++ b/src/Generating/BioGen.cpp
@@ -49,18 +49,18 @@ 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_CacheOrder[i] = static_cast<size_t>(i);
m_CacheData[i].m_ChunkX = 0x7fffffff;
m_CacheData[i].m_ChunkZ = 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;
}
@@ -1121,7 +1121,7 @@ public:
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes) override
{
int vals[16 * 16];
- m_Gen->GetInts(a_ChunkX * cChunkDef::Width, a_ChunkZ * cChunkDef::Width, 16, 16, vals);
+ m_Gen->GetInts(static_cast<size_t>(a_ChunkX * cChunkDef::Width), static_cast<size_t>(a_ChunkZ * cChunkDef::Width), 16, 16, vals);
for (int z = 0; z < cChunkDef::Width; z++)
{
for (int x = 0; x < cChunkDef::Width; x++)
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/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index 4a5ac5a18..fe5182004 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 (unsigned char 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..8308aae41 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
diff --git a/src/Generating/CompoGenBiomal.cpp b/src/Generating/CompoGenBiomal.cpp
index 3140bd754..1385bd523 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
@@ -427,7 +430,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/FinishGen.cpp b/src/Generating/FinishGen.cpp
index 00b34bddd..af4056e8c 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -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);
}
}
@@ -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
@@ -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
}
@@ -1374,7 +1374,7 @@ eMonsterType cFinishGenPassiveMobs::GetRandomMob(cChunkDesc & a_ChunkDesc)
return mtInvalidType;
}
- int RandMob = (m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7) % ListOfSpawnables.size();
+ size_t RandMob = static_cast<size_t>((m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7)) % ListOfSpawnables.size();
auto MobIter = ListOfSpawnables.begin();
std::advance(MobIter, RandMob);
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index e34ffc57c..e44885135 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(static_cast<size_t>(a_ChunkX * cChunkDef::Width), static_cast<size_t>(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]));
}
}
//*/
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..61f29b762 100644
--- a/src/Generating/MineShafts.cpp
+++ b/src/Generating/MineShafts.cpp
@@ -781,7 +781,6 @@ 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;
diff --git a/src/Generating/ProtIntGen.h b/src/Generating/ProtIntGen.h
index 9e471e8bb..a7625731a 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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++)
+ size_t BaseZ = a_MinZ + 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(static_cast<int>(a_MinX + x), static_cast<int>(BaseZ)) / 7) % m_Range;
}
} // for z
}
@@ -146,14 +146,14 @@ public:
}
- virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ virtual void GetInts(size_t a_MinX, size_t 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++)
+ size_t BaseZ = a_MinZ + 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(static_cast<int>(a_MinX + x), static_cast<int>(BaseZ)) / 7);
a_Values[x + a_SizeX * z] = ((rnd % 100) < m_Threshold) ? ((rnd / 101) % bgLandOceanMax + 1) : 0;
}
}
@@ -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(size_t a_MinX, size_t 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 lowerMinX = a_MinX >> 1;
+ size_t lowerMinZ = a_MinZ >> 1;
+ 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(size_t a_MinX, size_t 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++)
+ size_t NoiseZ = a_MinZ + 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(static_cast<int>(a_MinX + x), static_cast<int>(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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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++)
+ size_t BaseZ = a_MinZ + 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(static_cast<int>(BaseZ), static_cast<int>(a_MinX + 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(static_cast<int>(a_MinX + x), static_cast<int>(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(size_t a_MinX, size_t 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++)
+ size_t NoiseZ = a_MinZ + 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(static_cast<int>(a_MinX + x), static_cast<int>(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(size_t a_MinX, size_t 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++)
+ size_t NoiseZ = a_MinZ + 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(static_cast<int>(a_MinX + x), static_cast<int>(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(size_t a_MinX, size_t 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++)
+ size_t NoiseZ = a_MinZ + 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(static_cast<int>(a_MinX + x), static_cast<int>(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(static_cast<int>(a_MinX + x), static_cast<int>(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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(static_cast<int>(a_MinX + x), static_cast<int>(a_MinZ + 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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
@@ -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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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(size_t a_MinX, size_t 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/HTTPServer/HTTPFormParser.cpp b/src/HTTPServer/HTTPFormParser.cpp
index 72872078b..77f98e43b 100644
--- a/src/HTTPServer/HTTPFormParser.cpp
+++ b/src/HTTPServer/HTTPFormParser.cpp
@@ -90,11 +90,6 @@ void cHTTPFormParser::Parse(const char * a_Data, size_t a_Size)
m_MultipartParser->Parse(a_Data, a_Size);
break;
}
- default:
- {
- ASSERT(!"Unhandled form kind");
- break;
- }
}
}
@@ -113,7 +108,7 @@ bool cHTTPFormParser::Finish(void)
ParseFormUrlEncoded();
break;
}
- default:
+ case fpkMultipart:
{
// Nothing needed for other formats
break;
diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp
index 71f974a97..2eb8bf1ff 100644
--- a/src/HTTPServer/HTTPServer.cpp
+++ b/src/HTTPServer/HTTPServer.cpp
@@ -112,7 +112,9 @@ class cDebugCallbacks :
// TODO
}
-} g_DebugCallbacks;
+};
+
+static cDebugCallbacks g_DebugCallbacks;
diff --git a/src/Noise/Noise.cpp b/src/Noise/Noise.cpp
index d11c47bc2..703ec3d30 100644
--- a/src/Noise/Noise.cpp
+++ b/src/Noise/Noise.cpp
@@ -112,22 +112,22 @@ public:
////////////////////////////////////////////////////////////////////////////////
// Globals:
-void Debug3DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase, NOISE_DATATYPE a_Coeff)
+void Debug3DNoise(const NOISE_DATATYPE * a_Noise, size_t a_SizeX, size_t a_SizeY, size_t a_SizeZ, const AString & a_FileNameBase, NOISE_DATATYPE a_Coeff)
{
const int BUF_SIZE = 512;
ASSERT(a_SizeX <= BUF_SIZE); // Just stretch it, if needed
// Save in XY cuts:
cFile f1;
- if (f1.Open(Printf("%s_XY (%d).grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
+ if (f1.Open(Printf("%s_XY (" SIZE_T_FMT ").grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
{
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- for (int y = 0; y < a_SizeY; y++)
+ for (size_t y = 0; y < a_SizeY; y++)
{
- int idx = y * a_SizeX + z * a_SizeX * a_SizeY;
+ size_t idx = y * a_SizeX + z * a_SizeX * a_SizeY;
unsigned char buf[BUF_SIZE];
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
buf[x] = static_cast<unsigned char>(Clamp((int)(128 + a_Coeff * a_Noise[idx++]), 0, 255));
}
@@ -140,15 +140,15 @@ void Debug3DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, int
} // if (XY file open)
cFile f2;
- if (f2.Open(Printf("%s_XZ (%d).grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
+ if (f2.Open(Printf("%s_XZ (" SIZE_T_FMT ").grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
{
- for (int y = 0; y < a_SizeY; y++)
+ for (size_t y = 0; y < a_SizeY; y++)
{
- for (int z = 0; z < a_SizeZ; z++)
+ for (size_t z = 0; z < a_SizeZ; z++)
{
- int idx = y * a_SizeX + z * a_SizeX * a_SizeY;
+ size_t idx = y * a_SizeX + z * a_SizeX * a_SizeY;
unsigned char buf[BUF_SIZE];
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
buf[x] = static_cast<unsigned char>(Clamp((int)(128 + a_Coeff * a_Noise[idx++]), 0, 255));
}
@@ -165,19 +165,19 @@ void Debug3DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, int
-void Debug2DNoise(const NOISE_DATATYPE * a_Noise, int a_SizeX, int a_SizeY, const AString & a_FileNameBase, NOISE_DATATYPE a_Coeff)
+void Debug2DNoise(const NOISE_DATATYPE * a_Noise, size_t a_SizeX, size_t a_SizeY, const AString & a_FileNameBase, NOISE_DATATYPE a_Coeff)
{
const int BUF_SIZE = 512;
ASSERT(a_SizeX <= BUF_SIZE); // Just stretch it, if needed
cFile f1;
- if (f1.Open(Printf("%s (%d).grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
+ if (f1.Open(Printf("%s (" SIZE_T_FMT ").grab", a_FileNameBase.c_str(), a_SizeX), cFile::fmWrite))
{
- for (int y = 0; y < a_SizeY; y++)
+ for (size_t y = 0; y < a_SizeY; y++)
{
- int idx = y * a_SizeX;
+ size_t idx = y * a_SizeX;
unsigned char buf[BUF_SIZE];
- for (int x = 0; x < a_SizeX; x++)
+ for (size_t x = 0; x < a_SizeX; x++)
{
buf[x] = static_cast<unsigned char>(Clamp((int)(128 + a_Coeff * a_Noise[idx++]), 0, 255));
}
diff --git a/src/Noise/Noise.h b/src/Noise/Noise.h
index 323194bfd..5df32d3dc 100644
--- a/src/Noise/Noise.h
+++ b/src/Noise/Noise.h
@@ -288,11 +288,11 @@ NOISE_DATATYPE cNoise::LinearInterpolate(NOISE_DATATYPE a_A, NOISE_DATATYPE a_B,
/** Exports the noise array into a file.
a_Coeff specifies the value that each array value is multiplied by before being converted into a byte. */
-extern void Debug2DNoise(const NOISE_DATATYPE * a_Array, int a_SizeX, int a_SizeY, const AString & a_FileNameBase, NOISE_DATATYPE a_Coeff = 32);
+extern void Debug2DNoise(const NOISE_DATATYPE * a_Array, size_t a_SizeX, size_t a_SizeY, const AString & a_FileNameBase, NOISE_DATATYPE a_Coeff = 32);
/** Exports the noise array into a set of files, ordered by XY and XZ.
a_Coeff specifies the value that each array value is multiplied by before being converted into a byte. */
-extern void Debug3DNoise(const NOISE_DATATYPE * a_Array, int a_SizeX, int a_SizeY, int a_SizeZ, const AString & a_FileNameBase, NOISE_DATATYPE a_Coeff = 32);
+extern void Debug3DNoise(const NOISE_DATATYPE * a_Array, size_t a_SizeX, size_t a_SizeY, size_t a_SizeZ, const AString & a_FileNameBase, NOISE_DATATYPE a_Coeff = 32);
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp
index 43105b230..53f7c4afe 100644
--- a/src/OSSupport/File.cpp
+++ b/src/OSSupport/File.cpp
@@ -201,7 +201,7 @@ int cFile::Seek (int iPosition)
-int cFile::Tell (void) const
+ssize_t cFile::Tell (void) const
{
ASSERT(IsOpen());
@@ -210,14 +210,14 @@ int cFile::Tell (void) const
return -1;
}
- return (int)ftell(m_File);
+ return ftell(m_File);
}
-int cFile::GetSize(void) const
+ssize_t cFile::GetSize(void) const
{
ASSERT(IsOpen());
@@ -226,7 +226,7 @@ int cFile::GetSize(void) const
return -1;
}
- int CurPos = Tell();
+ ssize_t CurPos = Tell();
if (CurPos < 0)
{
return -1;
@@ -235,7 +235,7 @@ int cFile::GetSize(void) const
{
return -1;
}
- int res = Tell();
+ ssize_t res = Tell();
if (fseek(m_File, (long)CurPos, SEEK_SET) != 0)
{
return -1;
@@ -256,7 +256,19 @@ int cFile::ReadRestOfFile(AString & a_Contents)
return -1;
}
- size_t DataSize = GetSize() - Tell();
+ ssize_t TotalSize = GetSize();
+ if (TotalSize < 0)
+ {
+ return -1;
+ }
+
+ ssize_t Position = Tell();
+ if (Position < 0)
+ {
+ return -1;
+ }
+
+ auto DataSize = static_cast<size_t>(TotalSize - Position);
// HACK: This depends on the internal knowledge that AString's data() function returns the internal buffer directly
a_Contents.assign(DataSize, '\0');
@@ -349,7 +361,7 @@ bool cFile::IsFile(const AString & a_Path)
-int cFile::GetSize(const AString & a_FileName)
+ssize_t cFile::GetSize(const AString & a_FileName)
{
struct stat st;
if (stat(a_FileName.c_str(), &st) == 0)
diff --git a/src/OSSupport/File.h b/src/OSSupport/File.h
index 1b5e71a17..e92da4354 100644
--- a/src/OSSupport/File.h
+++ b/src/OSSupport/File.h
@@ -90,10 +90,10 @@ public:
int Seek (int iPosition);
/** Returns the current position (bytes from file start) or -1 for failure; asserts if not open */
- int Tell (void) const;
+ ssize_t Tell (void) const;
/** Returns the size of file, in bytes, or -1 for failure; asserts if not open */
- int GetSize(void) const;
+ ssize_t GetSize(void) const;
/** Reads the file from current position till EOF into an AString; returns the number of bytes read or -1 for error */
int ReadRestOfFile(AString & a_Contents);
@@ -119,7 +119,7 @@ public:
static bool IsFile(const AString & a_Path);
/** Returns the size of the file, or a negative number on error */
- static int GetSize(const AString & a_FileName);
+ static ssize_t GetSize(const AString & a_FileName);
/** Creates a new folder with the specified name. Returns true if successful. Path may be relative or absolute */
static bool CreateFolder(const AString & a_FolderPath);
diff --git a/src/Protocol/Packetizer.h b/src/Protocol/Packetizer.h
index 7f5e9c2c3..efed9c7a9 100644
--- a/src/Protocol/Packetizer.h
+++ b/src/Protocol/Packetizer.h
@@ -58,7 +58,7 @@ public:
}
- inline void WriteBEUInt16(short a_Value)
+ inline void WriteBEUInt16(UInt16 a_Value)
{
VERIFY(m_Out.WriteBEUInt16(a_Value));
}
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 799c021f3..0540ae9e1 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -1023,8 +1023,8 @@ void cProtocol172::SendExperience (void)
cPacketizer Pkt(*this, 0x1f); // Experience Packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEFloat(Player->GetXpPercentage());
- Pkt.WriteBEInt16(static_cast<UInt16>(std::max<int>(Player->GetXpLevel(), std::numeric_limits<UInt16>::max())));
- Pkt.WriteBEInt16(static_cast<UInt16>(std::max<int>(Player->GetCurrentXp(), std::numeric_limits<UInt16>::max())));
+ Pkt.WriteBEInt16(static_cast<Int16>(std::max<int>(Player->GetXpLevel(), std::numeric_limits<Int16>::max())));
+ Pkt.WriteBEInt16(static_cast<Int16>(std::max<int>(Player->GetCurrentXp(), std::numeric_limits<Int16>::max())));
}
diff --git a/src/StringUtils.h b/src/StringUtils.h
index b5fc58a2d..8f67d8031 100644
--- a/src/StringUtils.h
+++ b/src/StringUtils.h
@@ -158,7 +158,7 @@ bool StringToInteger(const AString & a_str, T & a_Num)
return false;
}
result *= 10;
- T digit = a_str[i] - '0';
+ T digit = static_cast<T>(a_str[i] - '0');
if (std::numeric_limits<T>::max() - digit < result)
{
return false;
@@ -179,7 +179,7 @@ bool StringToInteger(const AString & a_str, T & a_Num)
return false;
}
result *= 10;
- T digit = a_str[i] - '0';
+ T digit = static_cast<T>(a_str[i] - '0');
if (std::numeric_limits<T>::min() + digit > result)
{
return false;
diff --git a/src/World.h b/src/World.h
index 6c0548ae6..d29a89e65 100644
--- a/src/World.h
+++ b/src/World.h
@@ -216,7 +216,7 @@ public:
// Broadcast respective packets to all clients of the chunk where the event is taking place
// (Please keep these alpha-sorted)
void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle);
- void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
+ void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr); // tolua_export
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude