diff --git a/source/Entity/Player.cpp b/source/Entity/Player.cpp index 3d815a6f..3f903389 100644 --- a/source/Entity/Player.cpp +++ b/source/Entity/Player.cpp @@ -1345,12 +1345,21 @@ LightObj & CPlayer::GetSpectator() const } // ------------------------------------------------------------------------------------------------ -void CPlayer::SetSpectator(CPlayer & target) const +void CPlayer::SetSpectator(CPlayer * target) const { // Validate the managed identifier Validate(); - // Perform the requested operation - _Func->SetPlayerSpectateTarget(m_ID, target.GetID()); + // See if the given target is null + if (target == nullptr) + { + // Spectate an invalid player + _Func->SetPlayerSpectateTarget(m_ID, -1); + } + else + { + // Spectate the given target + _Func->SetPlayerSpectateTarget(m_ID, target->GetID()); + } } // ------------------------------------------------------------------------------------------------ diff --git a/source/Entity/Player.hpp b/source/Entity/Player.hpp index e84ac144..adb2acdc 100644 --- a/source/Entity/Player.hpp +++ b/source/Entity/Player.hpp @@ -727,7 +727,7 @@ public: /* -------------------------------------------------------------------------------------------- * Set the managed player entity to spectate the specified player entity. */ - void SetSpectator(CPlayer & target) const; + void SetSpectator(CPlayer * target) const; /* -------------------------------------------------------------------------------------------- * Redirect the managed player entity to the specified server.