public void AutomatchAccept(int playerID, string name) { WaitCallback callBack = null; this.NotifyStatus(Loc.Get("<LOC>Automatch Accept with player ")); EventLog.WriteLine("AutomatchAccept Enter: " + name, LogCategory.Get("Automatch"), new object[0]); if (this.mKind == "FFA") { if (this.mState == SupcomAutoState.Searching) { this.mFFAPlayers.Clear(); this.mState = SupcomAutoState.FFASetup; this.CallLaunchGame = new LaunchGameDelegate(this.HostTheGame); if (callBack == null) { callBack = delegate (object o) { Thread.Sleep(ConfigSettings.GetInt("FFAWaitTime", 0x2710)); if (this.mFFAPlayers.Count >= ConfigSettings.GetInt("MinFFASize", 4)) { this.CallLaunchGame(0, ""); } else { foreach (KeyValuePair<int, string> pair in this.mFFAPlayers) { Messaging.SendCustomCommand(pair.Value, CustomCommands.AutomatchAbortChallenge, new object[0]); } } }; } ThreadPool.QueueUserWorkItem(callBack); } if (this.mState == SupcomAutoState.FFASetup) { EventLog.WriteLine("AutomatchAccept Success: " + name, LogCategory.Get("Automatch"), new object[0]); Messaging.SendCustomCommand(name, CustomCommands.AutomatchAcknowledge, new object[0]); this.mFFAPlayers.Add(playerID, name); } else { Messaging.SendCustomCommand(name, CustomCommands.AutomatchBusy, new object[0]); } } else if (this.mState == SupcomAutoState.Searching) { EventLog.WriteLine("AutomatchAccept Success: " + name, LogCategory.Get("Automatch"), new object[0]); this.mState = SupcomAutoState.MatchAccept; Messaging.SendCustomCommand(name, CustomCommands.AutomatchAcknowledge, new object[0]); } else { Messaging.SendCustomCommand(name, CustomCommands.AutomatchBusy, new object[0]); } }
public void RetryPoll() { this.NotifyStatus(Loc.Get("<LOC>Polling for game"), true); if (this.mState != SupcomAutoState.Searching) { EventLog.WriteLine("Retry Poll ignored. In a nonsearching state.", LogCategory.Get("Automatch"), new object[0]); if (this.mPollCount > 1) { this.mState = SupcomAutoState.Searching; } this.mPollCount++; } else { this.mPollCount = 0; if (this.mRatingThreshhold == 0) { this.mRatingThreshhold = ConfigSettings.GetInt("RatingThreshhold", 250); } else { this.mRatingThreshhold += ConfigSettings.GetInt("RatingSearchGrowth", 0x19); } if (this.mRatingThreshhold > ConfigSettings.GetInt("RatingMaxThresh", 500)) { this.mRatingThreshhold = ConfigSettings.GetInt("RatingMaxThresh", 500); } EventLog.WriteLine("Retry Poll", LogCategory.Get("Automatch"), new object[0]); if (ConfigSettings.GetBool("DoOldGameList", false)) { ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "GetQueryData", this, "PollComplete", new object[] { "AutomatchSelect", new object[] { this.mRating - this.mRatingThreshhold, this.mRating + this.mRatingThreshhold, this.mKind } }); } else { ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "GetQueryData", this, "PollComplete", new object[] { "AutomatchSelect2", new object[] { this.mRating - this.mRatingThreshhold, this.mRating + this.mRatingThreshhold, this.mKind, GameInformation.SelectedGame.GameID } }); } } }
public bool RemoveMatch() { this.IsTeamLeader = false; this.mPolling = false; this.mState = SupcomAutoState.Unavailable; ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "ExecuteQuery", null, null, new object[] { "AutomatchDelete", new object[0] }); return true; }
private void RegisterComplete(bool result) { VGen0 gen = null; EventLog.WriteLine("RegisterComplete", LogCategory.Get("Automatch"), new object[0]); if (result) { this.mState = SupcomAutoState.Searching; if (gen == null) { gen = delegate { this.mPolling = true; while (this.mPolling) { this.RetryPoll(); int num = new Random().Next(-5000, 0x1388); Thread.Sleep((int) (0x7530 + num)); } }; } Thread thread = new Thread(new ThreadStart(gen.Invoke)); thread.IsBackground = true; thread.Start(); } }
internal void AutomatchAbortChallenge(int senderID, string senderName) { EventLog.WriteLine("A challenge has been aborted by " + senderName, LogCategory.Get("Automatch"), new object[0]); this.NotifyStatus(Loc.Get("<LOC>Game aborted by host. Resuming search.")); this.mState = SupcomAutoState.Searching; }
private void HostTheGame(int playerID, string name) { ThreadQueue.Quazal.Enqueue(typeof(Chatroom), "Leave", null, null, new object[0]); int num = 0; while (Chatroom.InChatroom) { Thread.Sleep(10); Application.DoEvents(); num++; if (num > 300) { break; } } this.NotifyStatus(Loc.Get("<LOC>Automatch Confirm with player ")); this.mPolling = false; EventLog.WriteLine("AutomatchConfirm Enter: " + name, LogCategory.Get("Automatch"), new object[0]); if (this.mState == SupcomAutoState.MatchAccept) { EventLog.WriteLine("AutomatchConfirm Success: " + name, LogCategory.Get("Automatch"), new object[0]); this.mState = SupcomAutoState.MatchConfirm; this.RemoveMatch(); string gamename = "AUTOMATCH" + Guid.NewGuid().ToString(); this.mSupcomGameManager = new SupComGameManager(); this.mSupcomGameManager.OnGameLaunched += new EventHandler(this.mSupcomGameManager_OnGameLaunched); this.mSupcomGameManager.MyTeam = this.mTeamName; this.mSupcomGameManager.OtherTeam = this.mOpponentTeamName; this.mSupcomGameManager.BeforeExit += new EventHandler(this.mSupcomGameManager_BeforeExit); if (this.mSupcomGameManager.OnExitCount() == 0) { this.mSupcomGameManager.OnExit += new EventHandler(this.mSupcomGameManager_OnExit); } string map = this.GetMap(); string str2 = "/team 3"; string str3 = "/players 2"; if (this.mKind == "2v2") { str3 = "/players 4"; } else if (this.mKind == "3v3") { str3 = "/players 6"; } else if (this.mKind == "4v4") { str3 = "/players 8"; } else if (this.mKind == "FFA") { str2 = "/team 1"; str3 = "/players " + this.mFFAPlayers.Count.ToString(); } this.RegisterGameInfo(gamename); this.NotifyStatus(Loc.Get("<LOC>Automatch is being hosted vs. ") + Loc.Get("<LOC>Opponent")); this.mSupcomGameManager.mLaunchMap = map; this.mSupcomGameManager.HostGame(true, gamename, " /gpgnetmap " + map + " " + this.Faction + " " + str2 + " " + str3); this.mSupcomGameManager.ForceAddPlayer(User.Current.Name, "random"); this.mSupcomGameManager.ForceAddPlayer(name, "random"); this.mSupcomGameManager.ForceMap(map); if (this.OnLaunchGame != null) { this.OnLaunchGame(this, EventArgs.Empty); } EventLog.WriteLine("AutomatchConfirm: Game has been hosted: " + gamename, LogCategory.Get("Automatch"), new object[0]); Thread thread = new Thread(new ThreadStart(((VGen0)delegate { try { EventLog.WriteLine("AutomatchConfirm: Entered poll for lobby thread.", LogCategory.Get("Automatch"), new object[0]); while (this.mSupcomGameManager.GameState != GameState.Lobby) { EventLog.WriteLine("AutomatchConfirm: Gamestate is not in lobby.", LogCategory.Get("Automatch"), new object[0]); Thread.Sleep(0x3e8); } EventLog.WriteLine("AutomatchConfirm: SENT LAUNCH COMMAND TO OPPONENT.", LogCategory.Get("Automatch"), new object[0]); if (this.mAllies != null) { Messaging.SendCustomCommand(name, CustomCommands.AutomatchNotifyAllies, new object[] { gamename, 2, User.Current.Name }); } if (((this.mKind == "2v2") || (this.mKind == "3v3")) || (this.mKind == "4v4")) { Thread.Sleep(ConfigSettings.GetInt("TeamDelayTime", 0x2710)); } if (this.mKind == "FFA") { foreach (KeyValuePair<int, string> pair in this.mFFAPlayers) { Messaging.SendCustomCommand(pair.Value, CustomCommands.AutomatchLaunch, new object[] { gamename, 1, User.Current.Name, "" }); } } else { Messaging.SendCustomCommand(name, CustomCommands.AutomatchLaunch, new object[] { gamename, 2, User.Current.Name, "" }); } this.AutomatchNotifyOpponentTeam(playerID, name, this.mTeamName, gamename); if (this.mAllies != null) { foreach (string str in this.mAllies) { if (str != User.Current.Name) { Messaging.SendCustomCommand(str, CustomCommands.AutomatchLaunch, new object[] { gamename, 3, User.Current.Name, this.Faction }); } } } } catch (Exception exception) { ErrorLog.WriteLine(exception); } }).Invoke)); thread.IsBackground = true; thread.Start(); } else { Messaging.SendCustomCommand(name, CustomCommands.AutomatchBusy, new object[0]); } }
public void AutomatchRequest(int playerID, string name) { this.NotifyStatus(Loc.Get("<LOC>Automatch Request with player ")); EventLog.WriteLine("AutomatchRequest Enter: " + name, LogCategory.Get("Automatch"), new object[0]); if (this.mState == SupcomAutoState.Searching) { EventLog.WriteLine("AutomatchRequest Success: " + name, LogCategory.Get("Automatch"), new object[0]); this.mState = SupcomAutoState.MatchAccept; Messaging.SendCustomCommand(name, CustomCommands.AutomatchAccept, new object[0]); } else { EventLog.WriteLine("AutomatchRequest received, but my state is: " + this.mState.ToString(), LogCategory.Get("Automatch"), new object[0]); } }
public void AutomatchAcknowledge(int playerID, string name) { this.NotifyStatus(Loc.Get("<LOC>Game is acknowledged. Please wait for launch from player "), true); this.mPolling = false; EventLog.WriteLine("AutomatchAcknowledge Enter: " + name, LogCategory.Get("Automatch"), new object[0]); if (this.mState == SupcomAutoState.MatchAccept) { EventLog.WriteLine("AutomatchAcknowledge Success: " + name, LogCategory.Get("Automatch"), new object[0]); this.mState = SupcomAutoState.MatchAcknowledge; Messaging.SendCustomCommand(name, CustomCommands.AutomatchConfirm, new object[0]); if (this.mKind != "FFA") { this.RemoveMatch(); } } else { Messaging.SendCustomCommand(name, CustomCommands.AutomatchBusy, new object[0]); } }