Esempio n. 1
0
        public override void UpdateState()
        {
            State = (LastQueryTimestamp == 0) ? Model.State.Waiting : Model.State.Done;

            if (!string.IsNullOrEmpty(ResultBase64))
            {
                byte[] buffer;
                EncoderToolkit.DecodeFromBase64(ResultBase64, out buffer);

                Result = Encoding.UTF8.GetString(EncoderToolkit.DecodeFromGZip(buffer));

                JSonObject = new MatchStatistics(Result);
            }
        }
 void Awake()
 {
     instance = this;
     ResetState();
 }
Esempio n. 3
0
        /// <summary>
        /// Writes spawn.ini and spawnmap.ini and starts the game.
        /// </summary>
        /// <param name="playerPorts">The list of port numbers to use for players.</param>
        private void StartGame(List<int> playerPorts)
        {
            string mapPath = ProgramConstants.gamepath + currentMap.Path;
            if (!File.Exists(mapPath))
            {
                MessageBox.Show("Unable to locate scenario map!" + Environment.NewLine + mapPath,
                    "Cannot read scenario", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnLeaveGame.PerformClick();
                return;
            }

            // 28. 12. 2014 No editing the map after accepting on it!
            string mapSHA1 = Utilities.CalculateSHA1ForFile(mapPath);
            if (mapSHA1 != currentMap.SHA1)
            {
                MessageBox.Show("Map modification detected! Please restart the Client." + Environment.NewLine + mapPath,
                    "Cannot read scenario", MessageBoxButtons.OK, MessageBoxIcon.Error);
                string messageToSend = "NOTICE " + ChannelName + " " + CTCPChar1 + CTCPChar2 + "MAPMOD" + CTCPChar2;
                CnCNetData.ConnectionBridge.SendMessage(messageToSend);
                btnLeaveGame.PerformClick();
                return;
            }

            string mapCodePath = currentMap.Path.Substring(0, currentMap.Path.Length - 3) + "ini";

            List<int> playerSides = new List<int>();
            List<bool> isPlayerSpectator = new List<bool>();
            List<int> playerColors = new List<int>();
            List<int> playerStartingLocations = new List<int>();

            SharedUILogic.Randomize(Players, AIPlayers, currentMap, Seed, playerSides,
                isPlayerSpectator, playerColors, playerStartingLocations,
                SharedUILogic.getAllowedSides(ComboBoxes, SideComboboxPrerequisites),
                SideComboboxPrerequisites.Count);

            List<int> MultiCmbIndexes;

            SharedUILogic.WriteSpawnIni(Players, AIPlayers, currentMap, currentGameMode, Seed,
                iNumLoadingScreens, isHost, playerPorts, tunnelAddress, tunnelPort, ComboBoxes,
                CheckBoxes, IsCheckBoxReversed, AssociatedCheckBoxSpawnIniOptions,
                AssociatedComboBoxSpawnIniOptions, ComboBoxDataWriteModes,
                playerSides, isPlayerSpectator, playerColors, playerStartingLocations,
                out MultiCmbIndexes);

            SharedLogic.WriteCoopDataToSpawnIni(currentMap, Players, AIPlayers, MultiCmbIndexes,
                coopDifficultyLevel, SideComboboxPrerequisites.Count, mapCodePath, Seed);

            List<bool> isCheckBoxChecked = new List<bool>();

            foreach (UserCheckBox chkBox in CheckBoxes)
                isCheckBoxChecked.Add(chkBox.Checked);

            File.Copy(mapPath, ProgramConstants.gamepath + ProgramConstants.SPAWNMAP_INI);

            IniFile mapIni = new IniFile(ProgramConstants.gamepath + ProgramConstants.SPAWNMAP_INI);

            SharedLogic.WriteMap(currentGameMode, isCheckBoxChecked, IsCheckBoxReversed, AssociatedCheckBoxCustomInis, mapIni);

            ms = new MatchStatistics(ProgramConstants.GAME_VERSION, currentMap.Name, currentGameMode, Players.Count);
            int id = 0;
            foreach (PlayerInfo p in Players)
            {
                if (p.Name == ProgramConstants.CNCNET_PLAYERNAME)
                    ms.AddPlayer(p.Name, true, false, p.SideId == SideComboboxPrerequisites.Count + 1, playerSides[id], p.TeamId, 10);
                else
                    ms.AddPlayer(p.Name, false, false, p.SideId == SideComboboxPrerequisites.Count + 1, playerSides[id], p.TeamId, 10);

                id++;
            }

            foreach (PlayerInfo ai in AIPlayers)
            {
                ms.AddPlayer("Computer", false, true, false, playerSides[id], ai.TeamId, GetAILevel(ai));
                id++;
            }

            Logger.Log("About to launch main executable.");

            StartGameProcess();
        }
 public DTAStatisticsParser(MatchStatistics ms) : base(ms)
 {
 }