summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-05-02 09:50:36 +0200
committerGitHub <noreply@github.com>2018-05-02 09:50:36 +0200
commita4dbb5c58270959884c17d720185da06464fa256 (patch)
tree2b4e81410e90e059f51726e6c9a01c03fcbfb98d /src/Entities
parenttolua++ bindings use nullptr. (#4219) (diff)
downloadcuberite-a4dbb5c58270959884c17d720185da06464fa256.tar
cuberite-a4dbb5c58270959884c17d720185da06464fa256.tar.gz
cuberite-a4dbb5c58270959884c17d720185da06464fa256.tar.bz2
cuberite-a4dbb5c58270959884c17d720185da06464fa256.tar.lz
cuberite-a4dbb5c58270959884c17d720185da06464fa256.tar.xz
cuberite-a4dbb5c58270959884c17d720185da06464fa256.tar.zst
cuberite-a4dbb5c58270959884c17d720185da06464fa256.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp26
-rw-r--r--src/Entities/EntityEffect.cpp20
-rw-r--r--src/Entities/Player.cpp8
3 files changed, 27 insertions, 27 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 73749d7a3..d1fdcfd39 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -410,7 +410,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{
- cPlayer * Player = reinterpret_cast<cPlayer *>(a_TDI.Attacker);
+ cPlayer * Player = static_cast<cPlayer *>(a_TDI.Attacker);
Player->GetEquippedItem().GetHandler()->OnEntityAttack(Player, this);
@@ -441,7 +441,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (IsMob())
{
- cMonster * Monster = reinterpret_cast<cMonster *>(this);
+ cMonster * Monster = static_cast<cMonster *>(this);
switch (Monster->GetMobType())
{
case mtSkeleton:
@@ -460,7 +460,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (IsMob())
{
- cMonster * Monster = reinterpret_cast<cMonster *>(this);
+ cMonster * Monster = static_cast<cMonster *>(this);
switch (Monster->GetMobType())
{
case mtSpider:
@@ -496,7 +496,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
}
else if (IsMob() && !IsInWater())
{
- cMonster * Monster = reinterpret_cast<cMonster *>(this);
+ cMonster * Monster = static_cast<cMonster *>(this);
switch (Monster->GetMobType())
{
case mtGhast:
@@ -871,7 +871,7 @@ void cEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// Handle cactus damage or destruction:
if (
IsMob() || IsPickup() ||
- (IsPlayer() && !((reinterpret_cast<cPlayer *>(this))->IsGameModeCreative() || (reinterpret_cast<cPlayer *>(this))->IsGameModeSpectator()))
+ (IsPlayer() && !((static_cast<cPlayer *>(this))->IsGameModeCreative() || (static_cast<cPlayer *>(this))->IsGameModeSpectator()))
)
{
DetectCacti();
@@ -1362,7 +1362,7 @@ bool cEntity::DetectPortal()
return false;
}
- if (IsPlayer() && !(reinterpret_cast<cPlayer *>(this))->IsGameModeCreative() && (m_PortalCooldownData.m_TicksDelayed != 80))
+ if (IsPlayer() && !(static_cast<cPlayer *>(this))->IsGameModeCreative() && (m_PortalCooldownData.m_TicksDelayed != 80))
{
// Delay teleportation for four seconds if the entity is a non-creative player
m_PortalCooldownData.m_TicksDelayed++;
@@ -1385,7 +1385,7 @@ bool cEntity::DetectPortal()
if (IsPlayer())
{
// Send a respawn packet before world is loaded / generated so the client isn't left in limbo
- (reinterpret_cast<cPlayer *>(this))->GetClientHandle()->SendRespawn(DestionationDim);
+ (static_cast<cPlayer *>(this))->GetClientHandle()->SendRespawn(DestionationDim);
}
Vector3d TargetPos = GetPosition();
@@ -1414,10 +1414,10 @@ bool cEntity::DetectPortal()
{
if (DestionationDim == dimNether)
{
- reinterpret_cast<cPlayer *>(this)->AwardAchievement(achEnterPortal);
+ static_cast<cPlayer *>(this)->AwardAchievement(achEnterPortal);
}
- reinterpret_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(DestionationDim);
+ static_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(DestionationDim);
}
Vector3d TargetPos = GetPosition();
@@ -1454,7 +1454,7 @@ bool cEntity::DetectPortal()
if (IsPlayer())
{
- cPlayer * Player = reinterpret_cast<cPlayer *>(this);
+ cPlayer * Player = static_cast<cPlayer *>(this);
if (Player->GetBedWorld() == DestinationWorld)
{
Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z);
@@ -1487,9 +1487,9 @@ bool cEntity::DetectPortal()
{
if (DestionationDim == dimEnd)
{
- reinterpret_cast<cPlayer *>(this)->AwardAchievement(achEnterTheEnd);
+ static_cast<cPlayer *>(this)->AwardAchievement(achEnterTheEnd);
}
- reinterpret_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(DestionationDim);
+ static_cast<cPlayer *>(this)->GetClientHandle()->SendRespawn(DestionationDim);
}
cWorld * TargetWorld = cRoot::Get()->GetWorld(GetWorld()->GetLinkedEndWorldName());
@@ -1717,7 +1717,7 @@ void cEntity::HandleAir(void)
if (RespirationLevel > 0)
{
- reinterpret_cast<cPawn *>(this)->AddEntityEffect(cEntityEffect::effNightVision, 200, 5, 0);
+ static_cast<cPawn *>(this)->AddEntityEffect(cEntityEffect::effNightVision, 200, 5, 0);
}
if (m_AirLevel <= 0)
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index 8f0ecc395..45a98c0d2 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -241,12 +241,12 @@ void cEntityEffectSpeed::OnActivate(cPawn & a_Target)
{
if (a_Target.IsMob())
{
- cMonster * Mob = reinterpret_cast<cMonster*>(&a_Target);
+ cMonster * Mob = static_cast<cMonster*>(&a_Target);
Mob->SetRelativeWalkSpeed(Mob->GetRelativeWalkSpeed() + 0.2 * m_Intensity);
}
else if (a_Target.IsPlayer())
{
- cPlayer * Player = reinterpret_cast<cPlayer*>(&a_Target);
+ cPlayer * Player = static_cast<cPlayer*>(&a_Target);
Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() + 0.2 * m_Intensity);
Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() + 0.26 * m_Intensity);
Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() + 0.2 * m_Intensity);
@@ -261,12 +261,12 @@ void cEntityEffectSpeed::OnDeactivate(cPawn & a_Target)
{
if (a_Target.IsMob())
{
- cMonster * Mob = reinterpret_cast<cMonster*>(&a_Target);
+ cMonster * Mob = static_cast<cMonster*>(&a_Target);
Mob->SetRelativeWalkSpeed(Mob->GetRelativeWalkSpeed() - 0.2 * m_Intensity);
}
else if (a_Target.IsPlayer())
{
- cPlayer * Player = reinterpret_cast<cPlayer*>(&a_Target);
+ cPlayer * Player = static_cast<cPlayer*>(&a_Target);
Player->SetNormalMaxSpeed(Player->GetNormalMaxSpeed() - 0.2 * m_Intensity);
Player->SetSprintingMaxSpeed(Player->GetSprintingMaxSpeed() - 0.26 * m_Intensity);
Player->SetFlyingMaxSpeed(Player->GetFlyingMaxSpeed() - 0.2 * m_Intensity);
@@ -328,7 +328,7 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
// Base amount = 6, doubles for every increase in intensity
int amount = static_cast<int>(6 * (1 << m_Intensity) * m_DistanceModifier);
- if (a_Target.IsMob() && reinterpret_cast<cMonster &>(a_Target).IsUndead())
+ if (a_Target.IsMob() && static_cast<cMonster &>(a_Target).IsUndead())
{
a_Target.TakeDamage(dtPotionOfHarming, nullptr, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
return;
@@ -348,7 +348,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
// Base amount = 6, doubles for every increase in intensity
int amount = static_cast<int>(6 * (1 << m_Intensity) * m_DistanceModifier);
- if (a_Target.IsMob() && reinterpret_cast<cMonster &>(a_Target).IsUndead())
+ if (a_Target.IsMob() && static_cast<cMonster &>(a_Target).IsUndead())
{
a_Target.Heal(amount);
return;
@@ -367,7 +367,7 @@ void cEntityEffectRegeneration::OnTick(cPawn & a_Target)
{
super::OnTick(a_Target);
- if (a_Target.IsMob() && reinterpret_cast<cMonster &>(a_Target).IsUndead())
+ if (a_Target.IsMob() && static_cast<cMonster &>(a_Target).IsUndead())
{
return;
}
@@ -396,7 +396,7 @@ void cEntityEffectHunger::OnTick(cPawn & a_Target)
if (a_Target.IsPlayer())
{
- cPlayer & Target = reinterpret_cast<cPlayer &>(a_Target);
+ cPlayer & Target = static_cast<cPlayer &>(a_Target);
Target.AddFoodExhaustion(0.025 * (static_cast<double>(GetIntensity()) + 1.0)); // 0.5 per second = 0.025 per tick
}
}
@@ -448,7 +448,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
if (a_Target.IsMob())
{
- cMonster & Target = reinterpret_cast<cMonster &>(a_Target);
+ cMonster & Target = static_cast<cMonster &>(a_Target);
// Doesn't effect undead mobs, spiders
if (
@@ -505,7 +505,7 @@ void cEntityEffectSaturation::OnTick(cPawn & a_Target)
{
if (a_Target.IsPlayer())
{
- cPlayer & Target = reinterpret_cast<cPlayer &>(a_Target);
+ cPlayer & Target = static_cast<cPlayer &>(a_Target);
Target.SetFoodSaturationLevel(Target.GetFoodSaturationLevel() + (1 + m_Intensity)); // Increase saturation 1 per tick, adds 1 for every increase in level
}
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index a58d45fb0..c674f4620 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -968,7 +968,7 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{
- cPlayer * Attacker = reinterpret_cast<cPlayer *>(a_TDI.Attacker);
+ cPlayer * Attacker = static_cast<cPlayer *>(a_TDI.Attacker);
if ((m_Team != nullptr) && (m_Team == Attacker->m_Team))
{
@@ -1098,7 +1098,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
}
else if (a_TDI.Attacker->IsPlayer())
{
- cPlayer * Killer = reinterpret_cast<cPlayer *>(a_TDI.Attacker);
+ cPlayer * Killer = static_cast<cPlayer *>(a_TDI.Attacker);
AString DeathMessage = Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str());
PluginManager->CallHookKilled(*this, a_TDI, DeathMessage);
if (DeathMessage != AString(""))
@@ -1139,7 +1139,7 @@ void cPlayer::Killed(cEntity * a_Victim)
}
else if (a_Victim->IsMob())
{
- if (reinterpret_cast<cMonster *>(a_Victim)->GetMobFamily() == cMonster::mfHostile)
+ if (static_cast<cMonster *>(a_Victim)->GetMobFamily() == cMonster::mfHostile)
{
AwardAchievement(achKillMonster);
}
@@ -2529,7 +2529,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos, bool a_PreviousIs
case cEntity::etBoat: m_Stats.AddValue(statDistBoat, Value); break;
case cEntity::etMonster:
{
- cMonster * Monster = reinterpret_cast<cMonster *>(m_AttachedTo);
+ cMonster * Monster = static_cast<cMonster *>(m_AttachedTo);
switch (Monster->GetMobType())
{
case mtPig: m_Stats.AddValue(statDistPig, Value); break;