From 77f1f58c0a7eb55001b375f1945690ed5c1e87a2 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 19 May 2015 19:32:10 +0100 Subject: Make -Werror disabling file only Ad fix a load of warnings --- src/Mobs/Blaze.cpp | 2 +- src/Mobs/CMakeLists.txt | 4 ++++ src/Mobs/CaveSpider.cpp | 2 +- src/Mobs/Chicken.cpp | 2 +- src/Mobs/Cow.cpp | 2 +- src/Mobs/Creeper.cpp | 2 +- src/Mobs/Enderman.cpp | 2 +- src/Mobs/Ghast.cpp | 2 +- src/Mobs/Guardian.cpp | 2 +- src/Mobs/Horse.cpp | 2 +- src/Mobs/Monster.cpp | 8 ++++---- src/Mobs/Monster.h | 6 +++--- src/Mobs/Mooshroom.cpp | 2 +- src/Mobs/Path.h | 2 +- src/Mobs/Pig.cpp | 2 +- src/Mobs/Rabbit.cpp | 2 +- src/Mobs/Sheep.cpp | 6 +++--- src/Mobs/Skeleton.cpp | 2 +- src/Mobs/Slime.cpp | 2 +- src/Mobs/Spider.cpp | 2 +- src/Mobs/Squid.cpp | 2 +- src/Mobs/Witch.cpp | 2 +- src/Mobs/Zombie.cpp | 2 +- src/Mobs/ZombiePigman.cpp | 2 +- 24 files changed, 34 insertions(+), 30 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index d4ad24166..731da6b18 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -23,7 +23,7 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer) { if ((a_Killer != nullptr) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf"))) { - int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + unsigned int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD); } } diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index ffbcdf3ea..bd8fa76b1 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -80,6 +80,10 @@ SET (HDRS Zombie.h 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") +endif() + if(NOT MSVC) add_library(Mobs ${SRCS} ${HDRS}) endif() diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index fa530db82..8000f3f68 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -44,7 +44,7 @@ void cCaveSpider::Attack(std::chrono::milliseconds a_Dt) void cCaveSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp index b2b21d4ae..a52d1a2da 100644 --- a/src/Mobs/Chicken.cpp +++ b/src/Mobs/Chicken.cpp @@ -48,7 +48,7 @@ void cChicken::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) void cChicken::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp index 7dc6f3f37..a45010201 100644 --- a/src/Mobs/Cow.cpp +++ b/src/Mobs/Cow.cpp @@ -21,7 +21,7 @@ cCow::cCow(void) : void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index 41796402f..6968bed17 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -60,7 +60,7 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer) return; } - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp index 42c33884a..10cec9751 100644 --- a/src/Mobs/Enderman.cpp +++ b/src/Mobs/Enderman.cpp @@ -91,7 +91,7 @@ cEnderman::cEnderman(void) : void cEnderman::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp index d17047ab7..15bbe484b 100644 --- a/src/Mobs/Ghast.cpp +++ b/src/Mobs/Ghast.cpp @@ -19,7 +19,7 @@ cGhast::cGhast(void) : void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp index 5eb30785b..a81667445 100644 --- a/src/Mobs/Guardian.cpp +++ b/src/Mobs/Guardian.cpp @@ -21,7 +21,7 @@ cGuardian::cGuardian(void) : void cGuardian::GetDrops(cItems & a_Drops, cEntity * a_Killer) { // Drops 0-3 Ink Sacs - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index 5b4c78bfc..e33cc1b9d 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -140,7 +140,7 @@ void cHorse::OnRightClicked(cPlayer & a_Player) void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 2b00f6959..619e20855 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1137,10 +1137,10 @@ void cMonster::AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short -void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel) +void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, unsigned int a_LootingLevel) { MTRand r1; - int Count = r1.randInt() % 200; + unsigned int Count = r1.randInt() % 200; if (Count < (5 + a_LootingLevel)) { int Rare = r1.randInt() % a_Items.Size(); @@ -1152,7 +1152,7 @@ void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a -void cMonster::AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel) +void cMonster::AddRandomArmorDropItem(cItems & a_Drops, unsigned int a_LootingLevel) { MTRand r1; if (r1.randInt() % 200 < ((m_DropChanceHelmet * 200) + (a_LootingLevel * 2))) @@ -1192,7 +1192,7 @@ void cMonster::AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel) -void cMonster::AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel) +void cMonster::AddRandomWeaponDropItem(cItems & a_Drops, unsigned int a_LootingLevel) { MTRand r1; if (r1.randInt() % 200 < ((m_DropChanceWeapon * 200) + (a_LootingLevel * 2))) diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index c4043b0e5..50bc02558 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -274,13 +274,13 @@ protected: void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0); /** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/ - void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel); + void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, unsigned int a_LootingLevel); /** Adds armor that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/ - void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel); + void AddRandomArmorDropItem(cItems & a_Drops, unsigned int a_LootingLevel); /** Adds weapon that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/ - void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel); + void AddRandomWeaponDropItem(cItems & a_Drops, unsigned int a_LootingLevel); } ; // tolua_export diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp index ec533cfca..3b2fbad57 100644 --- a/src/Mobs/Mooshroom.cpp +++ b/src/Mobs/Mooshroom.cpp @@ -24,7 +24,7 @@ cMooshroom::cMooshroom(void) : void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h index 7a4182f17..31002fe7f 100644 --- a/src/Mobs/Path.h +++ b/src/Mobs/Path.h @@ -99,7 +99,7 @@ public: return m_PathPoints[m_PathPoints.size() - 1 - a_index]; } /** Returns the total number of points this path has. */ - inline int GetPointCount() + inline size_t GetPointCount() { if (m_Status != ePathFinderStatus::PATH_FOUND) { diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index 56d6abfd5..efa779ac2 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -21,7 +21,7 @@ cPig::cPig(void) : void cPig::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Rabbit.cpp b/src/Mobs/Rabbit.cpp index cf49d2744..c7f3d58f0 100644 --- a/src/Mobs/Rabbit.cpp +++ b/src/Mobs/Rabbit.cpp @@ -20,7 +20,7 @@ cRabbit::cRabbit(void) : void cRabbit::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index ec24f167e..dcfef8135 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -37,10 +37,10 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer) { if (!m_IsSheared) { - a_Drops.push_back(cItem(E_BLOCK_WOOL, 1, m_WoolColor)); + a_Drops.push_back(cItem(E_BLOCK_WOOL, 1, static_cast(m_WoolColor))); } - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); @@ -65,7 +65,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player) cItems Drops; int NumDrops = m_World->GetTickRandomNumber(2) + 1; - Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor)); + Drops.push_back(cItem(E_BLOCK_WOOL, static_cast(NumDrops), static_cast(m_WoolColor))); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); m_World->BroadcastSoundEffect("mob.sheep.shear", GetPosX(), GetPosY(), GetPosZ(), 1.0f, 1.0f); } diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index f99404669..9a99a107c 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -22,7 +22,7 @@ cSkeleton::cSkeleton(bool IsWither) : void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 7fc4821d8..4988d1082 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -29,7 +29,7 @@ cSlime::cSlime(int a_Size) : void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Spider.cpp b/src/Mobs/Spider.cpp index deb263c41..184a1d912 100644 --- a/src/Mobs/Spider.cpp +++ b/src/Mobs/Spider.cpp @@ -18,7 +18,7 @@ cSpider::cSpider(void) : void cSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp index 3c508b65f..9affcd6e1 100644 --- a/src/Mobs/Squid.cpp +++ b/src/Mobs/Squid.cpp @@ -21,7 +21,7 @@ cSquid::cSquid(void) : void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer) { // Drops 0-3 Ink Sacs - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Witch.cpp b/src/Mobs/Witch.cpp index a3cadbaa0..1f672b4f7 100644 --- a/src/Mobs/Witch.cpp +++ b/src/Mobs/Witch.cpp @@ -19,7 +19,7 @@ cWitch::cWitch(void) : void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp index fa4ac855d..a5b44e6c0 100644 --- a/src/Mobs/Zombie.cpp +++ b/src/Mobs/Zombie.cpp @@ -23,7 +23,7 @@ cZombie::cZombie(bool a_IsVillagerZombie) : void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp index 8b415b0af..96d587287 100644 --- a/src/Mobs/ZombiePigman.cpp +++ b/src/Mobs/ZombiePigman.cpp @@ -18,7 +18,7 @@ cZombiePigman::cZombiePigman(void) : void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer) { - int LootingLevel = 0; + unsigned int LootingLevel = 0; if (a_Killer != nullptr) { LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); -- cgit v1.2.3 From dae9e5792a4f030ae9e748548a16a89790fbd311 Mon Sep 17 00:00:00 2001 From: tycho Date: Sun, 24 May 2015 12:56:56 +0100 Subject: Made -Weverything an error. --- src/Mobs/AggressiveMonster.cpp | 8 ++++---- src/Mobs/CMakeLists.txt | 4 +++- src/Mobs/CaveSpider.cpp | 2 +- src/Mobs/Creeper.cpp | 4 ++-- src/Mobs/Enderman.cpp | 2 +- src/Mobs/Guardian.cpp | 6 +++--- src/Mobs/Horse.cpp | 8 ++++---- src/Mobs/PassiveAggressiveMonster.cpp | 2 +- src/Mobs/PassiveMonster.cpp | 2 +- src/Mobs/Path.h | 8 ++++---- src/Mobs/Squid.cpp | 6 +++--- src/Mobs/Wolf.cpp | 4 ++-- 12 files changed, 29 insertions(+), 27 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index 648599999..7eccf0265 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -30,7 +30,7 @@ void cAggressiveMonster::InStateChasing(std::chrono::milliseconds a_Dt) { if (m_Target->IsPlayer()) { - if (((cPlayer *)m_Target)->IsGameModeCreative()) + if (static_cast(m_Target)->IsGameModeCreative()) { m_EMState = IDLE; return; @@ -46,7 +46,7 @@ void cAggressiveMonster::InStateChasing(std::chrono::milliseconds a_Dt) void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity) { - if (!((cPlayer *)a_Entity)->IsGameModeCreative()) + if (!static_cast(a_Entity)->IsGameModeCreative()) { super::EventSeePlayer(a_Entity); m_EMState = CHASING; @@ -110,12 +110,12 @@ void cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt) bool cAggressiveMonster::IsMovingToTargetPosition() { // Difference between destination x and target x is negligible (to 10^-12 precision) - if (fabsf((float)m_FinalDestination.x - (float)m_Target->GetPosX()) < std::numeric_limits::epsilon()) + if (fabsf(static_cast(m_FinalDestination.x) - static_cast(m_Target->GetPosX())) < std::numeric_limits::epsilon()) { return false; } // Difference between destination z and target z is negligible (to 10^-12 precision) - else if (fabsf((float)m_FinalDestination.z - (float)m_Target->GetPosZ()) > std::numeric_limits::epsilon()) + else if (fabsf(static_cast(m_FinalDestination.z) - static_cast(m_Target->GetPosZ())) > std::numeric_limits::epsilon()) { return false; } diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index bd8fa76b1..e99494508 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -81,7 +81,9 @@ 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") + 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") endif() if(NOT MSVC) diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 8000f3f68..a8b40f52e 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -34,7 +34,7 @@ void cCaveSpider::Attack(std::chrono::milliseconds a_Dt) if (m_Target->IsPawn()) { // TODO: Easy = no poison, Medium = 7 seconds, Hard = 15 seconds - ((cPawn *) m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0); + static_cast(m_Target)->AddEntityEffect(cEntityEffect::effPoison, 7 * 20, 0); } } diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index 6968bed17..ef3245894 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -124,7 +124,7 @@ void cCreeper::Attack(std::chrono::milliseconds a_Dt) if (!m_bIsBlowing) { - m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (0.75f + (static_cast((GetUniqueID() * 23) % 32)) / 64)); m_bIsBlowing = true; m_World->BroadcastEntityMetadata(*this); } @@ -142,7 +142,7 @@ void cCreeper::OnRightClicked(cPlayer & a_Player) { a_Player.UseEquippedItem(); } - m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("game.tnt.primed", GetPosX(), GetPosY(), GetPosZ(), 1.f, (0.75f + (static_cast((GetUniqueID() * 23) % 32)) / 64)); m_bIsBlowing = true; m_World->BroadcastEntityMetadata(*this); m_BurnedWithFlintAndSteel = true; diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp index 10cec9751..30bf82067 100644 --- a/src/Mobs/Enderman.cpp +++ b/src/Mobs/Enderman.cpp @@ -55,7 +55,7 @@ public: } cTracer LineOfSight(a_Player->GetWorld()); - if (LineOfSight.Trace(m_EndermanPos, Direction, (int)Direction.Length())) + if (LineOfSight.Trace(m_EndermanPos, Direction, static_cast(Direction.Length()))) { // No direct line of sight return false; diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp index a81667445..6efd4a42b 100644 --- a/src/Mobs/Guardian.cpp +++ b/src/Mobs/Guardian.cpp @@ -43,13 +43,13 @@ void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) Vector3d Pos = GetPosition(); // TODO: Not a real behavior, but cool :D - int RelY = (int)floor(Pos.y); + int RelY = static_cast(floor(Pos.y)); if ((RelY < 0) || (RelY >= cChunkDef::Height)) { return; } - int RelX = (int)floor(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width; - int RelZ = (int)floor(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width; + int RelX = static_cast(floor(Pos.x)) - a_Chunk.GetPosX() * cChunkDef::Width; + int RelZ = static_cast(floor(Pos.z)) - a_Chunk.GetPosZ() * cChunkDef::Width; BLOCKTYPE BlockType; if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire()) { diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index e33cc1b9d..4321fdc73 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -55,10 +55,10 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { if (m_World->GetTickRandomNumber(50) == 25) { - m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 0); - m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 2); - m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 6); - m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 8); + m_World->BroadcastSoundParticleEffect(2000, static_cast(GetPosX()), static_cast(GetPosY()), static_cast(GetPosZ()), 0); + m_World->BroadcastSoundParticleEffect(2000, static_cast(GetPosX()), static_cast(GetPosY()), static_cast(GetPosZ()), 2); + m_World->BroadcastSoundParticleEffect(2000, static_cast(GetPosX()), static_cast(GetPosY()), static_cast(GetPosZ()), 6); + m_World->BroadcastSoundParticleEffect(2000, static_cast(GetPosX()), static_cast(GetPosY()), static_cast(GetPosZ()), 8); m_Attachee->Detach(); m_bIsRearing = true; diff --git a/src/Mobs/PassiveAggressiveMonster.cpp b/src/Mobs/PassiveAggressiveMonster.cpp index cb8650cb9..f5577f71f 100644 --- a/src/Mobs/PassiveAggressiveMonster.cpp +++ b/src/Mobs/PassiveAggressiveMonster.cpp @@ -28,7 +28,7 @@ bool cPassiveAggressiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) if ((m_Target != nullptr) && (m_Target->IsPlayer())) { - if (!((cPlayer *)m_Target)->IsGameModeCreative()) + if (!static_cast(m_Target)->IsGameModeCreative()) { m_EMState = CHASING; } diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp index 012ca9949..c220a7128 100644 --- a/src/Mobs/PassiveMonster.cpp +++ b/src/Mobs/PassiveMonster.cpp @@ -48,7 +48,7 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { return; } - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); + cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast(m_SightDistance)); if (a_Closest_Player != nullptr) { if (a_Closest_Player->GetEquippedItem().IsEqual(FollowedItem)) diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h index 71b42edc0..db74eaba2 100644 --- a/src/Mobs/Path.h +++ b/src/Mobs/Path.h @@ -128,13 +128,13 @@ public: { // Guaranteed to have no hash collisions for any 128x128x128 area. Suitable for pathfinding. int32_t t = 0; - t += (int8_t)a_Vector.x; + t += static_cast(a_Vector.x); t = t << 8; - t += (int8_t)a_Vector.y; + t += static_cast(a_Vector.y); t = t << 8; - t += (int8_t)a_Vector.z; + t += static_cast(a_Vector.z); t = t << 8; - return (size_t)t; + return static_cast(t); } }; private: diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp index 9affcd6e1..7928f7dc8 100644 --- a/src/Mobs/Squid.cpp +++ b/src/Mobs/Squid.cpp @@ -41,13 +41,13 @@ void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) Vector3d Pos = GetPosition(); // TODO: Not a real behavior, but cool :D - int RelY = (int)floor(Pos.y); + int RelY = static_cast(floor(Pos.y)); if ((RelY < 0) || (RelY >= cChunkDef::Height)) { return; } - int RelX = (int)floor(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width; - int RelZ = (int)floor(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width; + int RelX = static_cast(floor(Pos.x)) - a_Chunk.GetPosX() * cChunkDef::Width; + int RelZ = static_cast(floor(Pos.z)) - a_Chunk.GetPosZ() * cChunkDef::Width; BLOCKTYPE BlockType; if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire()) { diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index 3c2ec1520..61c28c467 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -50,7 +50,7 @@ void cWolf::Attack(std::chrono::milliseconds a_Dt) if ((m_Target != nullptr) && (m_Target->IsPlayer())) { - if (((cPlayer *)m_Target)->GetName() != m_OwnerName) + if (static_cast(m_Target)->GetName() != m_OwnerName) { super::Attack(a_Dt); } @@ -157,7 +157,7 @@ void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) super::Tick(a_Dt, a_Chunk); } - cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); + cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast(m_SightDistance)); if (a_Closest_Player != nullptr) { switch (a_Closest_Player->GetEquippedItem().m_ItemType) -- cgit v1.2.3 From d1c91223401f7d13d6f32471da36db77360678b6 Mon Sep 17 00:00:00 2001 From: tycho Date: Sun, 24 May 2015 17:47:15 +0100 Subject: Fix warnings in cPath --- src/Mobs/Path.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp index 6f3d43305..4d04d9861 100644 --- a/src/Mobs/Path.cpp +++ b/src/Mobs/Path.cpp @@ -46,18 +46,18 @@ cPath::cPath( a_BoundingBoxWidth = 1; // Until we improve physics, if ever. - m_BoundingBoxWidth = ceil(a_BoundingBoxWidth); - m_BoundingBoxHeight = ceil(a_BoundingBoxHeight); + m_BoundingBoxWidth = static_cast(ceil(a_BoundingBoxWidth)); + m_BoundingBoxHeight = static_cast(ceil(a_BoundingBoxHeight)); m_HalfWidth = a_BoundingBoxWidth / 2; - int HalfWidthInt = a_BoundingBoxWidth / 2; - m_Source.x = floor(a_StartingPoint.x - HalfWidthInt); - m_Source.y = floor(a_StartingPoint.y); - m_Source.z = floor(a_StartingPoint.z - HalfWidthInt); + int HalfWidthInt = static_cast(a_BoundingBoxWidth / 2); + m_Source.x = static_cast(floor(a_StartingPoint.x - HalfWidthInt)); + m_Source.y = static_cast(floor(a_StartingPoint.y)); + m_Source.z = static_cast(floor(a_StartingPoint.z - HalfWidthInt)); - m_Destination.x = floor(a_EndingPoint.x - HalfWidthInt); - m_Destination.y = floor(a_EndingPoint.y); - m_Destination.z = floor(a_EndingPoint.z - HalfWidthInt); + m_Destination.x = static_cast(floor(a_EndingPoint.x - HalfWidthInt)); + m_Destination.y = static_cast(floor(a_EndingPoint.y)); + m_Destination.z = static_cast(floor(a_EndingPoint.z - HalfWidthInt)); if (GetCell(m_Source)->m_IsSolid || GetCell(m_Destination)->m_IsSolid) { -- cgit v1.2.3 From b2fa71a32ac8bd86bda778a5d54fe2e7e471a1c0 Mon Sep 17 00:00:00 2001 From: tycho Date: Thu, 28 May 2015 12:29:26 +0100 Subject: Fix comments --- src/Mobs/Guardian.cpp | 6 +++--- src/Mobs/Horse.cpp | 8 ++++---- src/Mobs/Path.cpp | 18 +++++++++--------- src/Mobs/Squid.cpp | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp index 6efd4a42b..cfe7861a6 100644 --- a/src/Mobs/Guardian.cpp +++ b/src/Mobs/Guardian.cpp @@ -43,13 +43,13 @@ void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) Vector3d Pos = GetPosition(); // TODO: Not a real behavior, but cool :D - int RelY = static_cast(floor(Pos.y)); + int RelY = FloorC(Pos.y); if ((RelY < 0) || (RelY >= cChunkDef::Height)) { return; } - int RelX = static_cast(floor(Pos.x)) - a_Chunk.GetPosX() * cChunkDef::Width; - int RelZ = static_cast(floor(Pos.z)) - a_Chunk.GetPosZ() * cChunkDef::Width; + int RelX = FloorC(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width; + int RelZ = FloorC(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width; BLOCKTYPE BlockType; if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire()) { diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index 4321fdc73..ce3bd65eb 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -55,10 +55,10 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { if (m_World->GetTickRandomNumber(50) == 25) { - m_World->BroadcastSoundParticleEffect(2000, static_cast(GetPosX()), static_cast(GetPosY()), static_cast(GetPosZ()), 0); - m_World->BroadcastSoundParticleEffect(2000, static_cast(GetPosX()), static_cast(GetPosY()), static_cast(GetPosZ()), 2); - m_World->BroadcastSoundParticleEffect(2000, static_cast(GetPosX()), static_cast(GetPosY()), static_cast(GetPosZ()), 6); - m_World->BroadcastSoundParticleEffect(2000, static_cast(GetPosX()), static_cast(GetPosY()), static_cast(GetPosZ()), 8); + m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 0); + m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 2); + m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 6); + m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 8); m_Attachee->Detach(); m_bIsRearing = true; diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp index 4d04d9861..1848e144e 100644 --- a/src/Mobs/Path.cpp +++ b/src/Mobs/Path.cpp @@ -46,18 +46,18 @@ cPath::cPath( a_BoundingBoxWidth = 1; // Until we improve physics, if ever. - m_BoundingBoxWidth = static_cast(ceil(a_BoundingBoxWidth)); - m_BoundingBoxHeight = static_cast(ceil(a_BoundingBoxHeight)); + m_BoundingBoxWidth = CeilC(a_BoundingBoxWidth); + m_BoundingBoxHeight = CeilC(a_BoundingBoxHeight); m_HalfWidth = a_BoundingBoxWidth / 2; - int HalfWidthInt = static_cast(a_BoundingBoxWidth / 2); - m_Source.x = static_cast(floor(a_StartingPoint.x - HalfWidthInt)); - m_Source.y = static_cast(floor(a_StartingPoint.y)); - m_Source.z = static_cast(floor(a_StartingPoint.z - HalfWidthInt)); + int HalfWidthInt = FloorC(a_BoundingBoxWidth / 2); + m_Source.x = FloorC(a_StartingPoint.x - HalfWidthInt); + m_Source.y = FloorC(a_StartingPoint.y); + m_Source.z = FloorC(a_StartingPoint.z - HalfWidthInt); - m_Destination.x = static_cast(floor(a_EndingPoint.x - HalfWidthInt)); - m_Destination.y = static_cast(floor(a_EndingPoint.y)); - m_Destination.z = static_cast(floor(a_EndingPoint.z - HalfWidthInt)); + m_Destination.x = FloorC(a_EndingPoint.x - HalfWidthInt); + m_Destination.y = FloorC(a_EndingPoint.y); + m_Destination.z = FloorC(a_EndingPoint.z - HalfWidthInt); if (GetCell(m_Source)->m_IsSolid || GetCell(m_Destination)->m_IsSolid) { diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp index 7928f7dc8..d148d65f3 100644 --- a/src/Mobs/Squid.cpp +++ b/src/Mobs/Squid.cpp @@ -41,13 +41,13 @@ void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) Vector3d Pos = GetPosition(); // TODO: Not a real behavior, but cool :D - int RelY = static_cast(floor(Pos.y)); + int RelY = FloorC(Pos.y); if ((RelY < 0) || (RelY >= cChunkDef::Height)) { return; } - int RelX = static_cast(floor(Pos.x)) - a_Chunk.GetPosX() * cChunkDef::Width; - int RelZ = static_cast(floor(Pos.z)) - a_Chunk.GetPosZ() * cChunkDef::Width; + int RelX = FloorC(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width; + int RelZ = FloorC(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width; BLOCKTYPE BlockType; if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire()) { -- cgit v1.2.3