summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authortycho <work.tycho@gmail.com>2015-05-24 13:56:56 +0200
committertycho <work.tycho@gmail.com>2015-05-24 13:56:56 +0200
commitdae9e5792a4f030ae9e748548a16a89790fbd311 (patch)
tree2142b8c4deb9f2c7ad096b8b0ec93fefccd8d8f1 /src/Mobs
parentMerge branch 'master' into PreventNewWarnings (diff)
downloadcuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.gz
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.bz2
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.lz
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.xz
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.zst
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/AggressiveMonster.cpp8
-rw-r--r--src/Mobs/CMakeLists.txt4
-rw-r--r--src/Mobs/CaveSpider.cpp2
-rw-r--r--src/Mobs/Creeper.cpp4
-rw-r--r--src/Mobs/Enderman.cpp2
-rw-r--r--src/Mobs/Guardian.cpp6
-rw-r--r--src/Mobs/Horse.cpp8
-rw-r--r--src/Mobs/PassiveAggressiveMonster.cpp2
-rw-r--r--src/Mobs/PassiveMonster.cpp2
-rw-r--r--src/Mobs/Path.h8
-rw-r--r--src/Mobs/Squid.cpp6
-rw-r--r--src/Mobs/Wolf.cpp4
12 files changed, 29 insertions, 27 deletions
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<cPlayer *>(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<cPlayer *>(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<float>::epsilon())
+ if (fabsf(static_cast<float>(m_FinalDestination.x) - static_cast<float>(m_Target->GetPosX())) < std::numeric_limits<float>::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<float>::epsilon())
+ else if (fabsf(static_cast<float>(m_FinalDestination.z) - static_cast<float>(m_Target->GetPosZ())) > std::numeric_limits<float>::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<cPawn *>(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<float>((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<float>((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<int>(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<int>(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<int>(floor(Pos.x)) - a_Chunk.GetPosX() * cChunkDef::Width;
+ int RelZ = static_cast<int>(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<int>(GetPosX()), static_cast<int>(GetPosY()), static_cast<int>(GetPosZ()), 0);
+ m_World->BroadcastSoundParticleEffect(2000, static_cast<int>(GetPosX()), static_cast<int>(GetPosY()), static_cast<int>(GetPosZ()), 2);
+ m_World->BroadcastSoundParticleEffect(2000, static_cast<int>(GetPosX()), static_cast<int>(GetPosY()), static_cast<int>(GetPosZ()), 6);
+ m_World->BroadcastSoundParticleEffect(2000, static_cast<int>(GetPosX()), static_cast<int>(GetPosY()), static_cast<int>(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<cPlayer *>(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<float>(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<int8_t>(a_Vector.x);
t = t << 8;
- t += (int8_t)a_Vector.y;
+ t += static_cast<int8_t>(a_Vector.y);
t = t << 8;
- t += (int8_t)a_Vector.z;
+ t += static_cast<int8_t>(a_Vector.z);
t = t << 8;
- return (size_t)t;
+ return static_cast<size_t>(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<int>(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<int>(floor(Pos.x)) - a_Chunk.GetPosX() * cChunkDef::Width;
+ int RelZ = static_cast<int>(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<cPlayer *>(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<float>(m_SightDistance));
if (a_Closest_Player != nullptr)
{
switch (a_Closest_Player->GetEquippedItem().m_ItemType)