From 4b60d55d8d97da113dbb2e90c2a4834e8e813629 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 7 Feb 2022 00:53:44 +0000 Subject: Spectation: keep track of spectators + Keep a list of spectators so that pointer clean-up can happen when the spectated is killed. * Fix invalid game state when riding/spectating and then entering or leaving spectator mode. --- src/Entities/Player.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index e0a88814d..2f2b9d62e 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -93,6 +93,9 @@ public: cPlayer(const std::shared_ptr & a_Client); virtual ~cPlayer() override; + /** Called when spectation stops, because the player crouched or when the entity we're spectating gets removed from the world. */ + void OnLoseSpectated(); + // tolua_begin /** Sets the experience total @@ -184,7 +187,7 @@ public: void SendRotation(double a_YawDegrees, double a_PitchDegrees); /** Spectates the target entity. If a_Target is nullptr or a pointer to self, end spectation. */ - void SpectateEntity(const cEntity * a_Target); + void SpectateEntity(cEntity * a_Target); /** Returns the position where projectiles thrown by this player should start, player eye position + adjustment */ Vector3d GetThrowStartPos(void) const; @@ -731,7 +734,7 @@ private: cTeam * m_Team; /** The entity that this player is spectating, nullptr if none. */ - const cEntity * m_Spectating; + cEntity * m_Spectating; StatisticsManager m_Stats; -- cgit v1.2.3