From 804805d35a87c2acc9425d1762ad26b1ba2ec9ac Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Wed, 29 Jul 2015 09:04:03 -0600 Subject: Silenced and fixed many warning messages across multiple files. --- src/Mobs/CMakeLists.txt | 4 +--- src/Mobs/Monster.cpp | 26 +++++++++++++------------- src/Mobs/SnowGolem.cpp | 8 ++++---- src/Mobs/Villager.cpp | 16 ++++++++-------- 4 files changed, 26 insertions(+), 28 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index e99494508..5c374f9ee 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -81,9 +81,7 @@ SET (HDRS ZombiePigman.h) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set_source_files_properties(Monster.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch -Wno-error=switch-enum -Wno-error=float-equal -Wno-error=old-style-cast") - set_source_files_properties(SnowGolem.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") - set_source_files_properties(Villager.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") + set_source_files_properties(Monster.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch -Wno-error=switch-enum -Wno-error=float-equal ") endif() if(NOT MSVC) diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 4befe307d..d97999e0f 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -238,7 +238,7 @@ void cMonster::MoveToWayPoint(cChunk & a_Chunk) if (DoesPosYRequireJump(FloorC(m_NextWayPointPosition.y))) { if ( - (IsOnGround() && (GetSpeedX() == 0) && (GetSpeedY() == 0)) || + (IsOnGround() && (GetSpeedX() == 0.0f) && (GetSpeedY() == 0.0f)) || (IsSwimming() && (m_GiveUpCounter < 15)) ) { @@ -257,7 +257,7 @@ void cMonster::MoveToWayPoint(cChunk & a_Chunk) } Vector3d Distance = m_NextWayPointPosition - GetPosition(); - if ((Distance.x != 0) || (Distance.z != 0)) + if ((Distance.x != 0.0f) || (Distance.z != 0.0f)) { Distance.y = 0; Distance.Normalize(); @@ -581,9 +581,9 @@ int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ) int PosY = POSY_TOINT; PosY = Clamp(PosY, 0, cChunkDef::Height); - if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ)))) + if (!cBlockInfo::IsSolid(m_World->GetBlock(FloorC(a_PosX), PosY, FloorC(a_PosZ)))) { - while (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))) && (PosY > 0)) + while (!cBlockInfo::IsSolid(m_World->GetBlock(FloorC(a_PosX), PosY, FloorC(a_PosZ))) && (PosY > 0)) { PosY--; } @@ -592,7 +592,7 @@ int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ) } else { - while ((PosY < cChunkDef::Height) && cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ)))) + while ((PosY < cChunkDef::Height) && cBlockInfo::IsSolid(m_World->GetBlock(static_cast(floor(a_PosX)), PosY, static_cast(floor(a_PosZ))))) { PosY++; } @@ -732,7 +732,7 @@ void cMonster::OnRightClicked(cPlayer & a_Player) void cMonster::CheckEventSeePlayer(void) { // TODO: Rewrite this to use cWorld's DoWithPlayers() - cPlayer * Closest = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance, false); + cPlayer * Closest = m_World->FindClosestPlayer(GetPosition(), static_cast(m_SightDistance), false); if (Closest != nullptr) { @@ -800,8 +800,8 @@ void cMonster::InStateIdle(std::chrono::milliseconds a_Dt) m_IdleInterval -= std::chrono::seconds(1); // So nothing gets dropped when the server hangs for a few seconds Vector3d Dist; - Dist.x = (double)m_World->GetTickRandomNumber(10) - 5; - Dist.z = (double)m_World->GetTickRandomNumber(10) - 5; + Dist.x = static_cast(m_World->GetTickRandomNumber(10)) - 5.0; + Dist.z = static_cast(m_World->GetTickRandomNumber(10)) - 5.0; if ((Dist.SqrLength() > 2) && (rem >= 3)) { @@ -1068,7 +1068,7 @@ cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType) VillagerType = 0; } - toReturn = new cVillager((cVillager::eVillagerType)VillagerType); + toReturn = new cVillager(static_cast(VillagerType)); break; } case mtHorse: @@ -1130,10 +1130,10 @@ cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType) void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth) { MTRand r1; - int Count = r1.randInt() % (a_Max + 1 - a_Min) + a_Min; + int Count = static_cast(static_cast(r1.randInt()) % (a_Max + 1 - a_Min) + a_Min); if (Count > 0) { - a_Drops.push_back(cItem(a_Item, Count, a_ItemHealth)); + a_Drops.push_back(cItem(a_Item, static_cast(Count), a_ItemHealth)); } } @@ -1158,10 +1158,10 @@ void cMonster::AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, unsigned int a_LootingLevel) { MTRand r1; - unsigned int Count = r1.randInt() % 200; + unsigned int Count = static_cast(static_cast(r1.randInt()) % 200); if (Count < (5 + a_LootingLevel)) { - int Rare = r1.randInt() % a_Items.Size(); + size_t Rare = static_cast(r1.randInt()) % a_Items.Size(); a_Drops.push_back(a_Items.at(Rare)); } } diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp index e1510b203..6afe3fda0 100644 --- a/src/Mobs/SnowGolem.cpp +++ b/src/Mobs/SnowGolem.cpp @@ -30,17 +30,17 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer) void cSnowGolem::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); - if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())))) + if (IsBiomeNoDownfall(m_World->GetBiomeAt(POSX_TOINT, POSZ_TOINT))) { TakeDamage(*this); } else { - BLOCKTYPE BlockBelow = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()) - 1, (int) floor(GetPosZ())); - BLOCKTYPE Block = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ())); + BLOCKTYPE BlockBelow = m_World->GetBlock(POSX_TOINT, POSY_TOINT - 1, POSZ_TOINT); + BLOCKTYPE Block = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT); if ((Block == E_BLOCK_AIR) && cBlockInfo::IsSolid(BlockBelow)) { - m_World->SetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()), E_BLOCK_SNOW, 0); + m_World->SetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT, E_BLOCK_SNOW, 0); } } } diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index 9239575d0..7a1a6e448 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -115,12 +115,12 @@ void cVillager::HandleFarmerPrepareFarmCrops() /// Read a 11x7x11 area. Surrounding.Read( m_World, - (int) GetPosX() - 5, - (int) GetPosX() + 6, - (int) GetPosY() - 3, - (int) GetPosY() + 4, - (int) GetPosZ() - 5, - (int) GetPosZ() + 6 + static_cast(GetPosX()) - 5, + static_cast(GetPosX()) + 6, + static_cast(GetPosY()) - 3, + static_cast(GetPosY()) + 4, + static_cast(GetPosZ()) - 5, + static_cast(GetPosZ()) + 6 ); for (int I = 0; I < 5; I++) @@ -142,8 +142,8 @@ void cVillager::HandleFarmerPrepareFarmCrops() } m_VillagerAction = true; - m_CropsPos = Vector3i((int) GetPosX() + X - 5, (int) GetPosY() + Y - 3, (int) GetPosZ() + Z - 5); - MoveToPosition(Vector3f((float) (m_CropsPos.x + 0.5), (float) m_CropsPos.y, (float) (m_CropsPos.z + 0.5))); + m_CropsPos = Vector3i(static_cast(GetPosX()) + X - 5, static_cast(GetPosY()) + Y - 3, static_cast(GetPosZ()) + Z - 5); + MoveToPosition(Vector3f(static_cast(m_CropsPos.x + 0.5), static_cast(m_CropsPos.y), static_cast(m_CropsPos.z + 0.5))); return; } // for Y loop. } // Repeat the procces 5 times. -- cgit v1.2.3