summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorJulian Laubstein <julianlaubstein@yahoo.de>2015-07-29 18:45:36 +0200
committerJulian Laubstein <julianlaubstein@yahoo.de>2015-07-29 18:45:36 +0200
commit735d590abf7f804a4504b70c84a289ba86c5f8e3 (patch)
tree13b603c8bbf8177da92ce87f5413fb646d204f3f /src/Mobs
parentMerge pull request #2376 from mjhanninen/fix-freebsd-build (diff)
parentSilenced and fixed many warning messages across multiple files. (diff)
downloadcuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.gz
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.bz2
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.lz
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.xz
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.zst
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/CMakeLists.txt4
-rw-r--r--src/Mobs/Monster.cpp26
-rw-r--r--src/Mobs/SnowGolem.cpp8
-rw-r--r--src/Mobs/Villager.cpp16
4 files changed, 26 insertions, 28 deletions
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<int>(floor(a_PosX)), PosY, static_cast<int>(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<float>(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<double>(m_World->GetTickRandomNumber(10)) - 5.0;
+ Dist.z = static_cast<double>(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<cVillager::eVillagerType>(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<int>(static_cast<unsigned int>(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<char>(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<unsigned int>(static_cast<unsigned long>(r1.randInt()) % 200);
if (Count < (5 + a_LootingLevel))
{
- int Rare = r1.randInt() % a_Items.Size();
+ size_t Rare = static_cast<size_t>(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<int>(GetPosX()) - 5,
+ static_cast<int>(GetPosX()) + 6,
+ static_cast<int>(GetPosY()) - 3,
+ static_cast<int>(GetPosY()) + 4,
+ static_cast<int>(GetPosZ()) - 5,
+ static_cast<int>(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<int>(GetPosX()) + X - 5, static_cast<int>(GetPosY()) + Y - 3, static_cast<int>(GetPosZ()) + Z - 5);
+ MoveToPosition(Vector3f(static_cast<float>(m_CropsPos.x + 0.5), static_cast<float>(m_CropsPos.y), static_cast<float>(m_CropsPos.z + 0.5)));
return;
} // for Y loop.
} // Repeat the procces 5 times.