room.IsOpen bug in Photon-OnPremise-Server-SDK_v4-0-29-11263

Hello,
that is from GameState.cs:
            if (updateOperation.MaxPlayers.HasValue && updateOperation.MaxPlayers.Value != this.MaxPlayer)
            {
                this.MaxPlayer = updateOperation.MaxPlayers.Value;
                this.properties[(byte)GameParameter.MaxPlayers] = this.MaxPlayer;
                changed = true;
            }

            if (updateOperation.IsOpen.HasValue && updateOperation.IsOpen.Value != this.IsOpen)
            {
                this.IsOpen = updateOperation.IsOpen.Value;
                this.properties[(byte)GameParameter.IsOpen] = this.MaxPlayer;
                changed = true;
            }
I think it should be
this.properties[(byte)GameParameter.IsOpen] = this.IsOpen;
instead of
this.properties[(byte)GameParameter.IsOpen] = this.MaxPlayer;

Comments

  • Hi @NikolayL,

    Thank you for choosing Photon and for reporting this!

    Indeed this was already fixed and the Photon Cloud is running a much more recent version with fix included.
    A newer Photon Server SDK version will be available soon.
  • Photon-OnPremise-Server-SDK_v4-0-29-11263 published more than a year ago.
    We have a problem - players often can join to closed rooms. I found one bug, but problem is still here.
    Can you please send me latest version of server?
  • hi, @NickolayL

    could you describe your issue more detailed? AFAIK, we did not have reports about this bug yet

    best,
    ilya
  • i'm closing game in plugin code with that code:
            
    namespace TestPlugins
    {
        class PestelTdmPlugin : TestPluginBase
        {
            public override void OnCreateGame(ICreateGameCallInfo info)
            {
                base.OnCreateGame(info);
                _timerId = PluginHost.CreateOneTimeTimer(OnMatchmakingTimerTick, 13000);
            }
    
            private void OnMatchmakingTimer()
            {
                    IsOpen = false;
                    // ... other things
            }
    
            #region IsOpen
            public const byte IsOpenKey = 253;
    
            public bool IsOpen
            {
                get
                {
                    if (PluginHost.GameProperties.ContainsKey(IsOpenKey))
                    {
                        return (bool)PluginHost.GameProperties[IsOpenKey];
                    }
                    return true;
                }
                set
                {
                    PluginHost.SetProperties(
                        actorNr: 0,
                        properties: new Hashtable() { { IsOpenKey, value } },
                        expected: null,
                        broadcast: true
                    );
                }
            }
            #endregion
        }
    }

    This code works as expected while I am testing it on local machine with 2...3 clients.
    But it doesn't work on production server with ~ 100 CCU - users often join to closed games.

    To fix it on server side, I'm using a hacked version of Photon.LoadBalancing.MasterServer.Lobby.GameState.cs:
         
                public bool IsOpen
                {
                    get
                    {
                        const string gameModeKey = "prop";
                        const int teamDeathmatchMode = 6;
                        const int timeForMatchmaking = 13;
    
                        try
                        {
                        
                            if (properties.ContainsKey(gameModeKey) &&
                                properties[gameModeKey] != null &&
                                properties[gameModeKey] is int &&
                                (int) properties[gameModeKey] == teamDeathmatchMode)
                            {
                                var sinceCreation = DateTime.UtcNow - CreateDateUtc;
                                if (sinceCreation > TimeSpan.FromSeconds(timeForMatchmaking))
                                {
                                    return false;
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            if (log.IsErrorEnabled)
                            {
                                log.Error("Can't check game mode in GameState.IsOpen: " + e.Message);
                            }
                        }
    
                        return _isOpen;
                    }
                    set
                    {
                        _isOpen = value;
                    }
                }
    It always return IsOpen = false for rooms older than 13 seconds. It solves the problem, but I don't want to keep dirty hacks in IsOpen getter =)

    Probably something wrong with my code to close room from plugin? I don't want to close room from one of clients - that isn't reliable
  • @NikolayL i have more questions

    are players able to join game on master or on both on master and on GS?

    in general it should not matter whether you have 3 clients on 1000. this could be for instance timeing issue. so that plyaers may join while game state is not updated yet

    best,
    ilya
Sign In or Register to comment.