private static void SetChatInfo(GameInformation info)
 {
     info.GameID = -1;
     info.GameDescription = Loc.Get("<LOC>GPGnet (Chat Only)");
     info.CDKey = "NOTNEEDED";
     info.GameLocation = Application.ExecutablePath;
     info.isInDb = true;
     GPGNetChat = info;
 }
 public CustomApplication(DataRecord record) : base(record)
 {
     foreach (GameInformation information in GameInformation.Games)
     {
         if (this.GameID == information.GameID)
         {
             this.mGameInfo = information;
         }
     }
     try
     {
         File.Delete(this.GetLocalPatchFile());
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
 }
 public static void LoadCachedGames()
 {
     Exception exception;
     try
     {
         GameInformation current;
         try
         {
             if (File.Exists(GetGameCachePath()))
             {
                 XmlSerializer serializer = new XmlSerializer(Games.GetType());
                 FileStream stream = new FileStream(GetGameCachePath(), FileMode.Open);
                 List<GameInformation> list = serializer.Deserialize(stream) as List<GameInformation>;
                 if (list != null)
                 {
                     Games = list;
                 }
                 stream.Close();
             }
         }
         catch (Exception exception1)
         {
             exception = exception1;
             ErrorLog.WriteLine(exception);
         }
         bool flag = false;
         bool flag2 = false;
         bool flag3 = false;
         using (List<GameInformation>.Enumerator enumerator = Games.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 current = enumerator.Current;
                 if (current.GameID == -1)
                 {
                     SetChatInfo(current);
                     flag = true;
                 }
                 if (current.GameID == 2)
                 {
                     flag2 = true;
                 }
                 if (current.GameID == 15)
                 {
                     flag3 = true;
                 }
             }
         }
         if (!flag)
         {
             current = new GameInformation();
             SetChatInfo(current);
             Games.Add(current);
         }
         if (!(flag2 || (!(Program.Settings.Login.DefaultServerName == "Retail Server") || !(Program.Settings.Login.DefaultServerName == "Supreme Commander Server"))))
         {
             Games.Add(GetSupcomInfo());
         }
         if (!(flag3 || (!(Program.Settings.Login.DefaultServerName != "Retail Server") || !(Program.Settings.Login.DefaultServerName != "Supreme Commander Server"))))
         {
             current = GetSpaceSiegeInfo();
             if (current != null)
             {
                 Games.Add(current);
             }
         }
         CheckMissingPaths();
         GamesChanged();
     }
     catch (Exception exception2)
     {
         exception = exception2;
         ErrorLog.WriteLine(exception);
     }
 }
 public static void LoadGamesFromDB()
 {
     DataList queryData = DataAccess.GetQueryData("Application Games", new object[0]);
     DataList list2 = DataAccess.GetQueryData("Application Keys", new object[0]);
     if (queryData.Count >= 2)
     {
         foreach (DataRecord record in queryData)
         {
             GameInformation item = new GameInformation();
             item.GameID = Convert.ToInt32(record["gpgnet_game_id"]);
             item.GameDescription = record["description"];
             item.ForcedCommandLineArgs = record["forced_command_line_args"];
             item.ApplicationDirectory = record["relative_app_directory"];
             item.VersionFile = record["relative_version_file"];
             item.ExeName = record["exe_name"];
             item.IconLabel = record["icon_label"];
             item.PatcherAppURL = record["patcher_app_url"];
             item.PatchURL = record["patch_url"];
             item.CurrentVersion = record["current_build"];
             item.InstallDirectory = record["install_directory"];
             item.LongDescription = record["long_description"];
             item.isInDb = true;
             foreach (DataRecord record2 in list2)
             {
                 if (record2["gpgnet_game_id"] == record["gpgnet_game_id"])
                 {
                     item.CDKey = record2["key_chars"];
                 }
             }
             GameInformation information2 = null;
             foreach (GameInformation information3 in Games)
             {
                 if (information3.GameID.ToString() == record["gpgnet_game_id"])
                 {
                     information2 = information3;
                 }
             }
             if (information2 == null)
             {
                 Games.Add(item);
             }
             else
             {
                 information2.DoCompare(item);
             }
         }
         CheckMissingPaths();
         for (int i = Games.Count - 1; i >= 0; i--)
         {
             if (!Games[i].isInDb)
             {
                 Games.RemoveAt(i);
             }
         }
         SaveGames();
         GamesChanged();
     }
 }
 private static GameInformation GetSupcomInfo()
 {
     GameInformation information = new GameInformation();
     information.GameID = 2;
     information.GameLocation = Program.Settings.SupcomPrefs.GamePath;
     information.ExeName = "SupremeCommander.exe";
     information.GameDescription = "Supreme Commander";
     information.VersionFile = "MohoEngine.dll";
     information.isInDb = true;
     return information;
 }
 private static GameInformation GetSpaceSiegeInfo()
 {
     GameInformation information = new GameInformation();
     information.GameID = 15;
     information.GameLocation = string.Empty;
     information.ExeName = "SpaceSiege.exe";
     information.GameDescription = "Space Siege";
     information.VersionFile = information.ExeName;
     information.isInDb = true;
     string name = @"Software\SEGA\Gas Powered Games\Space Siege\";
     RegistryKey key = Registry.CurrentUser.OpenSubKey(name);
     if (key == null)
     {
         key = Registry.LocalMachine.OpenSubKey(name);
     }
     if (key != null)
     {
         string path = (string) key.GetValue("InstallationDirectory");
         path = path + @"\" + information.ExeName;
         if (File.Exists(path))
         {
             information.GameLocation = path;
         }
         return information;
     }
     return null;
 }
 private void DoCompare(GameInformation dbinfo)
 {
     this.GameDescription = dbinfo.GameDescription;
     if ((this.ForcedCommandLineArgs != dbinfo.ForcedCommandLineArgs) && (this.ForcedCommandLineArgs == ""))
     {
         this.ForcedCommandLineArgs = dbinfo.ForcedCommandLineArgs;
         this.UserForcedCommandLineArgs = "";
     }
     this.ApplicationDirectory = dbinfo.ApplicationDirectory;
     this.VersionFile = dbinfo.VersionFile;
     this.CDKey = dbinfo.CDKey;
     this.ExeName = dbinfo.ExeName;
     this.IconLabel = dbinfo.IconLabel;
     this.isInDb = dbinfo.isInDb;
     this.PatchURL = dbinfo.PatchURL;
     this.PatcherAppURL = dbinfo.PatcherAppURL;
     this.CurrentVersion = dbinfo.CurrentVersion;
     this.InstallDirectory = dbinfo.InstallDirectory;
     this.LongDescription = dbinfo.LongDescription;
     this.ForcedCommandLineArgs = dbinfo.ForcedCommandLineArgs;
     this.mGameIcon = null;
     if (this.GameDescription.ToUpper() == "SUPREME COMMANDER")
     {
         this.GameLocation = Program.Settings.SupcomPrefs.GamePath;
     }
     else if (this.GameDescription.ToUpper() == "GPGNET")
     {
         this.GameLocation = Application.ExecutablePath;
     }
 }
