Skip to content

Commit

Permalink
disable spectating when a spectating player disconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Oct 13, 2023
1 parent 5dfb852 commit 2e184f0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Server/Source/player_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,17 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
{
continue;
}

Player* other = static_cast<Player*>(p);

// Related issue: https://github.com/openmultiplayer/open.mp/issues/735
// Disable spectator's spectating state when spectated player is disconnected
// This also makes spectateData values to be accurate and not remain with old data
if (other->spectateData_.type == PlayerSpectateData::ESpectateType::Player && other->spectateData_.spectateID == player.getID())
{
other->setSpectating(false);
}

if (player.streamedFor_.valid(other->poolID))
{
--other->numStreamed_;
Expand Down

0 comments on commit 2e184f0

Please sign in to comment.