MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / RequestSpectateMode

Method RequestSpectateMode

Sources/Jazz2/Multiplayer/MpLevelHandler.cpp:5958–5976  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5956 }
5957
5958 void MpLevelHandler::RequestSpectateMode(bool enable)
5959 {
5960 if (_players.empty()) {
5961 return;
5962 }
5963
5964 if (_isServer) {
5965 for (auto& [playerPeer, peerDesc] : *_networkManager->GetPeers()) {
5966 if (!peerDesc->RemotePeer && peerDesc->Player) {
5967 SetPlayerSpectateMode(peerDesc->Player, enable ? SpectateMode::Requested : SpectateMode::None);
5968 }
5969 }
5970 } else {
5971 MemoryStream packet(5);
5972 packet.WriteVariableUint32(_lastSpawnedActorId);
5973 packet.WriteValue<std::uint8_t>(enable ? 1 : 0);
5974 _networkManager->SendTo(AllPeers, NetworkChannel::Main, (std::uint8_t)ClientPacketType::PlayerSpectateRequest, packet);
5975 }
5976 }
5977
5978 bool MpLevelHandler::IsSpectating()
5979 {

Callers 1

ToggleSpectateMethod · 0.80

Calls 4

GetPeersMethod · 0.80
WriteVariableUint32Method · 0.80
SendToMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected