PlayerRoomIndexing and CustomRoomProperties.

Options
With PUN Classic:

After a recent upgrade to Unity 2019.1.2f and to PUN 1.97 form 1.91, upon creating a room, PlayerRoomIndexing errors twice.

IndexOutOfRangeException: Index was outside the bounds of the array.
ExitGames.UtilityScripts.PlayerRoomIndexing.RefreshData () (at Assets/AssetStorePackages/Photon Unity Networking/UtilityScripts/PhotonPlayer/PlayerRoomIndexing.cs:224)

Any ideas what is going on?

Comments

  • Spektre
    Options
    bump
  • Spektre
    Options
    Could really use some help on this one folks.

    To replicate.

    1. Make a scene with an empty game object named PlayerRoomIndexing. Add the script found at Photon Unity Networking>UtilityScripts>Photon Player>PlayerRoomIndexing to the object.
    2. Create a new Room with:

    RoomOptions roomOptions = new RoomOptions(); roomOptions.IsOpen = true; roomOptions.IsVisible = false; PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);

    PlayerRoomIndexing will error twice immediately with the above error.

    IndexOutOfRangeException: Index was outside the bounds of the array.
    ExitGames.UtilityScripts.PlayerRoomIndexing.RefreshData () (at Assets/AssetStorePackages/Photon Unity Networking/UtilityScripts/PhotonPlayer/PlayerRoomIndexing.cs:224)

    This corresponds to this line.
    _playerIds[_entry.Value] = _p.ID;

    Commenting out the vestigal: Debug.Log("Entry; "+_entry.Key+":"+_entry.Value);
    above this yields a Key of 1 and a value of 0
  • Spektre
    Options
    Found the issue. This routine requires the MaxPlayers property for a room be set. This should be documented in the code.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2019
    Options
    Hi @Spektre,

    it looks like it's the case yes.
    sorry, we didn't explicitly state this in the documentation.

    can you try replacing line 209 in "Assets/AssetStorePackages/Photon Unity Networking/UtilityScripts/PhotonPlayer/PlayerRoomIndexing.cs":
    _playerIds = new int[PhotonNetwork.room.MaxPlayers];
    
    with
    int count = PhotonNetwork.room.MaxPlayers;
                    if (count == 0)
                    {
                        count = PhotonNetwork.room.PlayerCount;
                    }
    		_playerIds = new int[count];
    this fix may work even with MaxPlayers = 0.
    please try and let us know.