summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Entities/ArrowEntity.cpp2
-rw-r--r--src/Entities/Boat.cpp4
-rw-r--r--src/Entities/Entity.cpp56
-rw-r--r--src/Entities/Entity.h14
-rw-r--r--src/Entities/EntityEffect.cpp10
-rw-r--r--src/Entities/ExpOrb.cpp2
-rw-r--r--src/Entities/Floater.cpp2
-rw-r--r--src/Entities/ItemFrame.cpp4
-rw-r--r--src/Entities/Minecart.cpp14
-rw-r--r--src/Entities/Minecart.h4
-rw-r--r--src/Entities/Painting.cpp2
-rw-r--r--src/Entities/Player.cpp60
-rw-r--r--src/Entities/Player.h4
-rw-r--r--src/Entities/ProjectileEntity.cpp16
-rw-r--r--src/Entities/ProjectileEntity.h4
15 files changed, 99 insertions, 99 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 7e429c62e..30f18f677 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -217,7 +217,7 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
int RelPosZ = m_HitBlockPos.z - a_Chunk.GetPosZ() * cChunkDef::Width;
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
- if (Chunk == NULL)
+ if (Chunk == nullptr)
{
// Inside an unloaded chunk, abort
return;
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index 328a70846..953213bca 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -42,7 +42,7 @@ bool cBoat::DoTakeDamage(TakeDamageInfo & TDI)
if (GetHealth() == 0)
{
- if (TDI.Attacker != NULL)
+ if (TDI.Attacker != nullptr)
{
if (TDI.Attacker->IsPlayer())
{
@@ -64,7 +64,7 @@ void cBoat::OnRightClicked(cPlayer & a_Player)
{
super::OnRightClicked(a_Player);
- if (m_Attachee != NULL)
+ if (m_Attachee != nullptr)
{
if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
{
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index da85dec50..afc61c73f 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -29,8 +29,8 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
: m_UniqueID(0)
, m_Health(1)
, m_MaxHealth(1)
- , m_AttachedTo(NULL)
- , m_Attachee(NULL)
+ , m_AttachedTo(nullptr)
+ , m_Attachee(nullptr)
, m_bDirtyHead(true)
, m_bDirtyOrientation(true)
, m_bHasSentNoSpeed(true)
@@ -38,9 +38,9 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
, m_Gravity(-9.81f)
, m_LastPos(a_X, a_Y, a_Z)
, m_IsInitialized(false)
- , m_WorldTravellingFrom(NULL)
+ , m_WorldTravellingFrom(nullptr)
, m_EntityType(a_EntityType)
- , m_World(NULL)
+ , m_World(nullptr)
, m_IsFireproof(false)
, m_TicksSinceLastBurnDamage(0)
, m_TicksSinceLastLavaDamage(0)
@@ -73,7 +73,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
cEntity::~cEntity()
{
// Before deleting, the entity needs to have been removed from the world, if ever added
- ASSERT((m_World == NULL) || !m_World->HasEntity(m_UniqueID));
+ ASSERT((m_World == nullptr) || !m_World->HasEntity(m_UniqueID));
/*
// DEBUG:
@@ -85,11 +85,11 @@ cEntity::~cEntity()
);
*/
- if (m_AttachedTo != NULL)
+ if (m_AttachedTo != nullptr)
{
Detach();
}
- if (m_Attachee != NULL)
+ if (m_Attachee != nullptr)
{
m_Attachee->Detach();
}
@@ -242,7 +242,7 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R
TDI.FinalDamage = a_FinalDamage;
Vector3d Heading(0, 0, 0);
- if (a_Attacker != NULL)
+ if (a_Attacker != nullptr)
{
Heading = a_Attacker->GetLookVector() * (a_Attacker->IsSprinting() ? 16 : 11);
Heading.y = 1.6;
@@ -265,7 +265,7 @@ void cEntity::SetYawFromSpeed(void)
SetYaw(0);
return;
}
- SetYaw(atan2(m_Speed.x, m_Speed.z) * 180 / PI);
+ SetYaw(atan2(m_Speed.x, m_Speed.z) * 180 / M_PI);
}
@@ -282,7 +282,7 @@ void cEntity::SetPitchFromSpeed(void)
SetPitch(0);
return;
}
- SetPitch(atan2(m_Speed.y, xz) * 180 / PI);
+ SetPitch(atan2(m_Speed.y, xz) * 180 / M_PI);
}
@@ -308,7 +308,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
return false;
}
- if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
+ if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{
cPlayer * Player = (cPlayer *)a_TDI.Attacker;
@@ -544,7 +544,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
m_Health = std::max(m_Health, 0);
// Add knockback:
- if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL))
+ if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != nullptr))
{
int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment
if (KnockbackLevel < 1)
@@ -571,7 +571,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
KilledBy(a_TDI);
- if (a_TDI.Attacker != NULL)
+ if (a_TDI.Attacker != nullptr)
{
a_TDI.Attacker->Killed(this);
}
@@ -778,7 +778,7 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
m_InvulnerableTicks--;
}
- if (m_AttachedTo != NULL)
+ if (m_AttachedTo != nullptr)
{
Vector3d DeltaPos = m_Pos - m_AttachedTo->GetPosition();
if (DeltaPos.Length() > 0.5)
@@ -1092,7 +1092,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
{
if (!m_IsFireproof)
{
- TakeDamage(dtOnFire, NULL, BURN_DAMAGE, 0);
+ TakeDamage(dtOnFire, nullptr, BURN_DAMAGE, 0);
}
m_TicksSinceLastBurnDamage = 0;
}
@@ -1163,7 +1163,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
{
if (!m_IsFireproof)
{
- TakeDamage(dtLavaContact, NULL, LAVA_DAMAGE, 0);
+ TakeDamage(dtLavaContact, nullptr, LAVA_DAMAGE, 0);
}
m_TicksSinceLastLavaDamage = 0;
}
@@ -1184,7 +1184,7 @@ void cEntity::TickBurning(cChunk & a_Chunk)
{
if (!m_IsFireproof)
{
- TakeDamage(dtFireContact, NULL, FIRE_DAMAGE, 0);
+ TakeDamage(dtFireContact, nullptr, FIRE_DAMAGE, 0);
}
m_TicksSinceLastFireDamage = 0;
}
@@ -1213,7 +1213,7 @@ void cEntity::TickInVoid(cChunk & a_Chunk)
{
if (m_TicksSinceLastVoidDamage == 20)
{
- TakeDamage(dtInVoid, NULL, 2, 0);
+ TakeDamage(dtInVoid, nullptr, 2, 0);
m_TicksSinceLastVoidDamage = 0;
}
else
@@ -1239,7 +1239,7 @@ void cEntity::DetectCacti(void)
(((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))))
)
{
- TakeDamage(dtCactusContact, NULL, 1, 0);
+ TakeDamage(dtCactusContact, nullptr, 1, 0);
}
}
@@ -1380,7 +1380,7 @@ bool cEntity::DetectPortal()
bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
{
UNUSED(a_ShouldSendRespawn);
- ASSERT(a_World != NULL);
+ ASSERT(a_World != nullptr);
if (GetWorld() == a_World)
{
@@ -1406,7 +1406,7 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
bool cEntity::MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn)
{
cWorld * World = cRoot::Get()->GetWorld(a_WorldName);
- if (World == NULL)
+ if (World == nullptr)
{
LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str());
return false;
@@ -1493,7 +1493,7 @@ void cEntity::HandleAir(void)
if (m_AirTickTimer <= 0)
{
// Damage player
- TakeDamage(dtDrowning, NULL, 1, 1, 0);
+ TakeDamage(dtDrowning, nullptr, 1, 1, 0);
// Reset timer
m_AirTickTimer = DROWNING_TICKS;
}
@@ -1708,7 +1708,7 @@ void cEntity::AttachTo(cEntity * a_AttachTo)
// Already attached to that entity, nothing to do here
return;
}
- if (m_AttachedTo != NULL)
+ if (m_AttachedTo != nullptr)
{
// Detach from any previous entity:
Detach();
@@ -1726,14 +1726,14 @@ void cEntity::AttachTo(cEntity * a_AttachTo)
void cEntity::Detach(void)
{
- if (m_AttachedTo == NULL)
+ if (m_AttachedTo == nullptr)
{
// Attached to no entity, our work is done
return;
}
- m_AttachedTo->m_Attachee = NULL;
- m_AttachedTo = NULL;
- m_World->BroadcastAttachEntity(*this, NULL);
+ m_AttachedTo->m_Attachee = nullptr;
+ m_AttachedTo = nullptr;
+ m_World->BroadcastAttachEntity(*this, nullptr);
}
@@ -1956,7 +1956,7 @@ void cEntity::HandleSpeedFromAttachee(float a_Forward, float a_Sideways)
void cEntity::SteerVehicle(float a_Forward, float a_Sideways)
{
- if (m_AttachedTo == NULL)
+ if (m_AttachedTo == nullptr)
{
return;
}
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 07754791d..af545fe4a 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -32,7 +32,7 @@
#define POSZ_TOINT FloorC(GetPosZ())
#define POS_TOINT Vector3i(POSXTOINT, POSYTOINT, POSZTOINT)
-#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); if ((ChunkVarName == NULL) || !ChunkVarName->IsValid()) { return; }
+#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); if ((ChunkVarName == nullptr) || !ChunkVarName->IsValid()) { return; }
@@ -309,7 +309,7 @@ public:
/// Returns the currently equipped boots; empty item if none
virtual cItem GetEquippedBoots(void) const { return cItem(); }
- /// Called when the health drops below zero. a_Killer may be NULL (environmental damage)
+ /// Called when the health drops below zero. a_Killer may be nullptr (environmental damage)
virtual void KilledBy(TakeDamageInfo & a_TDI);
/// Called when the entity kills another entity
@@ -401,7 +401,7 @@ public:
void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; }
/// Updates clients of changes in the entity.
- virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL);
+ virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = nullptr);
/// Attaches to the specified entity; detaches from any previous one first
void AttachTo(cEntity * a_AttachTo);
@@ -450,7 +450,7 @@ public:
virtual void OnRightClicked(cPlayer & a_Player) {}
/// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy().
- virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL)
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr)
{
UNUSED(a_Drops);
UNUSED(a_Killer);
@@ -471,10 +471,10 @@ protected:
int m_Health;
int m_MaxHealth;
- /// The entity to which this entity is attached (vehicle), NULL if none
+ /// The entity to which this entity is attached (vehicle), nullptr if none
cEntity * m_AttachedTo;
- /// The entity which is attached to this entity (rider), NULL if none
+ /// The entity which is attached to this entity (rider), nullptr if none
cEntity * m_Attachee;
/** Stores whether head yaw has been set manually */
@@ -502,7 +502,7 @@ protected:
bool m_IsInitialized;
/** World entity is travelling from
- Set to a valid world pointer by MoveToWorld; reset to NULL when the entity is removed from the old world
+ Set to a valid world pointer by MoveToWorld; reset to nullptr when the entity is removed from the old world
Can't be a simple boolean as context switches between worlds may leave the new chunk processing (and therefore immediately removing) the entity before the old chunk could remove it
*/
cWorld * m_WorldTravellingFrom;
diff --git a/src/Entities/EntityEffect.cpp b/src/Entities/EntityEffect.cpp
index b1ddaa30e..bae686b77 100644
--- a/src/Entities/EntityEffect.cpp
+++ b/src/Entities/EntityEffect.cpp
@@ -216,7 +216,7 @@ cEntityEffect * cEntityEffect::CreateEntityEffect(cEntityEffect::eType a_EffectT
}
ASSERT(!"Unhandled entity effect type!");
- return NULL;
+ return nullptr;
}
@@ -329,7 +329,7 @@ void cEntityEffectInstantHealth::OnActivate(cPawn & a_Target)
if (a_Target.IsMob() && ((cMonster &) a_Target).IsUndead())
{
- a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
+ a_Target.TakeDamage(dtPotionOfHarming, nullptr, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
return;
}
a_Target.Heal(amount);
@@ -352,7 +352,7 @@ void cEntityEffectInstantDamage::OnActivate(cPawn & a_Target)
a_Target.Heal(amount);
return;
}
- a_Target.TakeDamage(dtPotionOfHarming, NULL, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
+ a_Target.TakeDamage(dtPotionOfHarming, nullptr, amount, 0); // TODO: Store attacker in a pointer-safe way, pass to TakeDamage
}
@@ -452,7 +452,7 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
// Cannot take poison damage when health is at 1
if (a_Target.GetHealth() > 1)
{
- a_Target.TakeDamage(dtPoisoning, NULL, 1, 0);
+ a_Target.TakeDamage(dtPoisoning, nullptr, 1, 0);
}
}
}
@@ -473,7 +473,7 @@ void cEntityEffectWither::OnTick(cPawn & a_Target)
if ((m_Ticks % frequency) == 0)
{
- a_Target.TakeDamage(dtWither, NULL, 1, 0);
+ a_Target.TakeDamage(dtWither, nullptr, 1, 0);
}
}
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index 73d5cbfed..751308661 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -45,7 +45,7 @@ void cExpOrb::SpawnOn(cClientHandle & a_Client)
void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
{
cPlayer * a_ClosestPlayer(m_World->FindClosestPlayer(Vector3f(GetPosition()), 5));
- if (a_ClosestPlayer != NULL)
+ if (a_ClosestPlayer != nullptr)
{
Vector3f a_PlayerPos(a_ClosestPlayer->GetPosition());
a_PlayerPos.y++;
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp
index 159429147..5fe6a1238 100644
--- a/src/Entities/Floater.cpp
+++ b/src/Entities/Floater.cpp
@@ -22,7 +22,7 @@ public:
m_Pos(a_Pos),
m_NextPos(a_NextPos),
m_MinCoeff(1),
- m_HitEntity(NULL)
+ m_HitEntity(nullptr)
{
}
virtual bool Item(cEntity * a_Entity) override
diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp
index f512324eb..b7aac52d0 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 != NULL) && a_TDI.Attacker->IsPlayer() && !((cPlayer *)a_TDI.Attacker)->IsGameModeCreative())
+ if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPlayer() && !((cPlayer *)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 != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
+ if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
{
a_Items.push_back(cItem(E_ITEM_ITEM_FRAME));
}
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index f45e7bb69..22e046800 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -36,7 +36,7 @@ public:
virtual bool Item(cEntity * a_Entity) override
{
- ASSERT(a_Entity != NULL);
+ ASSERT(a_Entity != nullptr);
if (!a_Entity->IsPlayer() && !a_Entity->IsMob() && !a_Entity->IsMinecart() && !a_Entity->IsBoat())
{
@@ -130,7 +130,7 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
int RelPosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width;
int RelPosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width;
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
- if (Chunk == NULL)
+ if (Chunk == nullptr)
{
// Inside an unloaded chunk, bail out all processing
return;
@@ -806,7 +806,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
{
- cMinecartCollisionCallback MinecartCollisionCallback(GetPosition(), GetHeight(), GetWidth(), GetUniqueID(), ((m_Attachee == NULL) ? -1 : m_Attachee->GetUniqueID()));
+ cMinecartCollisionCallback MinecartCollisionCallback(GetPosition(), GetHeight(), GetWidth(), GetUniqueID(), ((m_Attachee == nullptr) ? -1 : m_Attachee->GetUniqueID()));
int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(POSX_TOINT, POSZ_TOINT, ChunkX, ChunkZ);
m_World->ForEachEntityInChunk(ChunkX, ChunkZ, MinecartCollisionCallback);
@@ -980,7 +980,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta)
bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
{
- if ((TDI.Attacker != NULL) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative())
+ if ((TDI.Attacker != nullptr) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative())
{
Destroy();
TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative
@@ -1074,7 +1074,7 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
{
super::OnRightClicked(a_Player);
- if (m_Attachee != NULL)
+ if (m_Attachee != nullptr)
{
if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
{
@@ -1120,14 +1120,14 @@ void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
{
// If the window is not created, open it anew:
cWindow * Window = GetWindow();
- if (Window == NULL)
+ if (Window == nullptr)
{
OpenNewWindow();
Window = GetWindow();
}
// Open the window for the player:
- if (Window != NULL)
+ if (Window != nullptr)
{
if (a_Player.GetWindow() != Window)
{
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index ab906fd06..40e22c641 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -140,9 +140,9 @@ protected:
{
UNUSED(a_SlotNum);
ASSERT(a_Grid == &m_Contents);
- if (m_World != NULL)
+ if (m_World != nullptr)
{
- if (GetWindow() != NULL)
+ if (GetWindow() != nullptr)
{
GetWindow()->BroadcastWholeWindow();
}
diff --git a/src/Entities/Painting.cpp b/src/Entities/Painting.cpp
index e217556c7..1aa6da0a1 100644
--- a/src/Entities/Painting.cpp
+++ b/src/Entities/Painting.cpp
@@ -43,7 +43,7 @@ void cPainting::Tick(float a_Dt, cChunk & a_Chunk)
void cPainting::GetDrops(cItems & a_Items, cEntity * a_Killer)
{
- if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
+ if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
{
a_Items.push_back(cItem(E_ITEM_PAINTING));
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 24daba048..b417feb86 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -55,8 +55,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_Stance(0.0),
m_Inventory(*this),
m_EnderChestContents(9, 3),
- m_CurrentWindow(NULL),
- m_InventoryWindow(NULL),
+ m_CurrentWindow(nullptr),
+ m_InventoryWindow(nullptr),
m_GameMode(eGameMode_NotSet),
m_IP(""),
m_ClientHandle(a_Client),
@@ -77,10 +77,10 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_IsChargingBow(false),
m_BowCharge(0),
m_FloaterID(-1),
- m_Team(NULL),
+ m_Team(nullptr),
m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL),
m_bIsTeleporting(false),
- m_UUID((a_Client != NULL) ? a_Client->GetUUID() : ""),
+ m_UUID((a_Client != nullptr) ? a_Client->GetUUID() : ""),
m_CustomName("")
{
m_InventoryWindow = new cInventoryWindow(*this);
@@ -93,7 +93,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_LastPlayerListTime = std::chrono::steady_clock::now();
m_PlayerName = a_PlayerName;
- cWorld * World = NULL;
+ cWorld * World = nullptr;
if (!LoadFromDisk(World))
{
m_Inventory.Clear();
@@ -141,10 +141,10 @@ cPlayer::~cPlayer(void)
SaveToDisk();
- m_ClientHandle = NULL;
+ m_ClientHandle = nullptr;
delete m_InventoryWindow;
- m_InventoryWindow = NULL;
+ m_InventoryWindow = nullptr;
LOGD("Player %p deleted", this);
}
@@ -183,12 +183,12 @@ void cPlayer::SpawnOn(cClientHandle & a_Client)
void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
{
- if (m_ClientHandle != NULL)
+ if (m_ClientHandle != nullptr)
{
if (m_ClientHandle->IsDestroyed())
{
// This should not happen, because destroying a client will remove it from the world, but just in case
- m_ClientHandle = NULL;
+ m_ClientHandle = nullptr;
return;
}
@@ -500,7 +500,7 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
if (Damage > 0)
{
// cPlayer makes sure damage isn't applied in creative, no need to check here
- TakeDamage(dtFalling, NULL, Damage, Damage, 0);
+ TakeDamage(dtFalling, nullptr, Damage, Damage, 0);
// Fall particles
GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, (int)GetPosY() - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */);
@@ -647,7 +647,7 @@ void cPlayer::AbortEating(void)
void cPlayer::SendHealth(void)
{
- if (m_ClientHandle != NULL)
+ if (m_ClientHandle != nullptr)
{
m_ClientHandle->SendHealth();
}
@@ -659,7 +659,7 @@ void cPlayer::SendHealth(void)
void cPlayer::SendExperience(void)
{
- if (m_ClientHandle != NULL)
+ if (m_ClientHandle != nullptr)
{
m_ClientHandle->SendExperience();
m_bDirtyExperience = false;
@@ -855,11 +855,11 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
}
}
- if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
+ if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
{
cPlayer * Attacker = (cPlayer *)a_TDI.Attacker;
- if ((m_Team != NULL) && (m_Team == Attacker->m_Team))
+ if ((m_Team != nullptr) && (m_Team == Attacker->m_Team))
{
if (!m_Team->AllowsFriendlyFire())
{
@@ -911,7 +911,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
SaveToDisk(); // Save it, yeah the world is a tough place !
- if ((a_TDI.Attacker == NULL) && m_World->ShouldBroadcastDeathMessages())
+ if ((a_TDI.Attacker == nullptr) && m_World->ShouldBroadcastDeathMessages())
{
AString DamageText;
switch (a_TDI.DamageType)
@@ -937,7 +937,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
}
GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str()));
}
- else if (a_TDI.Attacker == NULL) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough
+ else if (a_TDI.Attacker == nullptr) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough
{
// no-op
}
@@ -993,7 +993,7 @@ void cPlayer::Killed(cEntity * a_Victim)
void cPlayer::Respawn(void)
{
- ASSERT(m_World != NULL);
+ ASSERT(m_World != nullptr);
m_Health = GetMaxHealth();
SetInvulnerableTicks(20);
@@ -1103,9 +1103,9 @@ void cPlayer::SetTeam(cTeam * a_Team)
cTeam * cPlayer::UpdateTeam(void)
{
- if (m_World == NULL)
+ if (m_World == nullptr)
{
- SetTeam(NULL);
+ SetTeam(nullptr);
}
else
{
@@ -1138,7 +1138,7 @@ void cPlayer::OpenWindow(cWindow * a_Window)
void cPlayer::CloseWindow(bool a_CanRefuse)
{
- if (m_CurrentWindow == NULL)
+ if (m_CurrentWindow == nullptr)
{
m_CurrentWindow = m_InventoryWindow;
return;
@@ -1163,7 +1163,7 @@ void cPlayer::CloseWindow(bool a_CanRefuse)
void cPlayer::CloseWindowIfID(char a_WindowID, bool a_CanRefuse)
{
- if ((m_CurrentWindow == NULL) || (m_CurrentWindow->GetWindowID() != a_WindowID))
+ if ((m_CurrentWindow == nullptr) || (m_CurrentWindow->GetWindowID() != a_WindowID))
{
return;
}
@@ -1350,7 +1350,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos)
// Y = -999 and X, Z = attempting to create speed, usually up to 0.03
// We cannot test m_AttachedTo, because when deattaching, the server thinks the client is already deattached while
// the client may still send more of these nonsensical packets.
- if (m_AttachedTo != NULL)
+ if (m_AttachedTo != nullptr)
{
Vector3d AddSpeed(a_NewPos);
AddSpeed.y = 0;
@@ -1577,7 +1577,7 @@ void cPlayer::TossItems(const cItems & a_Items)
bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
{
- ASSERT(a_World != NULL);
+ ASSERT(a_World != nullptr);
if (GetWorld() == a_World)
{
@@ -1586,7 +1586,7 @@ bool cPlayer::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn)
}
// Send the respawn packet:
- if (a_ShouldSendRespawn && (m_ClientHandle != NULL))
+ if (a_ShouldSendRespawn && (m_ClientHandle != nullptr))
{
m_ClientHandle->SendRespawn(a_World->GetDimension());
}
@@ -1648,7 +1648,7 @@ bool cPlayer::LoadFromDisk(cWorldPtr & a_World)
GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str(), OfflineUsage
);
- if (a_World == NULL)
+ if (a_World == nullptr)
{
a_World = cRoot::Get()->GetDefaultWorld();
}
@@ -1725,7 +1725,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
m_LoadedWorldName = root.get("world", "world").asString();
a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), false);
- if (a_World == NULL)
+ if (a_World == nullptr)
{
a_World = cRoot::Get()->GetDefaultWorld();
}
@@ -1791,7 +1791,7 @@ bool cPlayer::SaveToDisk()
root["SpawnY"] = GetLastBedPos().y;
root["SpawnZ"] = GetLastBedPos().z;
- if (m_World != NULL)
+ if (m_World != nullptr)
{
root["world"] = m_World->GetName();
if (m_GameMode == m_World->GetGameMode())
@@ -1945,7 +1945,7 @@ void cPlayer::HandleFood(void)
else if ((m_FoodLevel <= 0) && (m_Health > 1))
{
// Damage from starving
- TakeDamage(dtStarving, NULL, 1, 1, 0);
+ TakeDamage(dtStarving, nullptr, 1, 1, 0);
}
}
}
@@ -2014,7 +2014,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
{
StatValue Value = (StatValue)floor(a_DeltaPos.Length() * 100 + 0.5);
- if (m_AttachedTo == NULL)
+ if (m_AttachedTo == nullptr)
{
if (IsClimbing())
{
@@ -2087,7 +2087,7 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
}
// If riding anything, apply no food exhaustion
- if (m_AttachedTo != NULL)
+ if (m_AttachedTo != nullptr)
{
return;
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 8dd5bdb19..c643aaa8e 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -176,10 +176,10 @@ public:
AString GetIP(void) const { return m_IP; } // tolua_export
- /** Returns the associated team, NULL if none */
+ /** Returns the associated team, nullptr if none */
cTeam * GetTeam(void) { return m_Team; } // tolua_export
- /** Sets the player team, NULL if none */
+ /** Sets the player team, nullptr if none */
void SetTeam(cTeam * a_Team);
// tolua_end
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index ab25ac30c..1768714f8 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -135,7 +135,7 @@ public:
m_Pos(a_Pos),
m_NextPos(a_NextPos),
m_MinCoeff(1),
- m_HitEntity(NULL)
+ m_HitEntity(nullptr)
{
}
@@ -221,9 +221,9 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a
super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height),
m_ProjectileKind(a_Kind),
m_CreatorData(
- ((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1),
- ((a_Creator != NULL) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""),
- ((a_Creator != NULL) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments())
+ ((a_Creator != nullptr) ? a_Creator->GetUniqueID() : -1),
+ ((a_Creator != nullptr) ? (a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "") : ""),
+ ((a_Creator != nullptr) ? a_Creator->GetEquippedWeapon().m_Enchantments : cEnchantments())
),
m_IsInGround(false)
{
@@ -251,7 +251,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Ve
cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed)
{
Vector3d Speed;
- if (a_Speed != NULL)
+ if (a_Speed != nullptr)
{
Speed = *a_Speed;
}
@@ -269,10 +269,10 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
case pkWitherSkull: return new cWitherSkullEntity (a_Creator, a_X, a_Y, a_Z, Speed);
case pkFirework:
{
- ASSERT(a_Item != NULL);
+ ASSERT(a_Item != nullptr);
if (a_Item->m_FireworkItem.m_Colours.empty())
{
- return NULL;
+ return nullptr;
}
return new cFireworkEntity(a_Creator, a_X, a_Y, a_Z, *a_Item);
@@ -280,7 +280,7 @@ cProjectileEntity * cProjectileEntity::Create(eKind a_Kind, cEntity * a_Creator,
}
LOGWARNING("%s: Unknown projectile kind: %d", __FUNCTION__, a_Kind);
- return NULL;
+ return nullptr;
}
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index 03eda9739..3861f9ecc 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -46,7 +46,7 @@ public:
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height);
- static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = NULL);
+ static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = nullptr);
/// Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace);
@@ -110,7 +110,7 @@ protected:
eKind m_ProjectileKind;
/** The structure for containing the entity ID and name who has created this projectile
- The ID and/or name may be NULL (e.g. for dispensers/mobs)
+ The ID and/or name may be nullptr (e.g. for dispensers/mobs)
*/
CreatorData m_CreatorData;