Deleted key values pairs being restored in the custom room hash table for the current room???

Options

Much to my surprise this seems to be happening:

  • I add a key value pair to hold some game state
  • I later delete the key value pair
  • I kept playing along when testing a multiplayer session
  • the key value pairs that should be deleted came back somehow
  • game is messed up - oops

My first question is are there any known issue with using the the custom properties hash table for the current room?

Second question how can I ensure the date is deleted. Here is my method to update the hash table:

    /// <summary>
    /// Remove a key value pair from the state.
    /// This method will remove pair from the local hash table and the Photon network.
    /// </summary>
    /// <param name="key"></param>
    private void SyncStateRemove(string key)
    {
      // To remove the property you need to set the property to null.
      PhotonHashTable table = new PhotonHashTable() { { key, null } };
      PhotonNetwork.CurrentRoom.SetCustomProperties(table);

      if (mapProperties.ContainsKey(key))
      {
        mapProperties[key] = null;
      }
    }


Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options

    Hi @ManjitB,

    Make sure RoomOptions.DeleteNullProperties is true (default) when creating rooms.

          if (mapProperties.ContainsKey(key))
          {
            mapProperties[key] = null;
          }
    

    This snippet should not be needed.

    Instead you need to wait until OnRoomPropertiesUpdate is called.

  • ManjitB
    Options

    Is this a bug? Intellisense says it defaults to false:

    We are using version 2.40.

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options

    Hi @ManjitB,

    My bad then set it to true.

    I thought it was true by default.