Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle spectating when a player disconnects #740

Merged
merged 3 commits into from
Oct 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
disable spectating when a spectating player disconnects
AmyrAhmady committed Oct 13, 2023
commit 2e184f0455b90322528c08381df0a0af966a5523
10 changes: 10 additions & 0 deletions Server/Source/player_pool.hpp
Original file line number Diff line number Diff line change
@@ -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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do this for vehicles as well.

{
other->setSpectating(false);
}

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