Skip to content

Commit

Permalink
Merge pull request #745 from openmultiplayer/amir/spec
Browse files Browse the repository at this point in the history
remove extra sanity check in setSpectating
  • Loading branch information
AmyrAhmady authored Oct 18, 2023
2 parents cb19455 + 84ecc4d commit 87710d4
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions Server/Source/player_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,21 +606,6 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy

void setSpectating(bool spectating) override
{
NetCode::RPC::TogglePlayerSpectating togglePlayerSpectatingRPC;

// Reset internal player spectating data if ID is already set to a player
// Related issue: https://github.com/openmultiplayer/open.mp/issues/735
// UPD: Also send player spectating RPC to disable it first in client internally
if (spectating && spectateData_.type == PlayerSpectateData::ESpectateType::Player && spectateData_.spectateID != INVALID_PLAYER_ID)
{
spectateData_.type = PlayerSpectateData::ESpectateType::None;
spectateData_.spectateID = INVALID_PLAYER_ID;
spectateData_.spectating = false;

togglePlayerSpectatingRPC.Enable = spectateData_.spectating;
PacketHelper::send(togglePlayerSpectatingRPC, *this);
}

if (spectating == spectateData_.spectating)
{
return;
Expand All @@ -646,6 +631,7 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy
// Is called in here, which it shouldn't according to samp structure.
}

NetCode::RPC::TogglePlayerSpectating togglePlayerSpectatingRPC;
spectateData_.spectating = spectating;
togglePlayerSpectatingRPC.Enable = spectating;
PacketHelper::send(togglePlayerSpectatingRPC, *this);
Expand Down

0 comments on commit 87710d4

Please sign in to comment.