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

  • JohnTube
    JohnTube ✭✭✭✭✭
    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
  • They can join to GS so clients immediately starts to receive messages about other player movements, RPC etc, but it shouldn't happen before load game level, and game level is loads only after room closing.
    Can I force somehow to sync game state between GS and master?
    I can also add some additional logs in server code, if it can helps you to determinate problem source
  • @NikolayL
    you should see in code that everytime you update properties we force updating of state on master. but the thing is that even if master is not updated and clients arrive on GS they should be rejected because room is closed already.
    this means that something goes wrong on GameServer. i've checked our code. it works ask expected. and this code prooven to work in our cloud for few monthes. so, i would say you need to take a look carefully in your code

    best,
    ilya