Exemplo n.º 1
0
 public DlgNoBetaKey(FrmMain mainForm) : base(mainForm)
 {
     WaitCallback callBack = null;
     this.components = null;
     this.InitializeComponent();
     string str = "";
     try
     {
         RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\THQ\Gas Powered Games\" + GameInformation.SelectedGame.GameDescription);
         if (key != null)
         {
             str = (string) key.GetValue("KEY", "");
         }
         if ((str == null) || (str == ""))
         {
             key = Registry.LocalMachine.OpenSubKey(@"Software\THQ\Gas Powered Games\" + GameInformation.SelectedGame.GameDescription);
             if (key != null)
             {
                 str = (string) key.GetValue("KEY", "");
             }
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
     switch (str)
     {
         case null:
         case "":
             str = "";
             break;
     }
     if (str.IndexOf("-") < 0)
     {
         for (int i = (str.Length / 4) - 1; i >= 1; i--)
         {
             str = str.Insert(i * 4, "-");
         }
     }
     this.gpgTextBoxAddBeta.Text = str;
     if (GameInformation.SelectedGame.GameID == -1)
     {
         base.DialogResult = DialogResult.OK;
     }
     if (callBack == null)
     {
         callBack = delegate (object o) {
             try
             {
                 DataList queryData = DataAccess.GetQueryData("Check For Other Keys", new object[0]);
                 if (queryData.Count > 0)
                 {
                     string names = "";
                     string curstr = "";
                     foreach (DataRecord record in queryData)
                     {
                         names = names + curstr + record["name"];
                         curstr = ", ";
                     }
                     mainForm.Invoke((VGen0)delegate {
                         try
                         {
                             DlgMessage.ShowDialog(Loc.Get("<LOC>We have detected that you have other accounts with the same email that already have CD keys attached.  You may want to quit, and relog into GPGnet under one of these accounts to get the full functionality out of your games.  These accounts are: ") + names);
                         }
                         catch (Exception exception)
                         {
                             ErrorLog.WriteLine(exception);
                         }
                     });
                 }
             }
             catch (Exception exception)
             {
                 ErrorLog.WriteLine(exception);
             }
         };
     }
     ThreadQueue.QueueUserWorkItem(callBack, new object[0]);
 }
Exemplo n.º 2
0
 public static void ProcessCustomCommand(FrmMain main, CustomCommands cmd, int senderID, string senderName, string[] args)
 {
     VGen0 method = null;
     VGen0 gen2 = null;
     VGen0 gen3 = null;
     VGen0 gen4 = null;
     VGen0 gen5 = null;
     VGen0 gen6 = null;
     EventLog.WriteLine("Running command " + cmd.ToString() + " " + senderID.ToString() + " " + senderName, LogCategory.Get("TournamentCommands"), args);
     if (cmd == CustomCommands.TournamentLaunchGame)
     {
         sDirectorName = senderName;
         sDirectorID = senderID;
         sTournamentID = Convert.ToInt32(args[1]);
         try
         {
             Thread.Sleep(Convert.ToInt32(args[2]));
         }
         catch
         {
         }
         sFaction = args[3].ToLower();
         sMap = args[4];
         foreach (KeyValuePair<string, string> pair in GameItem.MapNameLookup)
         {
             if (pair.Value.ToUpper() == sMap.ToUpper())
             {
                 sMap = pair.Key;
             }
         }
         sMap = SupcomAutomatch.CheckRenameMap(sMap);
         Random random = new Random();
         Thread.Sleep(random.Next(10, 0xfa0));
         if (method == null)
         {
             method = delegate {
                 main.PlayRankedGame(true, args[0], new List<string>(), "", true);
             };
         }
         main.Invoke(method);
     }
     else if (cmd == CustomCommands.TournamentResult)
     {
         if (DlgManageTournament.Current != null)
         {
             if (gen2 == null)
             {
                 gen2 = delegate {
                     DlgManageTournament.Current.UpdateStats(senderID, args[0]);
                 };
             }
             DlgManageTournament.Current.Invoke(gen2);
         }
     }
     else if (cmd == CustomCommands.TournamentChatroom)
     {
         sChatroom = args[0];
         if (gen3 == null)
         {
             gen3 = delegate {
                 main.SystemMessage(Loc.Get("<LOC>You are being rerouted to a new chatroom for the tournament you signed up for."), new object[0]);
                 main.JoinChat(args[0]);
             };
         }
         main.Invoke(gen3);
     }
     else if (cmd == CustomCommands.TournamentRequestStatus)
     {
         if (gen4 == null)
         {
             gen4 = delegate {
                 Messaging.SendCustomCommand(senderName, CustomCommands.TournamentAcknowledgeStatus, new object[] { SupcomAutomatch.GetSupcomAutomatch().State.ToString() });
             };
         }
         main.Invoke(gen4);
     }
     else if (cmd == CustomCommands.TournamentChatmessage)
     {
         if (gen5 == null)
         {
             gen5 = delegate {
                 main.SystemEvent(args[0], new object[0]);
             };
         }
         main.Invoke(gen5);
     }
     else if (cmd == CustomCommands.TournamentEndMatch)
     {
         main.Invoke((VGen0)delegate {
             try
             {
                 SupcomAutomatch.GetSupcomAutomatch().GetManager().ForceCloseGame(Loc.Get("<LOC>The Tournament Director has ended your game."));
             }
             catch (Exception exception)
             {
                 ErrorLog.WriteLine(exception);
             }
         });
     }
     else if (cmd == CustomCommands.TournamentAcknowledgeStatus)
     {
         if (gen6 == null)
         {
             gen6 = delegate {
                 sRespondingUsers.Add(senderName, args[0]);
                 if (DlgManageTournament.Current != null)
                 {
                     DlgManageTournament.Current.UpdateItemStatus(senderName, args[0]);
                 }
             };
         }
         main.Invoke(gen6);
     }
 }
        public static void ProcessCommand(FrmMain main, CustomCommands cmd, int senderID, string senderName, string[] args)
        {
            sFrmMain = main;
            if (!(main.IsDisposed || main.Disposing))
            {
                main.Invoke((VGen0)delegate {
                    Create();
                });
            }
            if (sDlgSupcom != null)
            {
                CustomCommands commands = cmd;
                int num = senderID;
                string str = senderName;
                string[] strArray = args;
                try
                {
                    int num2;
                    switch (commands)
                    {
                        case CustomCommands.AutomatchRequestAlliance:
                            lock (mInviteMutex)
                            {
                                if ((((sLeader == "") && !sIsHosting) && !sIsJoining) && !(main.IsDisposed || main.Disposing))
                                {
                                    main.BeginInvoke((VGen2)delegate (object objname, object objmain) {
                                        FrmMain mainForm = (FrmMain) objmain;
                                        if (((new DlgYesNo(mainForm, Loc.Get("<LOC>Arranged Team Request"), objname.ToString() + Loc.Get("<LOC> has invited you to play in a rated team game.  Do you wish to join?")).ShowDialog() == DialogResult.Yes) && (SupcomAutomatch.GetSupcomAutomatch().State == SupcomAutoState.Unavailable)) && !((!(sLeader == "") || sIsHosting) || sIsJoining))
                                        {
                                            sIsConfirmed = false;
                                            sIsJoining = true;
                                            Messaging.SendCustomCommand(objname.ToString(), CustomCommands.AutomatchConfirmAlliance, new object[0]);
                                            mainForm.SetStatus(Loc.Get("<LOC>Arranged Team Leader: ") + objname.ToString(), new object[0]);
                                            mainForm.DisableGameButtons();
                                            SkinStatusButton cancel = new SkinStatusButton();
                                            cancel.Click += new EventHandler(DlgSupcomTeamSelection.cancel_Click);
                                            cancel.Text = Loc.Get("<LOC>Leave Team");
                                            cancel.Tag = objname.ToString();
                                            mainForm.AddMiddleButton(cancel);
                                            sLeader = objname.ToString();
                                            ThreadPool.QueueUserWorkItem(delegate (object o) {
                                                Thread.Sleep(ConfigSettings.GetInt("TeamJoinTimeout", 0x1388));
                                                cancel.BeginInvoke((VGen1)delegate (object ocancel) {
                                                    if (!sIsConfirmed && (ocancel is SkinStatusButton))
                                                    {
                                                        (ocancel as SkinStatusButton).PerformClick();
                                                    }
                                                }, new object[] { o });
                                            }, cancel);
                                        }
                                    }, new object[] { str, main });
                                }
                            }
                            return;

                        case CustomCommands.AutomatchAcknowledgeTeam:
                            sIsConfirmed = true;
                            return;

                        default:
                            if (commands != CustomCommands.AutomatchConfirmAlliance)
                            {
                                goto Label_025A;
                            }
                            for (num2 = sDlgSupcom.mPendingUsers.Count - 1; num2 >= 0; num2--)
                            {
                                if (sDlgSupcom.mPendingUsers[num2].Name == str)
                                {
                                    int @int = ConfigSettings.GetInt("MaxTeamSize", 4);
                                    if (sDlgSupcom.mUsers.Count < @int)
                                    {
                                        sDlgSupcom.mUsers.Add(sDlgSupcom.mPendingUsers[num2]);
                                        Messaging.SendCustomCommand(senderName, CustomCommands.AutomatchAcknowledgeTeam, new object[0]);
                                        sDlgSupcom.mPendingUsers.RemoveAt(num2);
                                    }
                                    else
                                    {
                                        Messaging.SendCustomCommand(sDlgSupcom.mPendingUsers[num2].Name, CustomCommands.AutomatchEndAlliance, new object[0]);
                                        sDlgSupcom.mPendingUsers.RemoveAt(num2);
                                    }
                                    break;
                                }
                            }
                            break;
                    }
                    DisplayUsers();
                    return;
                Label_025A:
                    if (commands == CustomCommands.AutomatchCancelAlliance)
                    {
                        sIsJoining = false;
                        for (num2 = sDlgSupcom.mPendingUsers.Count - 1; num2 >= 0; num2--)
                        {
                            if (sDlgSupcom.mPendingUsers[num2].Name == str)
                            {
                                sDlgSupcom.mPendingUsers.RemoveAt(num2);
                                DisplayUsers();
                                break;
                            }
                        }
                        for (num2 = sDlgSupcom.mUsers.Count - 1; num2 >= 0; num2--)
                        {
                            if (sDlgSupcom.mUsers[num2].Name == str)
                            {
                                sDlgSupcom.mUsers.RemoveAt(num2);
                                DisplayUsers();
                                break;
                            }
                        }
                        if (SupcomAutomatch.GetSupcomAutomatch().State != SupcomAutoState.Unavailable)
                        {
                            sDlgSupcom.BeginInvoke((VGen0)delegate {
                                sDlgSupcom.AbortGame();
                            });
                        }
                    }
                    else
                    {
                        switch (commands)
                        {
                            case CustomCommands.AutomatchEndAlliance:
                                sIsJoining = false;
                                if (!(main.IsDisposed || main.Disposing))
                                {
                                    main.BeginInvoke((VGen2)delegate (object objname, object objmain) {
                                        FrmMain mainForm = (FrmMain) objmain;
                                        DlgMessage.Show(mainForm, Loc.Get("<LOC>The team leader has canceled the arranged team game."));
                                        mainForm.ClearStatus();
                                        mainForm.EnableGameButtons();
                                    }, new object[] { str, main });
                                }
                                sLeader = "";
                                sDlgSupcom = null;
                                break;

                            case CustomCommands.AutomatchStatusMessage:
                                if (strArray[0] == "AUTOSEARCH")
                                {
                                    SupcomAutomatch.GetSupcomAutomatch().OnExit += new EventHandler(DlgSupcomTeamSelection.DlgSupcomTeamSelection_OnExit);
                                }
                                else if (!(main.IsDisposed || main.Disposing))
                                {
                                    main.BeginInvoke((VGen3)delegate (object objname, object objmain, object objargs) {
                                        FrmMain curmain = (FrmMain) objmain;
                                        if (objargs.ToString().IndexOf("launch") >= 0)
                                        {
                                            curmain.ClearStatus();
                                        }
                                        curmain.SetStatus(Loc.Get(objargs.ToString()), new object[0]);
                                    }, new object[] { str, main, strArray[0] });
                                }
                                break;
                        }
                    }
                }
                catch (Exception exception)
                {
                    ErrorLog.WriteLine(exception);
                }
            }
        }