From 00911c5f94040e31a4f073ac72249645d506aab7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Dec 2013 15:44:56 +0100 Subject: Fixed missing parenthesis. --- src/Blocks/BlockDoor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp index e71ccd368..e91211559 100644 --- a/src/Blocks/BlockDoor.cpp +++ b/src/Blocks/BlockDoor.cpp @@ -65,10 +65,10 @@ void cBlockDoorHandler::OnPlacedByPlayer( { NIBBLETYPE a_TopBlockMeta = 8; if ( - (a_BlockMeta == 0) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1) == m_BlockType) || - (a_BlockMeta == 1) && (a_World->GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) == m_BlockType) || - (a_BlockMeta == 2) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) == m_BlockType) || - (a_BlockMeta == 3) && (a_World->GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) == m_BlockType) + ((a_BlockMeta == 0) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1) == m_BlockType)) || + ((a_BlockMeta == 1) && (a_World->GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) == m_BlockType)) || + ((a_BlockMeta == 2) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) == m_BlockType)) || + ((a_BlockMeta == 3) && (a_World->GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) == m_BlockType)) ) { a_TopBlockMeta = 9; -- cgit v1.2.3 From b19d7656663237c1dd23935f7d37f0444f2b63fb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Dec 2013 15:50:46 +0100 Subject: Fixed melon and pumpkin growing. --- src/Blocks/BlockStems.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Blocks/BlockStems.h b/src/Blocks/BlockStems.h index c2dff62cf..d860639a5 100644 --- a/src/Blocks/BlockStems.h +++ b/src/Blocks/BlockStems.h @@ -32,7 +32,7 @@ public: // Grow the produce: int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width; int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width; - a_Chunk.GetWorld()->GrowMelonPumpkin(BlockX, a_RelY, a_RelZ, m_BlockType); + a_Chunk.GetWorld()->GrowMelonPumpkin(BlockX, a_RelY, BlockZ, m_BlockType); } else { -- cgit v1.2.3 From 8610d45ef18f075e7fa207732233ddbd69bb604b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Dec 2013 16:01:34 +0100 Subject: 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(-) (limited to 'src') 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 -- cgit v1.2.3 From b6e4d2c263f25f3724376e72396e28220a0b57e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Dec 2013 16:11:25 +0100 Subject: Properly fixed warnings in cFastRandom. --- src/FastRandom.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/FastRandom.cpp b/src/FastRandom.cpp index 887e4426d..e6634bb0d 100644 --- a/src/FastRandom.cpp +++ b/src/FastRandom.cpp @@ -108,7 +108,7 @@ int cFastRandom::NextInt(int a_Range) int Counter = m_Counter++; // Use a_Range, m_Counter and m_Seed as inputs to the pseudorandom function: - int n = a_Range + m_Counter * 57 + m_Seed * 57 * 57; + int n = a_Range + Counter * 57 + m_Seed * 57 * 57; n = (n << 13) ^ n; n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff); return ((n / 11) % a_Range); @@ -127,7 +127,7 @@ int cFastRandom::NextInt(int a_Range, int a_Salt) int Counter = m_Counter++; // Use a_Range, a_Salt, m_Counter and m_Seed as inputs to the pseudorandom function: - int n = a_Range + m_Counter * 57 + m_Seed * 57 * 57 + a_Salt * 57 * 57 * 57; + int n = a_Range + Counter * 57 + m_Seed * 57 * 57 + a_Salt * 57 * 57 * 57; n = (n << 13) ^ n; n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff); return ((n / 11) % a_Range); @@ -143,7 +143,7 @@ float cFastRandom::NextFloat(float a_Range) int Counter = m_Counter++; // Use a_Range, a_Salt, m_Counter and m_Seed as inputs to the pseudorandom function: - int n = (int)a_Range + m_Counter * 57 + m_Seed * 57 * 57; + int n = (int)a_Range + Counter * 57 + m_Seed * 57 * 57; n = (n << 13) ^ n; n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff); @@ -161,7 +161,7 @@ float cFastRandom::NextFloat(float a_Range, int a_Salt) int Counter = m_Counter++; // Use a_Range, a_Salt, m_Counter and m_Seed as inputs to the pseudorandom function: - int n = (int)a_Range + m_Counter * 57 + m_Seed * 57 * 57 + a_Salt * 57 * 57 * 57; + int n = (int)a_Range + Counter * 57 + m_Seed * 57 * 57 + a_Salt * 57 * 57 * 57; n = (n << 13) ^ n; n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff); -- cgit v1.2.3 From 812375fab1517c70f56360719c10c2c61c03180d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Dec 2013 16:15:39 +0100 Subject: Attempt at fixing cChunkDef::Height signedness. --- src/Chunk.cpp | 7 +------ src/ChunkDef.h | 24 ++++++++++++------------ src/WorldStorage/WSSCompact.cpp | 6 +++--- src/WorldStorage/WSSCompact.h | 8 ++++++++ 4 files changed, 24 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 3eb46213c..3ae4e36be 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -633,11 +633,6 @@ void cChunk::Tick(float a_Dt) void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ) { unsigned Index = MakeIndex(a_RelX, a_RelY, a_RelZ); - if (Index == INDEX_OUT_OF_RANGE) - { - // An assert has already been made in MakeIndex() - return; - } cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 Handler->OnUpdate(*this, a_RelX, a_RelY, a_RelZ); @@ -1492,7 +1487,7 @@ void cChunk::QueueTickBlockNeighbors(int a_RelX, int a_RelY, int a_RelZ) { 0, 0, 1}, { 0, 0, -1}, } ; - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { UnboundedQueueTickBlock(a_RelX + Coords[i].x, a_RelY + Coords[i].y, a_RelZ + Coords[i].z); } // for i - Coords[] diff --git a/src/ChunkDef.h b/src/ChunkDef.h index d6630df7e..8c37e7907 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -152,17 +152,16 @@ enum EMCSBiome class cChunkDef { public: - static const int Width = 16; - static const int Height = 256; - static const int NumBlocks = Width * Height * Width; - static const int BlockDataSize = NumBlocks * 2 + (NumBlocks / 2); // 2.5 * numblocks - - // Offsets to individual components in the joined blockdata array - static const int MetaOffset = NumBlocks; - static const int LightOffset = MetaOffset + NumBlocks / 2; - static const int SkyLightOffset = LightOffset + NumBlocks / 2; - - static const unsigned int INDEX_OUT_OF_RANGE = 0xffffffff; + enum + { + // Chunk dimensions: + Width = 16, + Height = 256, + NumBlocks = Width * Height * Width, + + /// If the data is collected into a single buffer, how large it needs to be: + BlockDataSize = cChunkDef::NumBlocks * 2 + (cChunkDef::NumBlocks / 2), // 2.5 * numblocks + } ; /// The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column typedef HEIGHTTYPE HeightMap[Width * Width]; @@ -216,8 +215,9 @@ public: { return MakeIndexNoCheck(x, y, z); } + LOGERROR("cChunkDef::MakeIndex(): coords out of range: {%d, %d, %d}; returning fake index 0", x, y, z); ASSERT(!"cChunkDef::MakeIndex(): coords out of chunk range!"); - return INDEX_OUT_OF_RANGE; + return 0; } diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index 287938b24..e2556b96e 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -871,9 +871,9 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_Uncomp } BLOCKTYPE * BlockData = (BLOCKTYPE *)UncompressedData.data(); - NIBBLETYPE * MetaData = (NIBBLETYPE *)(BlockData + cChunkDef::MetaOffset); - NIBBLETYPE * BlockLight = (NIBBLETYPE *)(BlockData + cChunkDef::LightOffset); - NIBBLETYPE * SkyLight = (NIBBLETYPE *)(BlockData + cChunkDef::SkyLightOffset); + NIBBLETYPE * MetaData = (NIBBLETYPE *)(BlockData + MetaOffset); + NIBBLETYPE * BlockLight = (NIBBLETYPE *)(BlockData + LightOffset); + NIBBLETYPE * SkyLight = (NIBBLETYPE *)(BlockData + SkyLightOffset); a_World->SetChunkData( a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h index a75c41ccb..3223a986e 100644 --- a/src/WorldStorage/WSSCompact.h +++ b/src/WorldStorage/WSSCompact.h @@ -58,6 +58,14 @@ public: protected: + enum + { + // Offsets to individual components in the joined blockdata array + MetaOffset = cChunkDef::NumBlocks, + LightOffset = MetaOffset + cChunkDef::NumBlocks / 2, + SkyLightOffset = LightOffset + cChunkDef::NumBlocks / 2, + } ; + struct sChunkHeader; typedef std::vector sChunkHeaders; -- cgit v1.2.3 From b66722f73532e9c1d5df71f6a2f09b5da0163dee Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 20 Dec 2013 16:20:54 +0100 Subject: Fixed warnings in HTTP parser. --- src/HTTPServer/HTTPConnection.h | 2 +- src/HTTPServer/HTTPFormParser.cpp | 5 +++++ src/HTTPServer/HTTPMessage.h | 3 +++ src/HTTPServer/NameValueParser.cpp | 10 ++++++---- 4 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/HTTPServer/HTTPConnection.h b/src/HTTPServer/HTTPConnection.h index 14603bb70..00941f2ae 100644 --- a/src/HTTPServer/HTTPConnection.h +++ b/src/HTTPServer/HTTPConnection.h @@ -39,7 +39,7 @@ public: } ; cHTTPConnection(cHTTPServer & a_HTTPServer); - ~cHTTPConnection(); + virtual ~cHTTPConnection(); /// Sends HTTP status code together with a_Reason (used for HTTP errors) void SendStatusAndReason(int a_StatusCode, const AString & a_Reason); diff --git a/src/HTTPServer/HTTPFormParser.cpp b/src/HTTPServer/HTTPFormParser.cpp index 596db424e..01c68881a 100644 --- a/src/HTTPServer/HTTPFormParser.cpp +++ b/src/HTTPServer/HTTPFormParser.cpp @@ -109,6 +109,11 @@ bool cHTTPFormParser::Finish(void) ParseFormUrlEncoded(); break; } + default: + { + // Nothing needed for other formats + break; + } } return (m_IsValid && m_IncomingData.empty()); } diff --git a/src/HTTPServer/HTTPMessage.h b/src/HTTPServer/HTTPMessage.h index f5284c535..2a4c2879e 100644 --- a/src/HTTPServer/HTTPMessage.h +++ b/src/HTTPServer/HTTPMessage.h @@ -32,6 +32,9 @@ public: cHTTPMessage(eKind a_Kind); + // Force a virtual destructor in all descendants + virtual ~cHTTPMessage() {}; + /// Adds a header into the internal map of headers. Recognizes special headers: Content-Type and Content-Length void AddHeader(const AString & a_Key, const AString & a_Value); diff --git a/src/HTTPServer/NameValueParser.cpp b/src/HTTPServer/NameValueParser.cpp index a27f07d19..fd56f6b24 100644 --- a/src/HTTPServer/NameValueParser.cpp +++ b/src/HTTPServer/NameValueParser.cpp @@ -97,15 +97,17 @@ void cNameValueParser::Parse(const char * a_Data, int a_Size) { ASSERT(m_State != psFinished); // Calling Parse() after Finish() is wrong! - if ((m_State == psInvalid) || (m_State == psFinished)) - { - return; - } int Last = 0; for (int i = 0; i < a_Size;) { switch (m_State) { + case psInvalid: + case psFinished: + { + return; + } + case psKeySpace: { // Skip whitespace until a non-whitespace is found, then start the key: -- cgit v1.2.3