Esempio n. 1
0
        public CServerInfo(List <string> parameters, List <string> variables)
        {
            this.RoundTime = this.ServerUptime = -1;

            for (int paramCount = 0, varCount = 0; paramCount < parameters.Count && varCount < variables.Count; paramCount++, varCount++)
            {
                switch (parameters[paramCount])
                {
                case "TeamScores":

                    int scoresCount = 0;

                    if (int.TryParse(variables[varCount], out scoresCount) == true)
                    {
                        scoresCount++;

                        this.TeamScores = TeamScore.GetTeamScores(variables.GetRange(varCount, scoresCount + 1));

                        varCount += scoresCount;
                    }
                    else
                    {
                        varCount--;
                    }

                    break;

                case "GameMod":

                    if (Enum.IsDefined(typeof(GameMods), variables[varCount]) == true)
                    {
                        this.GameMod = (GameMods)Enum.Parse(typeof(GameMods), variables[varCount]);
                    }

                    break;

                default:
                    PropertyInfo property = null;
                    if ((property = this.GetType().GetProperty(parameters[paramCount])) != null)
                    {
                        try {
                            // Geoff Green 08/10/2011 to account for a bug in BF3 release 872601 F sending back blank "" instead of a valid int.
                            if (variables[varCount].Length == 0 && property.PropertyType == typeof(int))
                            {
                                variables[varCount] = "0";
                            }

                            object value = TypeDescriptor.GetConverter(property.PropertyType).ConvertFrom(variables[varCount]);

                            if (value != null)
                            {
                                property.SetValue(this, value, null);
                            }
                        }
                        catch (Exception) { }
                    }

                    break;
                }
            }
        }
        // Ermittle das Team das gerade besser ist und gebe die Team Nummer zurueck
        private int GetWinningTeamID()
        {
            WritePluginConsole("[GetWinningTeamID]", "DEBUG", 6);

            TeamScore tmpTeam = new TeamScore(0,0);

            foreach (TeamScore team in currentTeamScores)
            {
            WritePluginConsole("[GetWinningTeamID] TeamInfo: TeamID = " + team.TeamID + " Score = " + team.Score + " WinningScore = " + team.WinningScore, "DEBUG", 8);

            if (team.Score < team.WinningScore) // TDM, SQDM , etc...
            {
            if (team.Score > tmpTeam.Score)
            {
                tmpTeam = team;
            }

            }

            if (team.Score > team.WinningScore) // CQ, DOM , etc...
            {
            if (team.Score > tmpTeam.Score)
            {
                tmpTeam = team;
            }

            }

            }

            WritePluginConsole("[GetWinningTeamID] Winning Team is:  TeamID = " + tmpTeam.TeamID + " Score = " + tmpTeam.Score + " WinningScore = " + tmpTeam.WinningScore, "INFO", 6);
            return tmpTeam.TeamID;
        }