Beispiel #8
0
 public FrmMain()
 {
     WaitCallback callBack = null;
     MessageEventHandler handler = null;
     EventHandler handler2 = null;
     EventHandler handler3 = null;
     this.components = null;
     this.WebURL = null;
     this.IsGPGNetPatching = true;
     this.mNotFound = "";
     this.IsLatestVer = false;
     this.mPatchFileName = "";
     this.mServerGameVersion = null;
     this.mLastSelectedGame = null;
     this.mIsSupComVersionEnforced = null;
     this.mIsSupComPatching = false;
     this.DlgUpdate = null;
     this.SupComPatchThread = null;
     this.FriendsLoaded = false;
     this.FriendContainers = new BoundContainerList();
     this.FriendContainerLookup = new Dictionary<string, TextContainer>();
     this.ActiveDialogRequests = new List<string>();
     this.FriendRequests = new MappedObjectList<FriendRequest>();
     this.AwaitingLogin = true;
     this.ContinueLoading = null;
     this.LadderViews = new Dictionary<int, FrmLadderView>();
     this.mGameMenuItems = new List<ToolStripMenuItem>();
     this.mLastMoveItem = null;
     this.mConfigSleepRate = 0x493e0;
     this.mFirstConfig = true;
     this.mLastMOTD = "";
     this.mLastProcessList = "";
     this.mConfigThread = null;
     this.mConnected = true;
     this.mShuttingDown = false;
     this.CancelFade = false;
     this.HasFadeStarted = false;
     this.IsFading = false;
     this.TargetFade = 0.0;
     this.FadeIncrement = 0.0;
     this.StayActive = false;
     this.mIsActiveWindow = false;
     this.mWelcomePage = null;
     this.mRanInitializeChat = false;
     this.mHeightDiff = 0;
     this.mWidthDiff = 0;
     this.mLastX = 0;
     this.mLastY = 0;
     this.mLastMouseX = 0;
     this.mLastMouseY = 0;
     this.mLastWidth = 0;
     this.mLastHeight = 0;
     this.mIsMoving = false;
     this.mIsResizing = false;
     this.mStartResizing = false;
     this.RESIZE_RECT = 40;
     this.mResizeRect = new Rectangle();
     this.FirstPaint = true;
     this.mIsMaximized = false;
     this.mRestore = new Rectangle(0, 0, 100, 100);
     this.MinimizeLoc = new Point(-32000, -32000);
     this.MinimizeSize = new Size(640, 500);
     this.StatusTimer = null;
     this.mActiveDialogs = new List<DlgBase>();
     this.mActiveWindow = null;
     this.DlgAbout = null;
     this.DlgOptions = null;
     this.DlgUserFeedback = null;
     this.FrmStatsLadders = new List<FrmStatsLadder>();
     this.DlgGameKeys = null;
     this.DlgEmotes = null;
     this.DlgSelectChannel = null;
     this.DlgKeywordSearch = null;
     this.DlgSearchResults = null;
     this.DlgSolution = null;
     this.DlgSearchReplays = null;
     this.DlgTeamGame = null;
     this.DlgSelectGame = null;
     this.DlgActiveEfforts = null;
     this.DlgContentManager = null;
     this.mSearchingForAutomatch = false;
     this.mLastStatus = "";
     this.mCalcGridHeight = false;
     this.ToolstripSizeChanged = false;
     this.mCustomPaint = new List<ToolStripItem>();
     this.mLastCheckTime = DateTime.Now;
     this.mDlgWorldMap = null;
     this.mSelectedTab = null;
     this.mGameLinkClickTime = DateTime.Now;
     this.ChatRowPoints = new Dictionary<int, Rectangle>();
     this.ChatRowHeights = new Dictionary<int, int>();
     this.mFirstChatDraw = true;
     this.SelectedEmote = null;
     this.LastTick = 0;
     this.Divider = 1;
     this.CurrentFrame = 1;
     this.EmoteCount = 0;
     this.CountEmotes = true;
     this.PaintPending = false;
     this.mSelectedParticipantView = null;
     this.UIQueue = new ThreadQueue(true);
     this.IsSortingChatroom = false;
     this.IsSynchronizingChatroom = false;
     this.ChatSyncTimer = null;
     this._AddUser = null;
     this._UpdateUser = null;
     this._RemoveUser = null;
     this.mSelectedChatParticipant = null;
     this.ChatContainerLookup = new Dictionary<string, TextContainer<StatusTextLine>>();
     this.ChatContainers = new BoundContainerList<StatusTextLine>();
     this.RefreshData = false;
     this.BetweenChannels = false;
     this.mMainChatrom = "";
     this.ChatroomQueue = new ThreadQueue(true);
     this.mLastChatTimes = Hashtable.Synchronized(new Hashtable());
     this.mLastChatContent = Hashtable.Synchronized(new Hashtable());
     this.mChatLines = new BindingList<ChatLine>();
     this.PlayerChatEffects = new Dictionary<string, ChatEffectBase>();
     this.mSpeakingTimers = new Dictionary<string, StateTimer>();
     this.AwayTimer = new StateTimer();
     this.SelfLeaveTimer = new StateTimer();
     this.LastAction = DateTime.Now;
     this.mChatHistory = new LinkedList<string>();
     this.HistoryIndex = -1;
     this.SelectingTextList = false;
     this.PMTargets = new List<string>();
     this.mPrivateChats = new Dictionary<string, FrmPrivateChat>();
     this.PlayerProfileForm = null;
     this.ClanLoaded = false;
     this.ClanContainers = new BoundContainerList();
     this.ClanContainerLookup = new Dictionary<string, TextContainer>();
     this.ClanRequests = null;
     this.ClanInvites = null;
     this.ClanProfileForm = null;
     this.mBeforeGameChatroom = "";
     this.mIsInGame = false;
     this.StatusButtonRankedGameCancel = new SkinStatusButton();
     this.mGameName = "";
     this.mGameURL = "";
     this.mHostName = "";
     this.mSupcomGameManager = null;
     this.mPassword = "";
     this.mFirstRankedSupcomGame = true;
     this.PlayNowMatch = false;
     this.mAutoStatus = Loc.Get("<LOC>Searching for game ");
     this.LastGameChallenges = new Dictionary<int, bool>();
     this.LadderInvitePending = false;
     this.mCanDirectChallenge = true;
     this.mDirectChallengePlayer = "";
     this.AllowDirectChallenge = true;
     this.BeforeTeamGameChatroom = null;
     this.mTeamAutomatchExit = false;
     this.InviteAccepted = false;
     this.InvitePending = false;
     this.PendingJoinFrom = null;
     ThreadID = Thread.CurrentThread.ManagedThreadId;
     if (new DlgLogin().ShowDialog() == DialogResult.OK)
     {
         if (callBack == null)
         {
             callBack = delegate (object p) {
                 GameInformation.LoadGamesFromDB();
                 new QuazalQuery("RemoveSpaceSiegeGame", new object[0]).ExecuteNonQuery();
                 ConfigSettings.LoadSettings(DataAccess.GetQueryData("GetAllConfigs", new object[0]));
                 try
                 {
                     DataList queryData = null;
                     queryData = DataAccess.GetQueryData("GetTOSPrompt", new object[0]);
                     if ((queryData != null) && (queryData.Count < 1))
                     {
                         DataAccess.ExecuteQuery("CreatePlayerInfo", new object[0]);
                         queryData = DataAccess.GetQueryData("GetTOSPrompt", new object[0]);
                     }
                     if ((queryData != null) && (queryData.Count > 0))
                     {
                         if (Convert.ToInt32(queryData[0]["term_of_service_prompt"]) > 0)
                         {
                             if (new DlgTermsOfService(this, queryData[0]["url"]).ShowDialog() == DialogResult.OK)
                             {
                                 ThreadQueue.Quazal.Enqueue((VGen0)delegate {
                                     DataAccess.ExecuteQuery("SetTOSPrompt", new object[] { 0 });
                                 }, new object[0]);
                                 this.ContinueLoading = true;
                             }
                             else
                             {
                                 this.ContinueLoading = false;
                             }
                         }
                         else
                         {
                             this.ContinueLoading = true;
                         }
                     }
                     else
                     {
                         AuditLog.WriteLine("Unable to find Terms of Service agreement.", new object[0]);
                         this.ContinueLoading = true;
                     }
                 }
                 catch (Exception exception)
                 {
                     ErrorLog.WriteLine(exception);
                     this.ContinueLoading = false;
                 }
             };
         }
         ThreadQueue.QueueUserWorkItem(callBack, new object[0]);
         while (!this.ContinueLoading.HasValue)
         {
             Thread.Sleep(100);
         }
         if (this.ContinueLoading.Value)
         {
             if (ConfigSettings.GetBool("DoOldGameList", false))
             {
                 if (((User.Current.IsAdmin || (GameInformation.SelectedGame.GameID == -1)) || (GameKey.BetaKeys.Count > 0)) || ((GameKey.BetaKeys.Count < 1) && (new DlgNoBetaKey(this).ShowDialog() == DialogResult.OK)))
                 {
                     this.AwaitingLogin = false;
                 }
                 else
                 {
                     User.Logout();
                     this.ContinueLoading = false;
                     this.AwaitingLogin = false;
                 }
             }
             else if (((User.Current.IsAdmin || (GameInformation.SelectedGame.GameID == -1)) || (GameInformation.SelectedGame.CDKey != "")) || (new DlgNoBetaKey(this).ShowDialog() == DialogResult.OK))
             {
                 this.AwaitingLogin = false;
             }
             else
             {
                 User.Logout();
                 this.ContinueLoading = false;
                 this.AwaitingLogin = false;
             }
         }
         else
         {
             Application.Exit();
             this.AwaitingLogin = false;
         }
     }
     else
     {
         this.AwaitingLogin = false;
         if (OnCancelLoad != null)
         {
             OnCancelLoad(this, EventArgs.Empty);
         }
     }
     if (((User.Current == null) || base.Disposing) || base.IsDisposed)
     {
         if (OnCancelLoad != null)
         {
             OnCancelLoad(this, EventArgs.Empty);
         }
         base.Close();
     }
     else if (!(!this.ContinueLoading.HasValue ? false : this.ContinueLoading.Value))
     {
         if (OnCancelLoad != null)
         {
             OnCancelLoad(this, EventArgs.Empty);
         }
         base.Close();
     }
     else
     {
         Exception exception;
         this.InitializeComponent();
         this.InitializePlugins();
         this.SetToolTips();
         this.gpgChatGrid.IsCheckingExpand = false;
         DlgMessage.RegistermainForm(this);
         DlgSupcomTeamSelection.sFrmMain = this;
         if (this.GatheringDisplaycontrol is SkinGatheringDisplay)
         {
             (this.GatheringDisplaycontrol as SkinGatheringDisplay).MainForm = this;
         }
         this.ResetLobby();
         base.ShowInTaskbar = false;
         IntPtr handle = base.Handle;
         this.DoubleBuffered = true;
         this.SetSkin(Program.Settings.SkinName);
         this.StyleApplication(this, null);
         this.StyleChatroom(this, null);
         base.FormBorderStyle = FormBorderStyle.Sizable;
         User.LoggedOut += new EventHandler(this.LogoutLobby);
         this.SetRegion();
         this.PopulateLadderMenuItems();
         this.InitStatusDropdown();
         this.ChatFiltersChanged();
         this.SetLogo(this);
         this.ciChat_TeamInvite.DrawItem += new DrawItemEventHandler(this.miArrangedTeamsPopup_DrawItem);
         this.skinDropDownStatus.Enabled = false;
         this.textBoxMsg.Properties.MaxLength = 300;
         this.GatheringDisplaycontrol.Popup += new EventHandler(this.comboBoxGatherings_Popup);
         this.CheckControl(this);
         Messaging.NetDataRecieved += new NetDataEventHandler(FrmMain.Messaging_NetDataRecieved);
         Messaging.MessageRecieved += new MessageEventHandler(this.Messaging_MessageRecieved);
         Messaging.CommandRecieved += new MessageEventHandler(this.Messaging_CommandRecieved);
         if (handler == null)
         {
             handler = delegate (MessageEventArgs e) {
                 this.ParseCustomCommand(e.Command, e.CommandArgs);
             };
         }
         Messaging.CustomCommandRecieved += handler;
         if (handler2 == null)
         {
             handler2 = delegate (object s, EventArgs e) {
                 base.Invalidate(false);
             };
         }
         base.SizeChanged += handler2;
         if (handler3 == null)
         {
             handler3 = delegate (object s, EventArgs e) {
                 if (this.ActiveWindow != null)
                 {
                     this.ActiveWindow = null;
                 }
             };
         }
         base.Activated += handler3;
         base.MouseDown += new MouseEventHandler(this.this_MouseDown);
         this.pbTop.MouseDown += new MouseEventHandler(this.this_MouseDown);
         this.pbTopLeft.MouseDown += new MouseEventHandler(this.this_MouseDown);
         this.pbTopRight.MouseDown += new MouseEventHandler(this.this_MouseDown);
         this.pbBottomRight.MouseDown += new MouseEventHandler(this.this_MouseDown);
         base.MouseUp += new MouseEventHandler(this.this_MouseUp);
         this.pbTop.MouseUp += new MouseEventHandler(this.this_MouseUp);
         this.pbTopLeft.MouseUp += new MouseEventHandler(this.this_MouseUp);
         this.pbTopRight.MouseUp += new MouseEventHandler(this.this_MouseUp);
         this.gvChat.RowSeparatorHeight = Program.Settings.Chat.Appearance.ChatLineSpacing;
         this.BindToSettings();
         this.PreLoadChat();
         while (this.AwaitingLogin && (!base.Disposing && !base.IsDisposed))
         {
             Thread.Sleep(100);
         }
         ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "GetQueryData", this, "OnGetConfigs", new object[] { "GetAllConfigs" });
         ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "GetQueryData", this, "AddMenuItems", new object[] { "GetMenuItems" });
         try
         {
             ThreadQueue.QueueUserWorkItem(delegate (object state) {
                 DataAccess.ExecuteQuery("SetIP2", new object[] { User.HashPassword(DlgLogin.LastPass) });
                 DlgLogin.LastPass = "";
             }, new object[0]);
         }
         catch (Exception exception1)
         {
             exception = exception1;
             ErrorLog.WriteLine(exception);
         }
         ThreadQueue.QueueUserWorkItem(delegate (object state) {
             DataAccess.ExecuteQuery("AcceptAllLadderChallenges", new object[] { User.Current.ID });
         }, new object[0]);
         if (User.Current.IsAdmin)
         {
             this.miTranslate.Visible = true;
         }
         if (AccessControlList.HasAccessTo("PatchAdmins"))
         {
             this.miTools_LocPatches.Visible = true;
             this.miTools_LocPatches.Enabled = true;
         }
         if (AccessControlList.HasAccessTo("PrizeWinners"))
         {
             this.miGame_RedeemPrize.Visible = true;
             this.miGame_RedeemPrize.Enabled = true;
         }
         try
         {
             this.CreateGameList();
             this.RefreshGameList();
         }
         catch (Exception exception2)
         {
             exception = exception2;
         }
     }
 }
 private void sbAdd_Click(object sender, EventArgs e)
 {
     this.mAddMode = true;
     GameInformation item = new GameInformation();
     item.GameDescription = "New Game";
     item.PatcherAppURL = "http://thevault.gaspowered.com/webpatch.exe";
     item.PatchURL = "http://thevault.gaspowered.com/PatchService/Service.asmx?WSDL";
     this.lbGames.Items.Add(item);
     this.lbGames.SelectedItem = item;
     this.SetEditMode(true);
 }