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/Entities/CMakeLists.txt | 9 +++++---- src/Entities/EnderCrystal.cpp | 2 +- src/Entities/Entity.h | 4 ++-- src/Entities/ExpOrb.cpp | 4 ++-- src/Entities/FallingBlock.cpp | 2 +- src/Entities/FireChargeEntity.cpp | 10 +++++----- src/Entities/FireChargeEntity.h | 2 +- src/Entities/GhastFireballEntity.cpp | 8 ++++---- src/Entities/GhastFireballEntity.h | 2 +- src/Entities/ItemFrame.cpp | 6 +++--- src/Entities/Minecart.cpp | 12 ++++++------ src/Entities/Painting.cpp | 2 +- src/Entities/Pawn.cpp | 2 +- src/Entities/Pickup.cpp | 6 +++--- src/Entities/ProjectileEntity.cpp | 6 +++--- src/Entities/SplashPotionEntity.cpp | 11 ++++++++--- src/Entities/ThrownSnowballEntity.cpp | 2 +- 17 files changed, 48 insertions(+), 42 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt index 44257665e..7261e85c0 100644 --- a/src/Entities/CMakeLists.txt +++ b/src/Entities/CMakeLists.txt @@ -61,10 +61,11 @@ SET (HDRS WitherSkullEntity.h) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set_source_files_properties(Entity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=global-constructors -Wno-error=switch-enum") - set_source_files_properties(EntityEffect.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum") - set_source_files_properties(Floater.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion") - set_source_files_properties(Player.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=switch-enum -Wno-error=conversion") + set_source_files_properties(ArrowEntity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") + set_source_files_properties(Entity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=global-constructors -Wno-error=switch-enum -Wno-error=old-style-cast") + set_source_files_properties(EntityEffect.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast") + set_source_files_properties(Floater.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=old-style-cast") + set_source_files_properties(Player.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=switch-enum -Wno-error=conversion -Wno-error=old-style-cast") endif() if(NOT MSVC) diff --git a/src/Entities/EnderCrystal.cpp b/src/Entities/EnderCrystal.cpp index 7a911d4db..b71d70bdd 100644 --- a/src/Entities/EnderCrystal.cpp +++ b/src/Entities/EnderCrystal.cpp @@ -22,7 +22,7 @@ cEnderCrystal::cEnderCrystal(double a_X, double a_Y, double a_Z) void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle) { - a_ClientHandle.SendSpawnObject(*this, 51, 0, (Byte)GetYaw(), (Byte)GetPitch()); + a_ClientHandle.SendSpawnObject(*this, 51, 0, static_cast(GetYaw()), static_cast(GetPitch())); } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index fecbb9bf5..58d1287e7 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -205,8 +205,8 @@ public: double GetSpeedZ (void) const { return m_Speed.z; } double GetWidth (void) const { return m_Width; } - int GetChunkX(void) const {return (int)floor(m_Pos.x / cChunkDef::Width); } - int GetChunkZ(void) const {return (int)floor(m_Pos.z / cChunkDef::Width); } + int GetChunkX(void) const {return static_cast(floor(m_Pos.x / cChunkDef::Width)); } + int GetChunkZ(void) const {return static_cast(floor(m_Pos.z / cChunkDef::Width)); } void SetHeadYaw (double a_HeadYaw); void SetHeight (double a_Height); diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp index db7f6f2c8..676370508 100644 --- a/src/Entities/ExpOrb.cpp +++ b/src/Entities/ExpOrb.cpp @@ -56,12 +56,12 @@ void cExpOrb::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) LOGD("Player %s picked up an ExpOrb. His reward is %i", a_ClosestPlayer->GetName().c_str(), m_Reward); a_ClosestPlayer->DeltaExperience(m_Reward); - m_World->BroadcastSoundEffect("random.orb", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("random.orb", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (0.75f + (static_cast((GetUniqueID() * 23) % 32)) / 64)); Destroy(); } a_Distance.Normalize(); - a_Distance *= ((float) (5.5 - Distance)); + a_Distance *= (static_cast(5.5 - Distance)); SetSpeedX( a_Distance.x); SetSpeedY( a_Distance.y); SetSpeedZ( a_Distance.z); diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index 4a165909a..bae13ea66 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -38,7 +38,7 @@ void cFallingBlock::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) // GetWorld()->BroadcastTeleportEntity(*this); // Test position int BlockX = POSX_TOINT; - int BlockY = (int)(GetPosY() - 0.5); + int BlockY = static_cast(GetPosY() - 0.5); int BlockZ = POSZ_TOINT; if (BlockY < 0) diff --git a/src/Entities/FireChargeEntity.cpp b/src/Entities/FireChargeEntity.cpp index f6c665156..10d83b8dd 100644 --- a/src/Entities/FireChargeEntity.cpp +++ b/src/Entities/FireChargeEntity.cpp @@ -19,11 +19,11 @@ cFireChargeEntity::cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y -void cFireChargeEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) +void cFireChargeEntity::Explode(Vector3i a_Block) { - if (m_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR) + if (m_World->GetBlock(a_Block) == E_BLOCK_AIR) { - m_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 1); + m_World->SetBlock(a_Block.x, a_Block.y, a_Block.z, E_BLOCK_FIRE, 1); } } @@ -34,7 +34,7 @@ void cFireChargeEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); + Explode(a_HitPos.Floor()); } @@ -44,7 +44,7 @@ void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_ void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); + Explode(a_HitPos.Floor()); // TODO: Some entities are immune to hits a_EntityHit.StartBurning(5 * 20); // 5 seconds of burning diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h index eb08f5324..25f04cb7c 100644 --- a/src/Entities/FireChargeEntity.h +++ b/src/Entities/FireChargeEntity.h @@ -32,7 +32,7 @@ public: protected: - void Explode(int a_BlockX, int a_BlockY, int a_BlockZ); + void Explode(Vector3i a_Block); // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; diff --git a/src/Entities/GhastFireballEntity.cpp b/src/Entities/GhastFireballEntity.cpp index c64fb2a17..1adfd1bc0 100644 --- a/src/Entities/GhastFireballEntity.cpp +++ b/src/Entities/GhastFireballEntity.cpp @@ -19,9 +19,9 @@ cGhastFireballEntity::cGhastFireballEntity(cEntity * a_Creator, double a_X, doub -void cGhastFireballEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) +void cGhastFireballEntity::Explode(Vector3i a_Block) { - m_World->DoExplosionAt(1, a_BlockX, a_BlockY, a_BlockZ, true, esGhastFireball, this); + m_World->DoExplosionAt(1, a_Block.x, a_Block.y, a_Block.z, true, esGhastFireball, this); } @@ -31,7 +31,7 @@ void cGhastFireballEntity::Explode(int a_BlockX, int a_BlockY, int a_BlockZ) void cGhastFireballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); + Explode(a_HitPos.Floor()); } @@ -41,5 +41,5 @@ void cGhastFireballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace void cGhastFireballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) { Destroy(); - Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z)); + Explode(a_HitPos.Floor()); } diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h index bbce89d31..dc136dfc2 100644 --- a/src/Entities/GhastFireballEntity.h +++ b/src/Entities/GhastFireballEntity.h @@ -32,7 +32,7 @@ public: protected: - void Explode(int a_BlockX, int a_BlockY, int a_BlockZ); + void Explode(Vector3i a_Block); // cProjectileEntity overrides: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index 4e6e38f1f..6317eba85 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -62,7 +62,7 @@ void cItemFrame::KilledBy(TakeDamageInfo & a_TDI) return; } - if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPlayer() && !((cPlayer *)a_TDI.Attacker)->IsGameModeCreative()) + if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPlayer() && !static_cast(a_TDI.Attacker)->IsGameModeCreative()) { cItems Item; Item.push_back(m_Item); @@ -83,7 +83,7 @@ void cItemFrame::KilledBy(TakeDamageInfo & a_TDI) void cItemFrame::GetDrops(cItems & a_Items, cEntity * a_Killer) { - if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative()) + if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !static_cast(a_Killer)->IsGameModeCreative()) { a_Items.push_back(cItem(E_ITEM_ITEM_FRAME)); } @@ -96,7 +96,7 @@ void cItemFrame::GetDrops(cItems & a_Items, cEntity * a_Killer) void cItemFrame::SpawnOn(cClientHandle & a_ClientHandle) { super::SpawnOn(a_ClientHandle); - a_ClientHandle.SendSpawnObject(*this, 71, GetProtocolFacing(), (Byte)GetYaw(), (Byte)GetPitch()); + a_ClientHandle.SendSpawnObject(*this, 71, GetProtocolFacing(), static_cast(GetYaw()), static_cast(GetPitch())); a_ClientHandle.SendEntityMetadata(*this); } diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 3adc63129..7274a7a41 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -106,7 +106,7 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) : void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) { - a_ClientHandle.SendSpawnVehicle(*this, 10, (char)m_Payload); // 10 = Minecarts + a_ClientHandle.SendSpawnVehicle(*this, 10, static_cast(m_Payload)); // 10 = Minecarts a_ClientHandle.SendEntityMetadata(*this); } @@ -725,11 +725,11 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta) { if (GetSpeedZ() > 0) { - BLOCKTYPE Block = m_World->GetBlock(POSX_TOINT, POSY_TOINT, (int)ceil(GetPosZ())); + BLOCKTYPE Block = m_World->GetBlock(POSX_TOINT, POSY_TOINT, static_cast(ceil(GetPosZ()))); if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block)) { // We could try to detect a block in front based purely on coordinates, but xoft made a bounding box system - why not use? :P - cBoundingBox bbBlock(Vector3d(POSX_TOINT, POSY_TOINT, (int)ceil(GetPosZ())), 0.5, 1); + cBoundingBox bbBlock(Vector3d(POSX_TOINT, POSY_TOINT, static_cast(ceil(GetPosZ()))), 0.5, 1); cBoundingBox bbMinecart(Vector3d(GetPosX(), floor(GetPosY()), GetPosZ()), GetWidth() / 2, GetHeight()); if (bbBlock.DoesIntersect(bbMinecart)) @@ -762,10 +762,10 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta) { if (GetSpeedX() > 0) { - BLOCKTYPE Block = m_World->GetBlock((int)ceil(GetPosX()), POSY_TOINT, POSZ_TOINT); + BLOCKTYPE Block = m_World->GetBlock(static_cast(ceil(GetPosX())), POSY_TOINT, POSZ_TOINT); if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block)) { - cBoundingBox bbBlock(Vector3d((int)ceil(GetPosX()), POSY_TOINT, POSZ_TOINT), 0.5, 1); + cBoundingBox bbBlock(Vector3d(static_cast(ceil(GetPosX())), POSY_TOINT, POSZ_TOINT), 0.5, 1); cBoundingBox bbMinecart(Vector3d(GetPosX(), floor(GetPosY()), GetPosZ()), GetWidth() / 2, GetHeight()); if (bbBlock.DoesIntersect(bbMinecart)) @@ -1003,7 +1003,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta) bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI) { - if ((TDI.Attacker != nullptr) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative()) + if ((TDI.Attacker != nullptr) && TDI.Attacker->IsPlayer() && static_cast(TDI.Attacker)->IsGameModeCreative()) { Destroy(); TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative diff --git a/src/Entities/Painting.cpp b/src/Entities/Painting.cpp index 02a8f6ed0..d73c2a245 100644 --- a/src/Entities/Painting.cpp +++ b/src/Entities/Painting.cpp @@ -33,7 +33,7 @@ void cPainting::SpawnOn(cClientHandle & a_Client) void cPainting::GetDrops(cItems & a_Items, cEntity * a_Killer) { - if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative()) + if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !static_cast(a_Killer)->IsGameModeCreative()) { a_Items.push_back(cItem(E_ITEM_PAINTING)); } diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 9fdd7026b..2cd0f2f0e 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -75,7 +75,7 @@ void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, int a_Duration, s { return; } - a_Duration = (int)(a_Duration * a_DistanceModifier); + a_Duration = static_cast(a_Duration * a_DistanceModifier); m_EntityEffects[a_EffectType] = cEntityEffect::CreateEntityEffect(a_EffectType, a_Duration, a_Intensity, a_DistanceModifier); m_World->BroadcastEntityEffect(*this, a_EffectType, a_Intensity, static_cast(a_Duration)); diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index f2f76dbf9..24736350e 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -38,7 +38,7 @@ public: Vector3d EntityPos = a_Entity->GetPosition(); double Distance = (EntityPos - m_Position).Length(); - cItem & Item = ((cPickup *)a_Entity)->GetItem(); + cItem & Item = static_cast(a_Entity)->GetItem(); if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem())) { short CombineCount = Item.m_ItemCount; @@ -52,7 +52,7 @@ public: return false; } - m_Pickup->GetItem().AddCount((char)CombineCount); + m_Pickup->GetItem().AddCount(static_cast(CombineCount)); Item.m_ItemCount -= CombineCount; if (Item.m_ItemCount <= 0) @@ -229,7 +229,7 @@ bool cPickup::CollectedBy(cPlayer & a_Dest) m_Item.m_ItemCount -= NumAdded; m_World->BroadcastCollectEntity(*this, a_Dest); // Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;) - m_World->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64)); + m_World->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (0.75f + (static_cast((GetUniqueID() * 23) % 32)) / 64)); if (m_Item.m_ItemCount <= 0) { // All of the pickup has been collected, schedule the pickup for destroying diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 1f00533db..8e2e412dd 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -30,7 +30,7 @@ /// Converts an angle in radians into a byte representation used by the network protocol -#define ANGLE_TO_PROTO(X) (Byte)(X * 255 / 360) +#define ANGLE_TO_PROTO(X) static_cast(X * 255 / 360) @@ -222,7 +222,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a m_ProjectileKind(a_Kind), m_CreatorData( ((a_Creator != nullptr) ? a_Creator->GetUniqueID() : cEntity::INVALID_ID), - ((a_Creator != nullptr) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""), + ((a_Creator != nullptr) ? (a_Creator->IsPlayer() ? static_cast(a_Creator)->GetName() : "") : ""), ((a_Creator != nullptr) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments()) ), m_IsInGround(false) @@ -238,7 +238,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height) : super(etProjectile, a_Pos.x, a_Pos.y, a_Pos.z, a_Width, a_Height), m_ProjectileKind(a_Kind), - m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "", a_Creator->GetEquippedWeapon().m_Enchantments), + m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? static_cast(a_Creator)->GetName() : "", a_Creator->GetEquippedWeapon().m_Enchantments), m_IsInGround(false) { SetSpeed(a_Speed); diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index fd1a0179b..a79ba92b0 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -9,7 +9,7 @@ /// Converts an angle in radians into a byte representation used by the network protocol -#define ANGLE_TO_PROTO(X) (Byte)(X * 255 / 360) +#define ANGLE_TO_PROTO(X) static_cast(X * 255 / 360) //////////////////////////////////////////////////////////////////////////////// // cSplashPotionEntityCallback: @@ -51,7 +51,7 @@ public: double Reduction = -0.25 * SplashDistance + 1.0; Reduction = std::max(Reduction, 0.0); - ((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction); + static_cast(a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction); return false; } @@ -116,7 +116,12 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos) cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect); m_World->ForEachEntity(Callback); - m_World->BroadcastSoundParticleEffect(2002, (int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z), m_PotionColor); + m_World->BroadcastSoundParticleEffect( + 2002, + static_cast(floor(a_HitPos.x)), + static_cast(floor(a_HitPos.y)), + static_cast(floor(a_HitPos.z)), + m_PotionColor); } diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp index 24db1e7ee..b28205d44 100644 --- a/src/Entities/ThrownSnowballEntity.cpp +++ b/src/Entities/ThrownSnowballEntity.cpp @@ -32,7 +32,7 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & int TotalDamage = 0; if (a_EntityHit.IsMob()) { - eMonsterType MobType = ((cMonster &) a_EntityHit).GetMobType(); + eMonsterType MobType = static_cast(a_EntityHit).GetMobType(); if (MobType == mtBlaze) { TotalDamage = 3; -- cgit v1.2.3