コード例 #1
0
ファイル: PRoConClient.cs プロジェクト: Webs961/Procon-1
        protected void OnListPlayers(FrostbiteClient sender, List<CPlayerInfo> lstPlayers, CPlayerSubset cpsSubset) {
            if (cpsSubset.Subset == CPlayerSubset.PlayerSubsetType.All) {

                // Add or update players.
                foreach (CPlayerInfo cpiPlayer in lstPlayers) {
                    if (this.PlayerList.Contains(cpiPlayer.SoldierName) == true) {
                        this.PlayerList[this.PlayerList.IndexOf(this.PlayerList[cpiPlayer.SoldierName])] = cpiPlayer;
                    }
                    else {
                        this.PlayerList.Add(cpiPlayer);
                    }
                }

                PlayerDictionary recievedPlayerList = new PlayerDictionary(lstPlayers);
                foreach (CPlayerInfo storedPlayer in new List<CPlayerInfo>(this.PlayerList)) {

                    // If the stored player is not in the list we recieved
                    if (recievedPlayerList.Contains(storedPlayer.SoldierName) == false) {
                        // They have left the server, remove them from the master stored list.
                        this.PlayerList.Remove(storedPlayer.SoldierName);
                    }
                }

            }
        }
コード例 #2
0
ファイル: PRoConClient.cs プロジェクト: bensonk/Procon-1
        protected void OnListPlayers(FrostbiteClient sender, List<CPlayerInfo> lstPlayers, CPlayerSubset cpsSubset) {
            if (cpsSubset.Subset == CPlayerSubset.PlayerSubsetType.All) {
                // Add or update players.
                foreach (CPlayerInfo cpiPlayer in lstPlayers) {
                    if (PlayerList.Contains(cpiPlayer.SoldierName) == true) {
                        CPlayerInfo storedPlayer = PlayerList[PlayerList.IndexOf(PlayerList[cpiPlayer.SoldierName])];
                        cpiPlayer.JoinTime = CurrentServerInfo.ServerUptime;
                        if (storedPlayer.JoinTime == 0) { storedPlayer.JoinTime = CurrentServerInfo.ServerUptime; }
                        if (storedPlayer.JoinTime <= CurrentServerInfo.ServerUptime) {
                            cpiPlayer.SessionTime = CurrentServerInfo.ServerUptime - storedPlayer.JoinTime;
                            cpiPlayer.JoinTime = storedPlayer.JoinTime;
                        }
                        
                        PlayerList[PlayerList.IndexOf(PlayerList[cpiPlayer.SoldierName])] = cpiPlayer;
                    }
                    else {
                        cpiPlayer.JoinTime = CurrentServerInfo.ServerUptime;
                        PlayerList.Add(cpiPlayer);
                    }
                }

                var recievedPlayerList = new PlayerDictionary(lstPlayers);
                foreach (CPlayerInfo storedPlayer in new List<CPlayerInfo>(PlayerList)) {
                    // If the stored player is not in the list we recieved
                    if (recievedPlayerList.Contains(storedPlayer.SoldierName) == false) {
                        // They have left the server, remove them from the master stored list.
                        PlayerList.Remove(storedPlayer.SoldierName);
                    }
                }

                if (this.IsPRoConConnection == true && this.PlayTimesSynced == false) {
                    SendRequest(new List<string>() {
                        "procon.player.syncPlayTimes"
                    });
                    this.PlayTimesSynced = true;
                }
            }
        }