Skip to content

Commit

Permalink
fix: Fixing IndexChanged hook not being called for NetworkRoomPlayer …
Browse files Browse the repository at this point in the history
…(#2242)

* adding Server to make sure index is only changed on the server

* removing calls to RecalculateRoomPlayerIndices on client
  • Loading branch information
James-Frowen committed Sep 13, 2020
1 parent 0c78fa0 commit 94da8ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions Assets/Mirror/Components/NetworkRoomManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ public override void OnServerAddPlayer(NetworkConnection conn)
OnRoomServerAddPlayer(conn);
}

[Server]
public void RecalculateRoomPlayerIndices()
{
if (roomSlots.Count > 0)
Expand Down
6 changes: 4 additions & 2 deletions Assets/Mirror/Components/NetworkRoomPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public void Start()
DontDestroyOnLoad(gameObject);

room.roomSlots.Add(this);
room.RecalculateRoomPlayerIndices();

if (NetworkServer.active)
room.RecalculateRoomPlayerIndices();

if (NetworkClient.active)
room.CallOnClientEnterRoom();
Expand All @@ -69,8 +71,8 @@ public virtual void OnDisable()
{
if (NetworkClient.active && NetworkManager.singleton is NetworkRoomManager room)
{
// only need to call this on client as server removes it before object is destroyed
room.roomSlots.Remove(this);
room.RecalculateRoomPlayerIndices();

room.CallOnClientExitRoom();
}
Expand Down

0 comments on commit 94da8ae

Please sign in to comment.