[BUG] SpawnManagerBase Dictionary m_ActorNumberByPhotonViewIndex never update

Nixou

New member
Hello,

We found a critical bug when a player left the room.
The dictionary m_ActorNumberByPhotonViewIndex is not updated with the new index of the m_Players table.

To reproduce the bug
Connect 5 users
Player 2 left and rejoin => m_Players is recalculated but m_ActorNumberByPhotonViewIndex is not
Player 5 left => The wrong player is destroyed

Because the index return below is wrong
// Notify others that the player has left the room.
if (m_ActorNumberByPhotonViewIndex.TryGetValue(otherPlayer.ActorNumber, out int index)) {
Debug.Log("OnPlayerLeftRoom - Index =" + index);
var photonView = m_Players[index];


Fix proposed :

Add m_ActorNumberByPhotonViewIndex[m_Players[j + 1].Owner.ActorNumber] = j;
in
for (int j = index; j < m_PlayerCount - 1; ++j) {
m_Players[j] = m_Players[j + 1];
}

And Add
m_ActorNumberByPhotonViewIndex.Remove(otherPlayer.ActorNumber);

at the end of the function.

Can you confirm Justin please ?

Nixou
 
Top