Esempio n. 1
0
 public virtual void OnPlayerCountChanged(GameState gameState, int oldPlayerCount)
 {
     this.PlayerCount = this.PlayerCount - oldPlayerCount + gameState.PlayerCount;
     if (this.PlayerCount < 0)
     {
         log.WarnFormat("Got negative player count for lobby:'{0}/{1}', appId:{2}/{3}, PlayerCount:{4}, state debug:{5}",
                        this.Lobby.LobbyName, this.Lobby.LobbyType, this.Lobby.Application.ApplicationId,
                        this.Lobby.Application.Version, this.PlayerCount, gameState.GetDebugData());
         this.PlayerCount = 0;
     }
     if (log.IsDebugEnabled)
     {
         log.DebugFormat("PlayerCount updated: in list={0}, in game oldPlayerCount={1}, playerCount={2}, DebugData:{3}",
                         this.PlayerCount, oldPlayerCount, gameState.PlayerCount, gameState.GetDebugData());
     }
 }
Esempio n. 2
0
        // override in GameChannelList, SqlGameList
        protected virtual bool RemoveGameState(GameState gameState)
        {
            if (log.IsDebugEnabled)
            {
                LogGameState("RemoveGameState:", gameState);
            }

            if (this.nextJoinRandomStartNode != null && this.nextJoinRandomStartNode.Value == gameState)
            {
                this.AdvanceNextJoinRandomStartNode();
            }

            this.PlayerCount -= gameState.PlayerCount;

            gameState.OnRemoved();

            var gameId = gameState.Id;

            this.gameDict.Remove(gameId);
            this.changedGames.Remove(gameId);
            if (gameState.IsVisbleInLobby)
            {
                this.removedGames.Add(gameId);
            }

            if (this.PlayerCount < 0)
            {
                log.WarnFormat("Got negative player count for lobby:'{0}/{1}', appId:{2}/{3}, PlayerCount:{4}, GameStage:{5}",
                               this.Lobby.LobbyName, this.Lobby.LobbyType, this.Lobby.Application.ApplicationId, this.Lobby.Application.Version,
                               this.PlayerCount, gameState.GetDebugData());
                this.PlayerCount = 0;
            }

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("PlayerCount changed after game remove. New Value={0}", this.PlayerCount);
            }
            return(true);
        }