From 8610d45ef18f075e7fa207732233ddbd69bb604b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Dec 2013 16:01:34 +0100 Subject: [PATCH] Fixed compiler warning when iterating over a fixed array of items (ARRAYCOUNT). --- src/BlockEntities/HopperEntity.cpp | 4 ++-- src/BlockEntities/SignEntity.cpp | 4 ++-- src/BlockID.cpp | 12 ++++++------ src/Blocks/BlockCactus.h | 2 +- src/Blocks/BlockPortal.h | 4 ++-- src/Blocks/BlockSugarcane.h | 2 +- src/Blocks/BlockVine.h | 2 +- src/BoundingBox.cpp | 2 +- src/ChunkMap.cpp | 24 ++++++++++++------------ src/ChunkSender.cpp | 2 +- src/Enchantments.cpp | 2 +- src/Entities/Entity.cpp | 2 +- src/Generating/BioGen.cpp | 6 +++--- src/Generating/ChunkDesc.cpp | 4 ++-- src/Generating/DistortedHeightmap.cpp | 2 +- src/Generating/EndGen.cpp | 2 +- src/Generating/FinishGen.cpp | 6 +++--- src/Generating/HeiGen.cpp | 4 ++-- src/Generating/MineShafts.cpp | 2 +- src/Generating/Noise3DGenerator.cpp | 8 ++++---- src/Generating/StructGen.cpp | 8 ++++++-- src/LinearInterpolation.cpp | 2 +- src/Mobs/Monster.cpp | 2 +- src/Simulator/DelayedFluidSimulator.cpp | 2 +- src/Simulator/FireSimulator.cpp | 6 +++--- src/Simulator/FloodyFluidSimulator.cpp | 4 ++-- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 6 +++--- 28 files changed, 66 insertions(+), 62 deletions(-) diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 21212a363..0aca3209f 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -290,7 +290,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) {0, 1}, {0, -1}, } ; - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { int x = m_RelX + Coords[i].x; int z = m_RelZ + Coords[i].z; @@ -447,7 +447,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block {0, 1}, {0, -1}, } ; - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { int x = m_RelX + Coords[i].x; int z = m_RelZ + Coords[i].z; diff --git a/src/BlockEntities/SignEntity.cpp b/src/BlockEntities/SignEntity.cpp index df8774377..97fed0f04 100644 --- a/src/BlockEntities/SignEntity.cpp +++ b/src/BlockEntities/SignEntity.cpp @@ -45,7 +45,7 @@ void cSignEntity::SetLines(const AString & a_Line1, const AString & a_Line2, con void cSignEntity::SetLine(int a_Index, const AString & a_Line) { - if ((a_Index < 0) || (a_Index >= ARRAYCOUNT(m_Line))) + if ((a_Index < 0) || (a_Index >= (int)ARRAYCOUNT(m_Line))) { LOGWARNING("%s: setting a non-existent line %d (value \"%s\"", __FUNCTION__, a_Index, a_Line.c_str()); return; @@ -59,7 +59,7 @@ void cSignEntity::SetLine(int a_Index, const AString & a_Line) AString cSignEntity::GetLine(int a_Index) const { - if ((a_Index < 0) || (a_Index >= ARRAYCOUNT(m_Line))) + if ((a_Index < 0) || (a_Index >= (int)ARRAYCOUNT(m_Line))) { LOGWARNING("%s: requesting a non-existent line %d", __FUNCTION__, a_Index); return ""; diff --git a/src/BlockID.cpp b/src/BlockID.cpp index 708618d25..2ca9dc49a 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -353,7 +353,7 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) {biMesaPlateauM, "MesaPlateauM"}, } ; - for (int i = 0; i < ARRAYCOUNT(BiomeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(BiomeMap); i++) { if (NoCaseCompare(BiomeMap[i].m_String, a_BiomeString) == 0) { @@ -403,7 +403,7 @@ int StringToMobType(const AString & a_MobString) {cMonster::mtIronGolem, "IronGolem"}, {cMonster::mtVillager, "Villager"}, }; - for (int i = 0; i < ARRAYCOUNT(MobMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++) { if (NoCaseCompare(MobMap[i].m_String, a_MobString) == 0) { @@ -442,7 +442,7 @@ eDimension StringToDimension(const AString & a_DimensionString) { dimEnd, "End"}, { dimEnd, "Sky"}, // Old name for End } ; - for (int i = 0; i < ARRAYCOUNT(DimensionMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++) { if (NoCaseCompare(DimensionMap[i].m_String, a_DimensionString) == 0) { @@ -549,7 +549,7 @@ eDamageType StringToDamageType(const AString & a_DamageTypeString) { dtFireContact, "dtInFire"}, { dtAdmin, "dtPlugin"}, } ; - for (int i = 0; i < ARRAYCOUNT(DamageTypeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(DamageTypeMap); i++) { if (NoCaseCompare(DamageTypeMap[i].m_String, a_DamageTypeString) == 0) { @@ -594,14 +594,14 @@ public: memset(g_BlockIsTorchPlaceable, 0x00, sizeof(g_BlockIsTorchPlaceable)); // Setting bools to true must be done manually, see http://forum.mc-server.org/showthread.php?tid=629&pid=5415#pid5415 - for (int i = 0; i < ARRAYCOUNT(g_BlockIsSnowable); i++) + for (size_t i = 0; i < ARRAYCOUNT(g_BlockIsSnowable); i++) { g_BlockIsSnowable[i] = true; } memset(g_BlockRequiresSpecialTool, 0x00, sizeof(g_BlockRequiresSpecialTool)); // Set all blocks to false // Setting bools to true must be done manually, see http://forum.mc-server.org/showthread.php?tid=629&pid=5415#pid5415 - for (int i = 0; i < ARRAYCOUNT(g_BlockIsSolid); i++) + for (size_t i = 0; i < ARRAYCOUNT(g_BlockIsSolid); i++) { g_BlockIsSolid[i] = true; } diff --git a/src/Blocks/BlockCactus.h b/src/Blocks/BlockCactus.h index 7a9088178..f77df5e42 100644 --- a/src/Blocks/BlockCactus.h +++ b/src/Blocks/BlockCactus.h @@ -48,7 +48,7 @@ public: { 0, -1}, { 0, 1}, } ; - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h index c56f0cbc8..d88d14fc9 100644 --- a/src/Blocks/BlockPortal.h +++ b/src/Blocks/BlockPortal.h @@ -61,7 +61,7 @@ public: {-1, 0, 0}, } ; - for (int i = 0; i < ARRAYCOUNT(PortalCheck); i++) + for (size_t i = 0; i < ARRAYCOUNT(PortalCheck); i++) { BLOCKTYPE Block; a_Chunk.UnboundedRelGetBlockType(a_RelX + PortalCheck[i].x, a_RelY + PortalCheck[i].y, a_RelZ + PortalCheck[i].z, Block); @@ -86,7 +86,7 @@ public: { 0, 0, 1}, } ; - for (int i = 0; i < ARRAYCOUNT(PortalCheck); i++) + for (size_t i = 0; i < ARRAYCOUNT(PortalCheck); i++) { BLOCKTYPE Block; a_Chunk.UnboundedRelGetBlockType(a_RelX + PortalCheck[i].x, a_RelY + PortalCheck[i].y, a_RelZ + PortalCheck[i].z, Block); diff --git a/src/Blocks/BlockSugarcane.h b/src/Blocks/BlockSugarcane.h index 02d7a2fe4..9cff94800 100644 --- a/src/Blocks/BlockSugarcane.h +++ b/src/Blocks/BlockSugarcane.h @@ -47,7 +47,7 @@ public: { 0, 1}, } ; a_RelY -= 1; - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h index 2c9f67cab..60aaa9e4b 100644 --- a/src/Blocks/BlockVine.h +++ b/src/Blocks/BlockVine.h @@ -89,7 +89,7 @@ public: { 1, 0, 8}, // east, XP } ; int res = 0; - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp index 02602992e..d0943d42a 100644 --- a/src/BoundingBox.cpp +++ b/src/BoundingBox.cpp @@ -30,7 +30,7 @@ public: Vector3d(1.999, 0, 1.5), Vector3d(1.999, 4, 1.5), // Should intersect at 0.25, face 0 (YM) Vector3d(2.001, 0, 1.5), Vector3d(2.001, 4, 1.5), // Should not intersect } ; - for (int i = 0; i < ARRAYCOUNT(LineDefs) / 2; i++) + for (size_t i = 0; i < ARRAYCOUNT(LineDefs) / 2; i++) { double LineCoeff; char Face; diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 53b595545..c67d8e2e8 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2397,7 +2397,7 @@ cChunkMap::cChunkLayer::cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Pa cChunkMap::cChunkLayer::~cChunkLayer() { - for (int i = 0; i < ARRAYCOUNT(m_Chunks); ++i) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); ++i) { delete m_Chunks[i]; m_Chunks[i] = NULL; // // Must zero out, because further chunk deletions query the chunkmap for entities and that would touch deleted data @@ -2457,7 +2457,7 @@ cChunk * cChunkMap::cChunkLayer::FindChunk(int a_ChunkX, int a_ChunkZ) void cChunkMap::cChunkLayer::CollectMobCensus(cMobCensus& a_ToFill) { - for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++) { // We do count every Mobs in the world. But we are assuming that every chunk not loaded by any client // doesn't affect us. Normally they should not have mobs because every "too far" mobs despawn @@ -2476,7 +2476,7 @@ void cChunkMap::cChunkLayer::CollectMobCensus(cMobCensus& a_ToFill) void cChunkMap::cChunkLayer::SpawnMobs(cMobSpawner& a_MobSpawner) { - for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++) { // We only spawn close to players if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->HasAnyClients()) @@ -2490,7 +2490,7 @@ void cChunkMap::cChunkLayer::SpawnMobs(cMobSpawner& a_MobSpawner) void cChunkMap::cChunkLayer::Tick(float a_Dt) { - for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++) { // Only tick chunks that are valid and have clients: if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->HasAnyClients()) @@ -2506,7 +2506,7 @@ void cChunkMap::cChunkLayer::Tick(float a_Dt) void cChunkMap::cChunkLayer::RemoveClient(cClientHandle * a_Client) { - for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++) { if (m_Chunks[i] != NULL) { @@ -2522,7 +2522,7 @@ void cChunkMap::cChunkLayer::RemoveClient(cClientHandle * a_Client) bool cChunkMap::cChunkLayer::ForEachEntity(cEntityCallback & a_Callback) { // Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true - for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++) { if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid()) { @@ -2542,7 +2542,7 @@ bool cChunkMap::cChunkLayer::ForEachEntity(cEntityCallback & a_Callback) bool cChunkMap::cChunkLayer::DoWithEntityByID(int a_EntityID, cEntityCallback & a_Callback, bool & a_CallbackReturn) { // Calls the callback if the entity with the specified ID is found, with the entity object as the callback param. Returns true if entity found. - for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++) { if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid()) { @@ -2561,7 +2561,7 @@ bool cChunkMap::cChunkLayer::DoWithEntityByID(int a_EntityID, cEntityCallback & bool cChunkMap::cChunkLayer::HasEntity(int a_EntityID) { - for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++) { if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid()) { @@ -2581,7 +2581,7 @@ bool cChunkMap::cChunkLayer::HasEntity(int a_EntityID) int cChunkMap::cChunkLayer::GetNumChunksLoaded(void) const { int NumChunks = 0; - for ( int i = 0; i < ARRAYCOUNT(m_Chunks); ++i ) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); ++i) { if (m_Chunks[i] != NULL) { @@ -2599,7 +2599,7 @@ void cChunkMap::cChunkLayer::GetChunkStats(int & a_NumChunksValid, int & a_NumCh { int NumValid = 0; int NumDirty = 0; - for ( int i = 0; i < ARRAYCOUNT(m_Chunks); ++i ) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); ++i) { if (m_Chunks[i] == NULL) { @@ -2622,7 +2622,7 @@ void cChunkMap::cChunkLayer::GetChunkStats(int & a_NumChunksValid, int & a_NumCh void cChunkMap::cChunkLayer::Save(void) { cWorld * World = m_Parent->GetWorld(); - for (int i = 0; i < ARRAYCOUNT(m_Chunks); ++i) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); ++i) { if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->IsDirty()) { @@ -2637,7 +2637,7 @@ void cChunkMap::cChunkLayer::Save(void) void cChunkMap::cChunkLayer::UnloadUnusedChunks(void) { - for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++) { if ( (m_Chunks[i] != NULL) && // Is valid diff --git a/src/ChunkSender.cpp b/src/ChunkSender.cpp index 005cfe29d..7d1ef73a0 100644 --- a/src/ChunkSender.cpp +++ b/src/ChunkSender.cpp @@ -275,7 +275,7 @@ void cChunkSender::Entity(cEntity * a_Entity) void cChunkSender::BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) { - for (int i = 0; i < ARRAYCOUNT(m_BiomeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_BiomeMap); i++) { if ((*a_BiomeMap)[i] < 255) { diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp index 6b53d0b52..95ca201f0 100644 --- a/src/Enchantments.cpp +++ b/src/Enchantments.cpp @@ -181,7 +181,7 @@ int cEnchantments::StringToEnchantmentID(const AString & a_EnchantmentName) { enchLuckOfTheSea, "LuckOfTheSea"}, { enchLure, "Lure"}, } ; - for (int i = 0; i < ARRAYCOUNT(EnchantmentNames); i++) + for (size_t i = 0; i < ARRAYCOUNT(EnchantmentNames); i++) { if (NoCaseCompare(EnchantmentNames[i].m_Name, a_EnchantmentName) == 0) { diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 7721d58b3..32ee7f2bd 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -574,7 +574,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) } ; bool IsNoAirSurrounding = true; - for (int i = 0; i < ARRAYCOUNT(gCrossCoords); i++) + for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) { if (!NextChunk->UnboundedRelGetBlockType(RelBlockX + gCrossCoords[i].x, BlockY, RelBlockZ + gCrossCoords[i].z, GotBlock)) { diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 98999dee9..f89b1800d 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -83,7 +83,7 @@ cBiomeGen * cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a void cBioGenConstant::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) { - for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) { a_BiomeMap[i] = m_Biome; } @@ -277,7 +277,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) biJungleHills, } ; m_Biomes.reserve(ARRAYCOUNT(Biomes)); - for (int i = 0; i < ARRAYCOUNT(Biomes); i++) + for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) { m_Biomes.push_back(Biomes[i]); } @@ -655,7 +655,7 @@ void cBioGenMultiStepMap::BuildTemperatureHumidityMaps(int a_ChunkX, int a_Chunk LinearUpscale2DArrayInPlace(HumidityMap, 17, 17, 8, 8); // Re-map into integral values in [0 .. 255] range: - for (int idx = 0; idx < ARRAYCOUNT(a_TemperatureMap); idx++) + for (size_t idx = 0; idx < ARRAYCOUNT(a_TemperatureMap); idx++) { a_TemperatureMap[idx] = std::max(0, std::min(255, (int)(128 + TemperatureMap[idx] * 128))); a_HumidityMap[idx] = std::max(0, std::min(255, (int)(128 + HumidityMap[idx] * 128))); diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp index 6050430fd..af1a8a6c7 100644 --- a/src/Generating/ChunkDesc.cpp +++ b/src/Generating/ChunkDesc.cpp @@ -371,7 +371,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const { HEIGHTTYPE MaxHeight = m_HeightMap[0]; - for (unsigned int i = 1; i < ARRAYCOUNT(m_HeightMap); i++) + for (size_t i = 1; i < ARRAYCOUNT(m_HeightMap); i++) { if (m_HeightMap[i] > MaxHeight) { @@ -565,7 +565,7 @@ cBlockEntity * cChunkDesc::GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ) void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas) { const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas(); - for (unsigned int i = 0; i < ARRAYCOUNT(a_DestMetas); i++) + for (size_t i = 0; i < ARRAYCOUNT(a_DestMetas); i++) { a_DestMetas[i] = AreaMetas[2 * i] | (AreaMetas[2 * i + 1] << 4); } diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index c32a3bf43..342a4483f 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -612,7 +612,7 @@ void cDistortedHeightmap::GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_R // For each biome type that has a nonzero count, calc its amps and add it: NOISE_DATATYPE AmpX = 0; NOISE_DATATYPE AmpZ = 0; - for (unsigned int i = 0; i < ARRAYCOUNT(BiomeCounts); i++) + for (size_t i = 0; i < ARRAYCOUNT(BiomeCounts); i++) { if (BiomeCounts[i] <= 0) { diff --git a/src/Generating/EndGen.cpp b/src/Generating/EndGen.cpp index 1fa0fa121..f466039b9 100644 --- a/src/Generating/EndGen.cpp +++ b/src/Generating/EndGen.cpp @@ -151,7 +151,7 @@ void cEndGen::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_ { if (IsChunkOutsideRange(a_ChunkX, a_ChunkZ)) { - for (unsigned int i = 0; i < ARRAYCOUNT(a_HeightMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(a_HeightMap); i++) { a_HeightMap[i] = 0; } diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 8899e4bd0..866551e8a 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -271,7 +271,7 @@ void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc) int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap) { int res = 0; - for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) { if (a_BiomeMap[i] == m_Biome) { @@ -469,7 +469,7 @@ void cFinishGenPreSimulator::StationarizeFluid( {0, -1, 0} } ; BLOCKTYPE BlockToSet = a_StationaryFluid; // By default, don't simulate this block - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { if ((y == 0) && (Coords[i].y < 0)) { @@ -635,7 +635,7 @@ bool cFinishGenFluidSprings::TryPlaceSpring(cChunkDesc & a_ChunkDesc, int x, int { 0, 0, 1}, } ; int NumAirNeighbors = 0; - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { switch (a_ChunkDesc.GetBlockType(x + Coords[i].x, y + Coords[i].y, z + Coords[i].z)) { diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index ea6051371..2bf641089 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -18,7 +18,7 @@ void cHeiGenFlat::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) { - for (int i = 0; i < ARRAYCOUNT(a_HeightMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(a_HeightMap); i++) { a_HeightMap[i] = m_Height; } @@ -421,7 +421,7 @@ NOISE_DATATYPE cHeiGenBiomal::GetHeightAt(int a_RelX, int a_RelZ, int a_ChunkX, NOISE_DATATYPE Height = 0; int BlockX = a_ChunkX * cChunkDef::Width + a_RelX; int BlockZ = a_ChunkZ * cChunkDef::Width + a_RelZ; - for (int i = 0; i < ARRAYCOUNT(BiomeCounts); i++) + for (size_t i = 0; i < ARRAYCOUNT(BiomeCounts); i++) { if (BiomeCounts[i] == 0) { diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index f42240e55..cc39cef7b 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -1035,7 +1035,7 @@ void cMineShaftCrossing::AppendBranches(int a_RecursionLevel, cNoise & a_Noise) { 5, 5, 2, dirXP}, { 2, 5, 5, dirZP}, } ; - for (unsigned int i = 0; i < ARRAYCOUNT(Exits); i++) + for (size_t i = 0; i < ARRAYCOUNT(Exits); i++) { if (m_BoundingBox.p1.y + Exits[i].y >= m_BoundingBox.p2.y) { diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp index 0c68957c0..2511bb656 100644 --- a/src/Generating/Noise3DGenerator.cpp +++ b/src/Generating/Noise3DGenerator.cpp @@ -30,7 +30,7 @@ public: void DoTest1(void) { float In[3 * 3 * 3]; - for (int i = 0; i < ARRAYCOUNT(In); i++) + for (size_t i = 0; i < ARRAYCOUNT(In); i++) { In[i] = (float)(i % 5); } @@ -44,7 +44,7 @@ public: void DoTest2(void) { float In[3 * 3]; - for (int i = 0; i < ARRAYCOUNT(In); i++) + for (size_t i = 0; i < ARRAYCOUNT(In); i++) { In[i] = (float)(i % 5); } @@ -170,7 +170,7 @@ void cNoise3DGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile) void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) { - for (unsigned int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) { a_BiomeMap[i] = biExtremeHills; } @@ -236,7 +236,7 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT // Precalculate a "height" array: NOISE_DATATYPE Height[DIM_X * DIM_Z]; // Output for the cubic noise heightmap ("source") m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 25, EndX / 25, StartZ / 25, EndZ / 25); - for (unsigned int i = 0; i < ARRAYCOUNT(Height); i++) + for (size_t i = 0; i < ARRAYCOUNT(Height); i++) { Height[i] = abs(Height[i]) * m_HeightAmplification + 1; } diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp index 504c26238..da6227801 100644 --- a/src/Generating/StructGen.cpp +++ b/src/Generating/StructGen.cpp @@ -467,7 +467,7 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a cChunkDef::HeightMap HeightMap; m_HeiGen.GenHeightMap(a_ChunkX, a_ChunkZ, HeightMap); HEIGHTTYPE MinHeight = HeightMap[0]; - for (int i = 1; i < ARRAYCOUNT(HeightMap); i++) + for (size_t i = 1; i < ARRAYCOUNT(HeightMap); i++) { if (HeightMap[i] < MinHeight) { @@ -646,7 +646,7 @@ void cStructGenDirectOverhangs::GenStructures(cChunkDesc & a_ChunkDesc) bool cStructGenDirectOverhangs::HasWantedBiome(cChunkDesc & a_ChunkDesc) const { cChunkDef::BiomeMap & Biomes = a_ChunkDesc.GetBiomeMap(); - for (int i = 0; i < ARRAYCOUNT(Biomes); i++) + for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++) { switch (Biomes[i]) { @@ -655,6 +655,10 @@ bool cStructGenDirectOverhangs::HasWantedBiome(cChunkDesc & a_ChunkDesc) const { return true; } + default: + { + break; + } } } // for i return false; diff --git a/src/LinearInterpolation.cpp b/src/LinearInterpolation.cpp index d4975418b..9455f3e4f 100644 --- a/src/LinearInterpolation.cpp +++ b/src/LinearInterpolation.cpp @@ -39,7 +39,7 @@ public: void DoTest2(void) { float In[3 * 3 * 3]; - for (int i = 0; i < ARRAYCOUNT(In); i++) + for (size_t i = 0; i < ARRAYCOUNT(In); i++) { In[i] = (float)(i % 5); } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 0e2da942d..606e93408 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -571,7 +571,7 @@ void cMonster::SetSightDistance(float sd) AString cMonster::MobTypeToString(cMonster::eType a_MobType) { // Mob types aren't sorted, so we need to search linearly: - for (int i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++) + for (size_t i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++) { if (g_MobTypeNames[i].m_Type == a_MobType) { diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp index a4645ca09..3d2170e44 100644 --- a/src/Simulator/DelayedFluidSimulator.cpp +++ b/src/Simulator/DelayedFluidSimulator.cpp @@ -137,7 +137,7 @@ void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_Chunk cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_SimSlotNum]; // Simulate all the blocks in the scheduled slot: - for (int i = 0; i < ARRAYCOUNT(Slot.m_Blocks); i++) + for (size_t i = 0; i < ARRAYCOUNT(Slot.m_Blocks); i++) { cCoordWithIntVector & Blocks = Slot.m_Blocks[i]; if (Blocks.empty()) diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 03e4f6e45..d7c5ab3b4 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -241,7 +241,7 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in IsBlockBelowSolid = g_BlockIsSolid[BlockBelow]; } - for (int i = 0; i < ARRAYCOUNT(gCrossCoords); i++) + for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++) { BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; @@ -317,7 +317,7 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int void cFireSimulator::RemoveFuelNeighbors(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ) { - for (int i = 0; i < ARRAYCOUNT(gNeighborCoords); i++) + for (size_t i = 0; i < ARRAYCOUNT(gNeighborCoords); i++) { BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; @@ -358,7 +358,7 @@ bool cFireSimulator::CanStartFireInBlock(cChunk * a_NearChunk, int a_RelX, int a return false; } - for (int i = 0; i < ARRAYCOUNT(gNeighborCoords); i++) + for (size_t i = 0; i < ARRAYCOUNT(gNeighborCoords); i++) { if (!a_NearChunk->UnboundedRelGetBlock(a_RelX + gNeighborCoords[i].x, a_RelY + gNeighborCoords[i].y, a_RelZ + gNeighborCoords[i].z, BlockType, BlockMeta)) { diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp index 58e5d614b..fdc4643a8 100644 --- a/src/Simulator/FloodyFluidSimulator.cpp +++ b/src/Simulator/FloodyFluidSimulator.cpp @@ -143,7 +143,7 @@ bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a Vector3i( 0, 0, 1), Vector3i( 0, 0, -1), } ; - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { if (!a_Chunk->UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta)) { @@ -309,7 +309,7 @@ bool cFloodyFluidSimulator::CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX } ; int NumNeeded = m_NumNeighborsForSource; - for (int i = 0; i < ARRAYCOUNT(NeighborCoords); i++) + for (size_t i = 0; i < ARRAYCOUNT(NeighborCoords); i++) { int x = a_RelX + NeighborCoords[i].x; int y = a_RelY + NeighborCoords[i].y; diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index c9013b1b3..5c87c2679 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -432,7 +432,7 @@ bool cNBTChunkSerializer::LightIsValid(bool a_IsLightValid) void cNBTChunkSerializer::BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) { memcpy(m_Biomes, a_BiomeMap, sizeof(m_Biomes)); - for (int i = 0; i < ARRAYCOUNT(m_Biomes); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Biomes); i++) { if ((*a_BiomeMap)[i] < 255) { diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 79be4dfa2..dd06f19fa 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -469,7 +469,7 @@ cChunkDef::BiomeMap * cWSSAnvil::LoadVanillaBiomeMapFromNBT(cChunkDef::BiomeMap return NULL; } const unsigned char * VanillaBiomeData = (const unsigned char *)(a_NBT.GetData(a_TagIdx)); - for (int i = 0; i < ARRAYCOUNT(*a_BiomeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(*a_BiomeMap); i++) { if ((VanillaBiomeData)[i] == 0xff) { @@ -497,7 +497,7 @@ cChunkDef::BiomeMap * cWSSAnvil::LoadBiomeMapFromNBT(cChunkDef::BiomeMap * a_Bio return NULL; } const int * BiomeData = (const int *)(a_NBT.GetData(a_TagIdx)); - for (int i = 0; i < ARRAYCOUNT(*a_BiomeMap); i++) + for (size_t i = 0; i < ARRAYCOUNT(*a_BiomeMap); i++) { (*a_BiomeMap)[i] = (EMCSBiome)(ntohl(BiomeData[i])); if ((*a_BiomeMap)[i] == 0xff) @@ -1538,7 +1538,7 @@ unsigned cWSSAnvil::cMCAFile::FindFreeLocation(int a_LocalX, int a_LocalZ, const // Doesn't fit, append to the end of file (we're wasting a lot of space, TODO: fix this later) unsigned MaxLocation = 2 << 8; // Minimum sector is #2 - after the headers - for (int i = 0; i < ARRAYCOUNT(m_Header); i++) + for (size_t i = 0; i < ARRAYCOUNT(m_Header); i++) { ChunkLocation = ntohl(m_Header[i]); ChunkLocation = ChunkLocation + ((ChunkLocation & 0xff) << 8); // Add the number of sectors used; don't care about the 4th byte