public void SetAbort()
 {
     this.mGameState = GPG.Multiplayer.Game.GameState.Aborted;
 }
        private void mSupcomTCPConnection_OnGetCommand(object sender, Driver.InputEventArgs e)
        {
            EventLog.WriteLine("Got a command from the game: ", LogCategory.Get("SupComGameManager"), new object[] { e });
            if (!(e.Command == "GameOption"))
            {
                if (e.Command == "Terminate")
                {
                    string message = "";
                    foreach (string str3 in e.Args)
                    {
                        message = message + str3 + " ";
                    }
                    if (message == "")
                    {
                        message = "The game has been closed with the Terminate arguement.  Please provide a reason after the Terminate command to provide context.";
                    }
                    this.ForceCloseGame(message);
                }
                else if (e.Command == "PlayerOption")
                {
                    string[] strArray2 = ("/PLAYEROPTION " + ((string) e.Args[0])).Split(" ".ToCharArray());
                    if (strArray2.Length >= 4)
                    {
                        string playerName = strArray2[2];
                        if (playerName.IndexOf("<") != 0)
                        {
                            for (int i = 3; i < (strArray2.Length - 2); i++)
                            {
                                playerName = playerName + " " + strArray2[i];
                            }
                            string str5 = strArray2[1];
                            string str6 = strArray2[strArray2.Length - 2];
                            string str7 = strArray2[strArray2.Length - 1];
                            this.mGameInfo.PlayerByName(playerName).Army = Convert.ToInt32(str6);
                            switch (str5)
                            {
                                case "faction":
                                {
                                    string str8 = "UEF";
                                    switch (str7)
                                    {
                                        case "2":
                                            str8 = "Aeon";
                                            break;

                                        case "3":
                                            str8 = "Cybran";
                                            break;

                                        case "4":
                                            str8 = "Seraphim";
                                            break;
                                    }
                                    this.mGameInfo.PlayerByName(playerName).Faction = str8;
                                    return;
                                }
                                case "color":
                                    this.mGameInfo.PlayerByName(playerName).Color = str7;
                                    return;

                                case "team":
                                {
                                    string str9 = "FFA";
                                    switch (str7)
                                    {
                                        case "2":
                                            str9 = "Team 1";
                                            break;

                                        case "3":
                                            str9 = "Team 2";
                                            break;

                                        case "4":
                                            str9 = "Team 3";
                                            break;

                                        case "5":
                                            str9 = "Team 4";
                                            break;
                                    }
                                    this.mGameInfo.PlayerByName(playerName).Team = str9;
                                    return;
                                }
                                case "startspot":
                                    this.mGameInfo.PlayerByName(playerName).StartSpot = Convert.ToInt32(str7);
                                    return;
                            }
                        }
                    }
                }
                else if (e.Command == "Stats")
                {
                    string str10 = (string) e.Args[0];
                    str10 = str10.Replace("<LOC", "&lt;LOC").Replace("_desc>", "_desc&gt;");
                    this.mStats = str10;
                    foreach (SupcomPlayerInfo info in this.mGameInfo.Players)
                    {
                        info.UnitInfo.Clear();
                    }
                    try
                    {
                        string str11 = "";
                        foreach (string str12 in str10.Split(new char[] { '\n' }))
                        {
                            if (str12.ToUpper().IndexOf("<ARMY") >= 0)
                            {
                                string[] strArray4 = str12.Split(new char[] { '"' });
                                if (strArray4.Length >= 3)
                                {
                                    int num2 = Convert.ToInt32(strArray4[1]);
                                    string str13 = strArray4[3];
                                    str11 = str13;
                                    foreach (SupcomPlayerInfo info2 in this.mGameInfo.Players)
                                    {
                                        if (info2.PlayerName == str13)
                                        {
                                            info2.Army = num2;
                                            break;
                                        }
                                    }
                                }
                            }
                            else if ((str12.ToUpper().IndexOf("<ENERGY PRODUCED=\"") >= 0) && (str11 != ""))
                            {
                                double num3 = 0.0;
                                double num4 = 0.0;
                                foreach (string str14 in str12.Split(new char[] { ' ' }))
                                {
                                    try
                                    {
                                        string[] strArray5 = str14.Split("=".ToCharArray(), 2);
                                        if (strArray5.Length == 2)
                                        {
                                            try
                                            {
                                                if (strArray5[0].ToLower() == "produced")
                                                {
                                                    num4 += Convert.ToDouble(strArray5[1].Replace("\"", ""));
                                                }
                                                else if (strArray5[0].ToLower() == "consumed")
                                                {
                                                    num3 += Convert.ToDouble(strArray5[1].Replace("\"", ""));
                                                }
                                            }
                                            catch (Exception exception)
                                            {
                                                ErrorLog.WriteLine(exception);
                                            }
                                        }
                                    }
                                    catch (Exception exception2)
                                    {
                                        ErrorLog.WriteLine(exception2);
                                    }
                                }
                                foreach (SupcomPlayerInfo info3 in this.mGameInfo.Players)
                                {
                                    if (info3.PlayerName == str11)
                                    {
                                        info3.EnergyConsumed = num3;
                                        info3.EnergyProduced = num4;
                                        break;
                                    }
                                }
                            }
                            else if ((str12.ToUpper().IndexOf("<MASS PRODUCED=\"") >= 0) && (str11 != ""))
                            {
                                double num5 = 0.0;
                                double num6 = 0.0;
                                foreach (string str15 in str12.Split(new char[] { ' ' }))
                                {
                                    try
                                    {
                                        string[] strArray6 = str15.Split("=".ToCharArray(), 2);
                                        if (strArray6.Length == 2)
                                        {
                                            try
                                            {
                                                if (strArray6[0].ToLower() == "produced")
                                                {
                                                    num6 += Convert.ToDouble(strArray6[1].Replace("\"", ""));
                                                }
                                                else if (strArray6[0].ToLower() == "consumed")
                                                {
                                                    num5 += Convert.ToDouble(strArray6[1].Replace("\"", ""));
                                                }
                                            }
                                            catch (Exception exception3)
                                            {
                                                ErrorLog.WriteLine(exception3);
                                            }
                                        }
                                    }
                                    catch (Exception exception4)
                                    {
                                        ErrorLog.WriteLine(exception4);
                                    }
                                }
                                foreach (SupcomPlayerInfo info4 in this.mGameInfo.Players)
                                {
                                    if (info4.PlayerName == str11)
                                    {
                                        info4.MassConsumed = num5;
                                        info4.MassProduced = num6;
                                        break;
                                    }
                                }
                            }
                            else if ((str12.ToUpper().IndexOf("<UNIT ID=\"") >= 0) && (str11 != ""))
                            {
                                string str16 = "";
                                int num7 = 0;
                                int num8 = 0;
                                int num9 = 0;
                                double num10 = 0.0;
                                double num11 = 0.0;
                                foreach (string str17 in str12.Split(new char[] { ' ' }))
                                {
                                    try
                                    {
                                        string[] strArray7 = str17.Split("=".ToCharArray(), 2);
                                        if (strArray7.Length == 2)
                                        {
                                            try
                                            {
                                                if (strArray7[0].ToLower() == "id")
                                                {
                                                    str16 = strArray7[1].Replace("\"", "");
                                                }
                                                else if (strArray7[0].ToLower() == "built")
                                                {
                                                    num7 += Convert.ToInt32(strArray7[1].Replace("\"", ""));
                                                }
                                                else if (strArray7[0].ToLower() == "lost")
                                                {
                                                    num8 += Convert.ToInt32(strArray7[1].Replace("\"", ""));
                                                }
                                                else if (strArray7[0].ToLower() == "killed")
                                                {
                                                    num9 += Convert.ToInt32(strArray7[1].Replace("\"", ""));
                                                }
                                                else if (strArray7[0].ToLower() == "damagedealt")
                                                {
                                                    num10 += Convert.ToDouble(strArray7[1].Replace("\"", ""));
                                                }
                                                else if (strArray7[0].ToLower() == "damagereceived")
                                                {
                                                    num11 += Convert.ToDouble(strArray7[1].Replace("\"", ""));
                                                }
                                            }
                                            catch (Exception exception5)
                                            {
                                                ErrorLog.WriteLine(exception5);
                                            }
                                        }
                                    }
                                    catch (Exception exception6)
                                    {
                                        ErrorLog.WriteLine(exception6);
                                    }
                                }
                                num7 += num8;
                                foreach (SupcomPlayerInfo info5 in this.mGameInfo.Players)
                                {
                                    if (info5.PlayerName == str11)
                                    {
                                        SupcomUnitInfo item = new SupcomUnitInfo {
                                            unitid = str16,
                                            built = num7,
                                            lost = num8,
                                            killed = num9,
                                            damagedealt = num10,
                                            damagereceived = num11
                                        };
                                        info5.UnitInfo.Add(item);
                                    }
                                }
                                if ((str12.ToUpper().IndexOf("<UNIT ID=\"UEL0001\"") >= 0) && (str11 != ""))
                                {
                                    if ((str12.ToUpper().IndexOf("BUILT=\"1\"") > 0) || (str12.ToUpper().IndexOf("LOST=\"1\"") > 0))
                                    {
                                        foreach (SupcomPlayerInfo info7 in this.mGameInfo.Players)
                                        {
                                            if (info7.PlayerName == str11)
                                            {
                                                info7.Faction = "UEF";
                                                break;
                                            }
                                        }
                                    }
                                }
                                else if ((str12.ToUpper().IndexOf("<UNIT ID=\"UAL0001\"") >= 0) && (str11 != ""))
                                {
                                    if ((str12.ToUpper().IndexOf("BUILT=\"1\"") > 0) || (str12.ToUpper().IndexOf("LOST=\"1\"") > 0))
                                    {
                                        foreach (SupcomPlayerInfo info8 in this.mGameInfo.Players)
                                        {
                                            if (info8.PlayerName == str11)
                                            {
                                                info8.Faction = "Aeon";
                                                break;
                                            }
                                        }
                                    }
                                }
                                else if ((str12.ToUpper().IndexOf("<UNIT ID=\"URL0001\"") >= 0) && (str11 != ""))
                                {
                                    if ((str12.ToUpper().IndexOf("BUILT=\"1\"") > 0) || (str12.ToUpper().IndexOf("LOST=\"1\"") > 0))
                                    {
                                        foreach (SupcomPlayerInfo info9 in this.mGameInfo.Players)
                                        {
                                            if (info9.PlayerName == str11)
                                            {
                                                info9.Faction = "Cybran";
                                                break;
                                            }
                                        }
                                    }
                                }
                                else if (((str12.ToUpper().IndexOf("<UNIT ID=\"XSL0001\"") >= 0) && (str11 != "")) && ((str12.ToUpper().IndexOf("BUILT=\"1\"") > 0) || (str12.ToUpper().IndexOf("LOST=\"1\"") > 0)))
                                {
                                    foreach (SupcomPlayerInfo info10 in this.mGameInfo.Players)
                                    {
                                        if (info10.PlayerName == str11)
                                        {
                                            info10.Faction = "Seraphim";
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        this.ProcessGameResults();
                    }
                    catch (Exception exception7)
                    {
                        ErrorLog.WriteLine(exception7);
                    }
                    if (!this.IsRegularRankedGame())
                    {
                        TimeSpan span = (TimeSpan) (DateTime.Now - this.mGameInfo.StartTime);
                        string oldValue = "<GameStats xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
                        string newValue = oldValue + "\r\n  <GameInfo map=\"" + this.mGameInfo.Map + "\" starttime=\"" + this.mGameInfo.StartTime.ToUniversalTime().ToString() + "\" duration=\"" + span.TotalSeconds.ToString() + "\" gametype=\"Custom\">\r\n    <PlayerInformation>\r\n";
                        if (this.mGameInfo != null)
                        {
                            foreach (SupcomPlayerInfo info11 in this.mGameInfo.Players)
                            {
                                newValue = newValue + "      <Player name=\"" + info11.PlayerName + "\" faction=\"" + info11.Faction + "\" team=\"" + info11.Team + "\" status=\"" + info11.Status + "\" startposition=\"" + info11.StartSpot.ToString() + "\" color=\"" + info11.Color + "\"/>\r\n";
                            }
                        }
                        newValue = newValue + "    </PlayerInformation>\r\n" + "  </GameInfo>\r\n";
                        this.mStats = this.mStats.Replace(oldValue, newValue);
                    }
                    else
                    {
                        foreach (SupcomPlayerInfo info12 in this.mGameInfo.Players)
                        {
                            foreach (string str20 in this.mStats.Split("\r\n".ToCharArray()))
                            {
                                if ((str20.IndexOf("\"" + info12.PlayerName + "\"") >= 0) && (str20.IndexOf("victory") >= 0))
                                {
                                    info12.Status = "victory";
                                }
                                if ((str20.IndexOf("\"" + info12.PlayerName + "\"") >= 0) && (str20.IndexOf("defeat") >= 0))
                                {
                                    info12.Status = "defeat";
                                }
                                if (str20.IndexOf("GameInfo") >= 0)
                                {
                                    foreach (string str21 in str20.Split(new char[] { ' ' }))
                                    {
                                        if (str21.IndexOf("starttime") >= 0)
                                        {
                                            try
                                            {
                                                this.mGameInfo.StartTime = DateTime.Parse(str21.Replace("starttime", "").Replace("\"", "").Trim());
                                            }
                                            catch
                                            {
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (this.OnStatsXML != null)
                    {
                        this.OnStatsXML(this.mStats);
                    }
                }
                else if (e.Command == "Desync")
                {
                    this.ForceCloseGame(Loc.Get("<LOC>The game has desynced and has been shut down."));
                }
                else
                {
                    if (e.Command == "Bottleneck")
                    {
                        if (ConfigSettings.GetBool("AutoDisconnect", true))
                        {
                            try
                            {
                                if (Convert.ToDouble(e.Args[3]) > ConfigSettings.GetInt("AutoTime", 0x7530))
                                {
                                    this.MessageGame("//DISCPLAYER " + e.Args[2].ToString());
                                }
                            }
                            catch (Exception exception8)
                            {
                                ErrorLog.WriteLine(exception8);
                            }
                        }
                        if (!ConfigSettings.GetBool("LogBottlenecks", true))
                        {
                            return;
                        }
                        try
                        {
                            string str22 = "";
                            foreach (object obj2 in e.Args)
                            {
                                str22 = str22 + obj2.ToString() + " ";
                            }
                            double num13 = Convert.ToDouble(e.Args[3]);
                            if ((Environment.TickCount - this.mBottleNeckCooldown) > ConfigSettings.GetInt("BottleNeckCooldown", 0x7530))
                            {
                                if (num13 > ConfigSettings.GetInt("AutoTime", 0x7530))
                                {
                                    ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "ExecuteQuery", null, null, new object[] { "GameEvent", new object[] { User.Current.ID, "Bottleneck", str22, this.GameName, this.GameName } });
                                }
                                this.mBottleNeckCooldown = Environment.TickCount;
                            }
                            return;
                        }
                        catch (Exception exception9)
                        {
                            ErrorLog.WriteLine(exception9);
                            return;
                        }
                    }
                    if (e.Command == "GameState")
                    {
                        string str23 = (string) e.Args[0];
                        if (str23 != "Idle")
                        {
                            if (((str23 == "Lobby") && (this.mGameState != GPG.Multiplayer.Game.GameState.Lobby)) && (this.mGameState != GPG.Multiplayer.Game.GameState.Launching))
                            {
                                if (this.MyTeam != "")
                                {
                                    this.MessageGame("//TEAMNAME " + this.MyTeam);
                                }
                                if (Chatroom.InChatroom)
                                {
                                    Chatroom.JoinGame();
                                }
                                this.mGameState = GPG.Multiplayer.Game.GameState.Lobby;
                                if (this.mIsHost)
                                {
                                    ThreadQueue.Quazal.Enqueue(typeof(Game), "CreateGame", this, "FinishCreateGame", new object[] { this.mGameName, "Unknown Map", 0x5dc, 8, "SupCom", "1.0", this.GetParams() });
                                    ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "ExecuteQuery", null, null, new object[] { "GameEvent", new object[] { User.Current.ID, "HostedGame", this.mGameName, this.mGameName, this.mGameName } });
                                }
                                else
                                {
                                    ThreadQueue.Quazal.Enqueue(typeof(Game), "JoinGame", this, "FinishJoinGame", new object[] { this.mGameName });
                                }
                            }
                            else if ((str23 == "Running") && (this.mGameState != GPG.Multiplayer.Game.GameState.Playing))
                            {
                                this.mGameState = GPG.Multiplayer.Game.GameState.Playing;
                                this.MessageGame("//PLAYING " + User.Current.Name);
                                this.mGameInfo.StartTime = DateTime.Now;
                            }
                            else if ((str23 == "Launching") && (this.mGameState != GPG.Multiplayer.Game.GameState.Launching))
                            {
                                ThreadQueue.Quazal.Enqueue(typeof(Game), "StartGame", null, null, new object[0]);
                                this.mGameState = GPG.Multiplayer.Game.GameState.Launching;
                                if (this.OnGameLaunched != null)
                                {
                                    this.OnGameLaunched(this, EventArgs.Empty);
                                }
                                this.MessageGame("//PLAYERINFO " + User.Current.ID.ToString() + " " + User.Current.Name + " -1");
                                if (this.mIsHost)
                                {
                                    ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "ExecuteQuery", null, null, new object[] { "GameEvent", new object[] { User.Current.ID, "LaunchedGame: " + this.mGameInfo.Map, this.mGameName, this.mGameName, this.mGameName } });
                                    ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "ExecuteQuery", null, null, new object[] { "GameEvent", new object[] { User.Current.ID, "Map", this.mGameInfo.Map, this.mGameName, this.mGameName } });
                                    this.MessageGame("//MAP " + this.mGameInfo.Map);
                                    if (this.MyTeam != "")
                                    {
                                        this.MessageGame("//TEAMNAME " + this.MyTeam);
                                    }
                                    foreach (SupcomPlayerInfo info13 in this.mGameInfo.Players)
                                    {
                                        this.MessageGame("//PLAYERINFO " + info13.PlayerID.ToString() + " " + info13.PlayerName + " " + info13.Army.ToString());
                                    }
                                }
                                else if (ConfigSettings.GetBool("LogJoins", true))
                                {
                                    ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "ExecuteQuery", null, null, new object[] { "GameEvent", new object[] { User.Current.ID, "JoinedLaunchedGame: " + this.mGameInfo.Map, this.mGameName, this.mGameName, this.mGameName } });
                                }
                                this.MessageGame("//LAUNCHING " + User.Current.Name);
                                if (this.DoReplay)
                                {
                                    ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "ExecuteQuery", null, null, new object[] { "ReplayLaunched", new object[] { this.mReplayID } });
                                }
                            }
                        }
                    }
                    else if (e.Command == "GameResult")
                    {
                        this.mResultsQueue.Add(e);
                    }
                }
            }
            else if (((string) e.Args[0]) == "ScenarioFile")
            {
                string[] strArray = ((string) e.Args[1]).Split(new char[] { '/' });
                this.mGameInfo.Map = (string) e.Args[1];
                foreach (string str in strArray)
                {
                    if (str.ToUpper().IndexOf("SCMP") == 0)
                    {
                        this.mGameInfo.Map = str.ToUpper();
                        break;
                    }
                }
                ThreadQueue.Quazal.Enqueue(typeof(Game), "UpdateGame", null, null, new object[] { this.mGameInfo.Map, 0, this.mGameInfo.GetMaxPlayers(), "", "", "" });
            }
        }
        public void ReceiveMessage(NetMessage message)
        {
            EventLog.WriteLine("Game Message: " + message.EndPoint.Address.ToString() + " " + message.Text, LogCategory.Get("SupComGameManager"), new object[0]);
            if (message.Text.IndexOf("/GAMEOPTION") == 0)
            {
                string[] strArray = message.Text.Split(" ".ToCharArray());
                if (strArray.Length >= 4)
                {
                    string playerName = strArray[2];
                    if (playerName.IndexOf("<") != 0)
                    {
                        for (int i = 3; i < (strArray.Length - 2); i++)
                        {
                            playerName = playerName + " " + strArray[i];
                        }
                        string str2 = strArray[1];
                        string str3 = strArray[strArray.Length - 2];
                        string str4 = strArray[strArray.Length - 1];
                        this.mGameInfo.PlayerByName(playerName).Army = Convert.ToInt32(str3);
                        switch (str2)
                        {
                            case "faction":
                            {
                                string str5 = "UEF";
                                switch (str4)
                                {
                                    case "2":
                                        str5 = "Aeon";
                                        break;

                                    case "3":
                                        str5 = "Cybran";
                                        break;
                                }
                                this.mGameInfo.PlayerByName(playerName).Faction = str5;
                                return;
                            }
                            case "color":
                                this.mGameInfo.PlayerByName(playerName).Color = str4;
                                return;

                            case "team":
                            {
                                string str6 = "FFA";
                                switch (str4)
                                {
                                    case "2":
                                        str6 = "Team 1";
                                        break;

                                    case "3":
                                        str6 = "Team 2";
                                        break;

                                    case "4":
                                        str6 = "Team 3";
                                        break;

                                    case "5":
                                        str6 = "Team 4";
                                        break;
                                }
                                this.mGameInfo.PlayerByName(playerName).Team = str6;
                                return;
                            }
                            case "startspot":
                                this.mGameInfo.PlayerByName(playerName).StartSpot = Convert.ToInt32(str4);
                                return;
                        }
                    }
                }
            }
            else if (message.Text.IndexOf("/MAP") == 0)
            {
                string[] strArray2 = message.Text.Split(new char[] { '/' });
                this.mGameInfo.Map = strArray2[strArray2.Length - 1].Replace(".scmap", "");
                ThreadQueue.Quazal.Enqueue(typeof(Game), "UpdateGame", null, null, new object[] { this.mGameInfo.Map, 0, this.mGameInfo.GetMaxPlayers(), "", "", "" });
            }
            else if (message.Text.IndexOf("/STATS") == 0)
            {
                if (message.Text != "/STATS End Stats")
                {
                    if (message.Text == "/STATS Begin Stats")
                    {
                        this.mStats = "";
                    }
                    else
                    {
                        string str9 = message.Text.Replace("/STATS ", "") + "\r\n";
                        while (str9.IndexOf("<LOC") >= 0)
                        {
                            int index = str9.IndexOf("<LOC");
                            str9 = str9.Remove(index, 4);
                            if (str9.IndexOf(">") > 0)
                            {
                                str9 = str9.Remove(str9.IndexOf(">"), 1);
                            }
                        }
                        this.mStats = this.mStats + str9;
                    }
                }
                else
                {
                    TimeSpan span = (TimeSpan) (DateTime.Now - this.mGameInfo.StartTime);
                    string oldValue = "<GameStats xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
                    string newValue = oldValue + "\r\n  <GameInfo map=\"" + this.mGameInfo.Map + "\" starttime=\"" + this.mGameInfo.StartTime.ToUniversalTime().ToString() + "\" duration=\"" + span.TotalSeconds.ToString() + "\" gametype=\"Custom\">\r\n    <PlayerInformation>\r\n";
                    foreach (SupcomPlayerInfo info in this.mGameInfo.Players)
                    {
                        newValue = newValue + "      <Player name=\"" + info.PlayerName + "\" faction=\"" + info.Faction + "\" team=\"" + info.Team + "\" status=\"" + info.Status + "\" startposition=\"" + info.StartSpot.ToString() + "\" color=\"" + info.Color + "\"/>\r\n";
                    }
                    newValue = newValue + "    </PlayerInformation>\r\n" + "  </GameInfo>\r\n";
                    this.mStats = this.mStats.Replace(oldValue, newValue);
                    if (this.OnStatsXML != null)
                    {
                        this.OnStatsXML(this.mStats);
                    }
                    if (this.mStatsShutdown)
                    {
                        this.EndGame();
                    }
                }
            }
            else if (((message.Text.ToUpper() == "/GAMESTATE LOBBY") && (this.mGameState != GPG.Multiplayer.Game.GameState.Lobby)) && (this.mGameState != GPG.Multiplayer.Game.GameState.Launching))
            {
                if (Chatroom.InChatroom)
                {
                    Chatroom.JoinGame();
                }
                this.mGameState = GPG.Multiplayer.Game.GameState.Lobby;
                this.mSupcomTCPConnection.SendMessage("LUA", new object[] { "LOG('This is a test.')" });
                if (this.mIsHost)
                {
                    ThreadQueue.Quazal.Enqueue(typeof(Game), "CreateGame", this, "FinishCreateGame", new object[] { this.mGameName, "Unknown Map", 0x5dc, 8, "SupCom", "1.0", this.GetParams() });
                }
                else
                {
                    ThreadQueue.Quazal.Enqueue(typeof(Game), "JoinGame", this, "FinishJoinGame", new object[] { this.mGameName });
                }
            }
            else if ((message.Text.ToUpper() == "/GAMESTATE GAME IS RUNNING") && (this.mGameState != GPG.Multiplayer.Game.GameState.Playing))
            {
                this.mGameState = GPG.Multiplayer.Game.GameState.Playing;
                this.MessageGame("//PLAYING " + User.Current.Name);
                this.mGameInfo.StartTime = DateTime.Now;
            }
            else if ((message.Text.ToUpper() == "/GAMESTATE LAUNCHING") && (this.mGameState != GPG.Multiplayer.Game.GameState.Launching))
            {
                ThreadQueue.Quazal.Enqueue(typeof(Game), "StartGame", null, null, new object[0]);
                this.mGameState = GPG.Multiplayer.Game.GameState.Launching;
                this.MessageGame("//LAUNCHING " + User.Current.Name);
            }
            else if (message.Text.ToUpper().IndexOf("/GAMERESULT") == 0)
            {
                this.mStatsWatcher.Stop();
                string[] strArray3 = message.Text.Split(" ".ToCharArray(), 3);
                if (strArray3.Length == 3)
                {
                    this.mGameInfo.Sort();
                    this.mGameInfo.Players[Convert.ToInt32(strArray3[1]) - 1].Status = strArray3[2];
                }
                int num3 = 0;
                foreach (SupcomPlayerInfo info2 in this.mGameInfo.Players)
                {
                    if (info2.Status.ToUpper() == "DEFEAT")
                    {
                        num3++;
                    }
                }
                if ((num3 + 1) == this.mGameInfo.Players.Count)
                {
                    foreach (SupcomPlayerInfo info3 in this.mGameInfo.Players)
                    {
                        if (info3.Status.ToUpper() != "DEFEAT")
                        {
                            info3.Status = "victory";
                        }
                    }
                }
                foreach (SupcomPlayerInfo info4 in this.mGameInfo.Players)
                {
                    if (info4.PlayerName.ToUpper() == User.Current.Name.ToUpper())
                    {
                        this.mStatsWatcher.Stop();
                    }
                }
                this.GetStats();
            }
            else if (message.Text.ToUpper() == "/SENDSHUTDOWN")
            {
                this.EndGame();
            }
        }