Skip to content

Commit

Permalink
Merge branch 'multiplayer/ui' of https://github.com/icosa-foundation/…
Browse files Browse the repository at this point in the history
…open-brush into multiplayer/ui
  • Loading branch information
sbanca committed Nov 11, 2024
2 parents ac4c240 + 00033e2 commit 5ca5b49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Assets/Scripts/Multiplayer/MultiplayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,12 @@ void OnPlayerLeft(int id)
}

// Ownership logic
// If the player that left was a room owner
if (m_Manager.GetPlayerRoomOwnershipStatus(id) == false) return;
// Check if any remaining player is the room owner
bool anyRoomOwner = m_RemotePlayers.Any(player => m_Manager.GetPlayerRoomOwnershipStatus(player.PlayerId))
|| (m_LocalPlayer != null && m_Manager.GetPlayerRoomOwnershipStatus(m_LocalPlayer.PlayerId));
// If there's still a room owner, no reassignment is needed
if (anyRoomOwner) return;
Debug.LogError("No room owner left after a player left, reassigning ownership.");

// If there are no other players left, the local player becomes the room owner
if (m_RemotePlayers.Count == 0)
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Multiplayer/Photon/PhotonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ public bool GetPlayerRoomOwnershipStatus(int playerId)
.Select(playerRef => m_Runner.GetPlayerObject(playerRef)?.GetComponent<PhotonPlayerRig>())
.FirstOrDefault(playerRig => playerRig != null && playerRig.PlayerId == playerId);

Debug.LogError($"Remote Player: {remotePlayer.PlayerId} is Room Owner: {remotePlayer.IsRoomOwner}");

return remotePlayer != null && remotePlayer.IsRoomOwner;
}

Expand Down

0 comments on commit 5ca5b49

Please sign in to comment.