private void EVEOnFrame(object sender, EventArgs e) { if (!OnframeProcessEveryPulse()) { return; } if (Settings.Instance.DebugOnframe) { Logging.Log("Questor", "OnFrame: this is Questor.cs [" + DateTime.UtcNow + "] by default the next pulse will be in [" + Time.Instance.QuestorPulse_milliseconds + "]milliseconds", Logging.Teal); } RunOnceAfterStartup(); RunOnceInStationAfterStartup(); if (!Cache.Instance.Paused) { if (DateTime.UtcNow.Subtract(Cache.Instance.LastWalletCheck).TotalMinutes > Time.Instance.WalletCheck_minutes && !Settings.Instance.DefaultSettingsLoaded) { WalletCheck(); } } // We always check our defense state if we're in space, regardless of questor state // We also always check panic if ((Cache.Instance.LastInSpace.AddSeconds(2) > DateTime.UtcNow) && Cache.Instance.InSpace) { DebugPerformanceClearandStartTimer(); if (!Cache.Instance.DoNotBreakInvul) { _defense.ProcessState(); } DebugPerformanceStopandDisplayTimer("Defense.ProcessState"); } if (Cache.Instance.Paused || DateTime.UtcNow < _nextQuestorAction) { Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; Cache.Instance.GotoBaseNow = false; Cache.Instance.SessionState = string.Empty; return; } if (Cache.Instance.SessionState == "Quitting") { if (_States.CurrentQuestorState != QuestorState.CloseQuestor) { Cleanup.BeginClosingQuestor(); } } // When in warp there's nothing we can do, so ignore everything if (Cache.Instance.InSpace && Cache.Instance.InWarp) { return; } switch (_States.CurrentQuestorState) { case QuestorState.Idle: if (TimeCheck()) { return; //Should we close questor due to stoptime or runtime? } if (!SkillQueueCheck()) { return; //if we need to train skills we return here, on the next pass we will be _States.CurrentQuestorState = QuestorSate.SkillTrainer } if (Cache.Instance.StopBot) { if (Settings.Instance.DebugIdle) { Logging.Log("Questor", "Cache.Instance.StopBot = true - this is set by the LocalWatch code so that we stay in station when local is unsafe", Logging.Orange); } return; } if (_States.CurrentQuestorState == QuestorState.Idle && Settings.Instance.CharacterMode != "none" && Settings.Instance.CharacterName != null) { _States.CurrentQuestorState = QuestorState.Start; return; } Logging.Log("Questor", "Settings.Instance.CharacterMode = [" + Settings.Instance.CharacterMode + "]", Logging.Orange); _States.CurrentQuestorState = QuestorState.Error; break; case QuestorState.CombatMissionsBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _combatMissionsBehavior.ProcessState(); break; case QuestorState.SkillTrainer: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // SkillTrainerClass.ProcessState(); break; case QuestorState.CombatHelperBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _combatHelperBehavior.ProcessState(); break; case QuestorState.DedicatedBookmarkSalvagerBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _dedicatedBookmarkSalvagerBehavior.ProcessState(); break; case QuestorState.DirectionalScannerBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _directionalScannerBehavior.ProcessState(); break; case QuestorState.DebugHangarsBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _debugHangarsBehavior.ProcessState(); break; case QuestorState.DebugReloadAll: if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distances.OnGridWithMe))) { return; } _States.CurrentQuestorState = QuestorState.Start; break; case QuestorState.Mining: _miningBehavior.ProcessState(); break; case QuestorState.Start: switch (Settings.Instance.CharacterMode.ToLower()) { case "combat missions": case "combat_missions": case "dps": Logging.Log("Questor", "Start Mission Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.CombatMissionsBehavior; break; case "salvage": Logging.Log("Questor", "Start Salvaging Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.DedicatedBookmarkSalvagerBehavior; break; case "mining": Logging.Log("Questor", "Start Mining Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.Mining; _States.CurrentMiningState = MiningState.Start; break; case "combat helper": case "combat_helper": case "combathelper": Logging.Log("Questor", "Start CombatHelper Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.CombatHelperBehavior; break; case "custom": Logging.Log("Questor", "Start Custom Behavior", Logging.White); //_States.CurrentQuestorState = QuestorState.BackgroundBehavior; break; case "directionalscanner": Logging.Log("Questor", "Start DirectionalScanner Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.DirectionalScannerBehavior; break; } break; case QuestorState.CloseQuestor: if (Cache.Instance.ReasonToStopQuestor == string.Empty) { Cache.Instance.ReasonToStopQuestor = "case QuestorState.CloseQuestor:"; } Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); return; case QuestorState.DebugCloseQuestor: //Logging.Log("ISBoxerCharacterSet: " + Settings.Instance.Lavish_ISBoxerCharacterSet); //Logging.Log("Profile: " + Settings.Instance.Lavish_InnerspaceProfile); //Logging.Log("Game: " + Settings.Instance.Lavish_Game); Logging.Log("Questor", "CloseQuestorCMDUplinkInnerspaceProfile: " + Settings.Instance.CloseQuestorCMDUplinkInnerspaceProfile, Logging.White); Logging.Log("Questor", "CloseQuestorCMDUplinkISboxerCharacterSet: " + Settings.Instance.CloseQuestorCMDUplinkIsboxerCharacterSet, Logging.White); Logging.Log("Questor", "CloseQuestorArbitraryOSCmd" + Settings.Instance.CloseQuestorArbitraryOSCmd, Logging.White); Logging.Log("Questor", "CloseQuestorOSCmdContents" + Settings.Instance.CloseQuestorOSCmdContents, Logging.White); Logging.Log("Questor", "WalletBalanceChangeLogOffDelay: " + Settings.Instance.WalletBalanceChangeLogOffDelay, Logging.White); Logging.Log("Questor", "WalletBalanceChangeLogOffDelayLogoffOrExit: " + Settings.Instance.WalletBalanceChangeLogOffDelayLogoffOrExit, Logging.White); Logging.Log("Questor", "EVEProcessMemoryCeiling: " + Settings.Instance.EVEProcessMemoryCeiling, Logging.White); Logging.Log("Questor", "EVEProcessMemoryCeilingLogofforExit: " + Settings.Instance.EVEProcessMemoryCeilingLogofforExit, Logging.White); Logging.Log("Questor", "Cache.Instance.CloseQuestorCMDExitGame: " + Cache.Instance.CloseQuestorCMDExitGame, Logging.White); Logging.Log("Questor", "Cache.Instance.CloseQuestorCMDLogoff: " + Cache.Instance.CloseQuestorCMDLogoff, Logging.White); Logging.Log("Questor", "Cache.Instance.CloseQuestorEndProcess: " + Cache.Instance.CloseQuestorEndProcess, Logging.White); Logging.Log("Questor", "Cache.Instance.EnteredCloseQuestor_DateTime: " + Cache.Instance.EnteredCloseQuestor_DateTime.ToShortTimeString(), Logging.White); _States.CurrentQuestorState = QuestorState.Error; return; case QuestorState.DebugWindows: List <DirectWindow> windows = Cache.Instance.Windows; if (windows != null && windows.Any()) { foreach (DirectWindow window in windows) { Logging.Log("Questor", "--------------------------------------------------", Logging.Orange); Logging.Log("Questor", "Debug_Window.Name: [" + window.Name + "]", Logging.White); Logging.Log("Questor", "Debug_Window.Caption: [" + window.Caption + "]", Logging.White); Logging.Log("Questor", "Debug_Window.Type: [" + window.Type + "]", Logging.White); Logging.Log("Questor", "Debug_Window.IsModal: [" + window.IsModal + "]", Logging.White); Logging.Log("Questor", "Debug_Window.IsDialog: [" + window.IsDialog + "]", Logging.White); Logging.Log("Questor", "Debug_Window.Id: [" + window.Id + "]", Logging.White); Logging.Log("Questor", "Debug_Window.IsKillable: [" + window.IsKillable + "]", Logging.White); Logging.Log("Questor", "Debug_Window.Html: [" + window.Html + "]", Logging.White); } //Logging.Log("Questor", "Debug_InventoryWindows", Logging.White); //foreach (DirectWindow window in windows) //{ // if (window.Type.Contains("inventory")) // { // Logging.Log("Questor", "Debug_Window.Name: [" + window.Name + "]", Logging.White); // Logging.Log("Questor", "Debug_Window.Type: [" + window.Type + "]", Logging.White); // Logging.Log("Questor", "Debug_Window.Caption: [" + window.Caption + "]", Logging.White); // //Logging.Log("Questor", "Debug_Window.Type: [" + window. + "]", Logging.White); // } //} } else { Logging.Log("Questor", "DebugWindows: No Windows Found", Logging.White); } _States.CurrentQuestorState = QuestorState.Error; return; case QuestorState.DebugInventoryTree: if (Cache.Instance.PrimaryInventoryWindow.ExpandCorpHangarView()) { Logging.Log("DebugInventoryTree", "ExpandCorpHangar executed", Logging.Teal); } Logging.Log("DebugInventoryTree", "--------------------------------------------------", Logging.Orange); Logging.Log("DebugInventoryTree", "InventoryWindow.Name: [" + Cache.Instance.PrimaryInventoryWindow.Name + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.Caption: [" + Cache.Instance.PrimaryInventoryWindow.Caption + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.Type: [" + Cache.Instance.PrimaryInventoryWindow.Type + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.IsModal: [" + Cache.Instance.PrimaryInventoryWindow.IsModal + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.IsDialog: [" + Cache.Instance.PrimaryInventoryWindow.IsDialog + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.Id: [" + Cache.Instance.PrimaryInventoryWindow.Id + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.IsKillable: [" + Cache.Instance.PrimaryInventoryWindow.IsKillable + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.IsReady: [" + Cache.Instance.PrimaryInventoryWindow.IsReady + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.LocationFlag: [" + Cache.Instance.PrimaryInventoryWindow.LocationFlag + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.currInvIdName: " + Cache.Instance.PrimaryInventoryWindow.currInvIdName, Logging.Red); Logging.Log("DebugInventoryTree", "InventoryWindow.currInvIdName: " + Cache.Instance.PrimaryInventoryWindow.currInvIdItem, Logging.Red); foreach (Int64 itemInTree in Cache.Instance.IDsinInventoryTree) { if (Cache.Instance.PrimaryInventoryWindow.GetIdsFromTree(false).Contains(itemInTree)) { Cache.Instance.PrimaryInventoryWindow.SelectTreeEntryByID(itemInTree); Cache.Instance.IDsinInventoryTree.Remove(itemInTree); break; } } break; //case QuestorState.BackgroundBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // //_backgroundbehavior.ProcessState(); //break; } }
public Questor(QuestorfrmMain form1) { _mParent = form1; _lastQuestorPulse = DateTime.UtcNow; _defense = new Defense(); _combatMissionsBehavior = new CombatMissionsBehavior(); _combatHelperBehavior = new CombatHelperBehavior(); _dedicatedBookmarkSalvagerBehavior = new DedicatedBookmarkSalvagerBehavior(); _directionalScannerBehavior = new DirectionalScannerBehavior(); _debugHangarsBehavior = new DebugHangarsBehavior(); _miningBehavior = new MiningBehavior(); //_backgroundbehavior = new BackgroundBehavior(); _cleanup = new Cleanup(); _watch = new Stopwatch(); _innerspaceCommands = new InnerspaceCommands(); _statistics = new Statistics(); Cache.Instance.ScheduleCharacterName = Logging._character; Cache.Instance.NextStartupAction = DateTime.UtcNow; // State fixed on ExecuteMission _States.CurrentQuestorState = QuestorState.Idle; if (Cache.Instance.DirectEve == null) { Logging.Log("Startup", "Error on Loading DirectEve, maybe server is down", Logging.Orange); Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.CloseQuestorEndProcess = true; Settings.Instance.AutoStart = true; Cache.Instance.ReasonToStopQuestor = "Error on Loading DirectEve, maybe server is down"; Cache.Instance.SessionState = "Quitting"; Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); return; } try { if (Cache.Instance.DirectEve.HasSupportInstances()) { //Logging.Log("Questor", "You have a valid directeve.lic file and have instances available", Logging.Orange); } else { //Logging.Log("Questor", "You have 0 Support Instances available [ _directEve.HasSupportInstances() is false ]", Logging.Orange); } } catch (Exception exception) { Logging.Log("Questor", "Exception while checking: _directEve.HasSupportInstances() in questor.cs - exception was: [" + exception + "]", Logging.Orange); } Cache.Instance.StopTimeSpecified = Program.StopTimeSpecified; Cache.Instance.MaxRuntime = Program.MaxRuntime; if (Program.StartTime.AddMinutes(10) < Program.StopTime) { Cache.Instance.StopTime = Program.StopTime; Logging.Log("Questor", "Schedule: setup correctly: stoptime is [" + Cache.Instance.StopTime.ToShortTimeString() + "]", Logging.Orange); } else { Cache.Instance.StopTime = DateTime.Now.AddHours(Time.Instance.QuestorScheduleNotUsed_Hours); Logging.Log("Questor", "Schedule: NOT setup correctly: stoptime set to [" + Time.Instance.QuestorScheduleNotUsed_Hours + "] hours from now at [" + Cache.Instance.StopTime.ToShortTimeString() + "]", Logging.Orange); Logging.Log("Questor", "You can correct this by editing schedules.xml to have an entry for this toon", Logging.Orange); Logging.Log("Questor", "Ex: <char user=\"" + Settings.Instance.CharacterName + "\" pw=\"MyPasswordForEVEHere\" name=\"MyLoginNameForEVEHere\" start=\"06:45\" stop=\"08:10\" start2=\"09:05\" stop2=\"14:20\"/>", Logging.Orange); Logging.Log("Questor", "make sure each toon has its own innerspace profile and specify the following startup program line:", Logging.Orange); Logging.Log("Questor", "dotnet questor questor -x -c \"MyEVECharacterName\"", Logging.Orange); } Cache.Instance.StartTime = Program.StartTime; Cache.Instance.QuestorStarted_DateTime = DateTime.UtcNow; // get the current process Process currentProcess = System.Diagnostics.Process.GetCurrentProcess(); // get the physical mem usage Cache.Instance.TotalMegaBytesOfMemoryUsed = ((currentProcess.WorkingSet64 / 1024) / 1024); Logging.Log("Questor", "EVE instance: totalMegaBytesOfMemoryUsed - " + Cache.Instance.TotalMegaBytesOfMemoryUsed + " MB", Logging.White); Cache.Instance.SessionIskGenerated = 0; Cache.Instance.SessionLootGenerated = 0; Cache.Instance.SessionLPGenerated = 0; Settings.Instance.CharacterMode = "none"; try { Cache.Instance.DirectEve.OnFrame += EVEOnFrame; } catch (Exception ex) { Logging.Log("Questor", string.Format("DirectEVE.OnFrame: Exception {0}...", ex), Logging.White); Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.CloseQuestorEndProcess = true; Settings.Instance.AutoStart = true; Cache.Instance.ReasonToStopQuestor = "Error on DirectEve.OnFrame, maybe the DirectEVE license server is down"; Cache.Instance.SessionState = "Quitting"; Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); } }
public static void ProcessState() { // Only pulse state changes every .5s if (DateTime.UtcNow < Cache.Instance.NextSkillTrainerProcessState) { return; } Cache.Instance.NextSkillTrainerProcessState = DateTime.UtcNow.AddMilliseconds(Time.Instance.SkillTrainerPulse_milliseconds); switch (_State.CurrentSkillTrainerState) { case SkillTrainerState.Idle: if (Cache.Instance.InStation && DateTime.UtcNow > Cache.Instance.NextSkillTrainerAction) { Logging.Log("SkillTrainer", "It is Time to Start SkillTrainer again...", Logging.White); _State.CurrentSkillTrainerState = SkillTrainerState.Begin; } break; case SkillTrainerState.Begin: _State.CurrentSkillTrainerState = SkillTrainerState.LoadPlan; SkillPlan.doneWithAllPlannedSKills = false; break; case SkillTrainerState.LoadPlan: Logging.Log("SkillTrainer", "LoadPlan", Logging.Debug); if (!SkillPlan.ImportSkillPlan()) { _State.CurrentSkillTrainerState = SkillTrainerState.Error; return; } SkillPlan.ReadySkillPlan(); _State.CurrentSkillTrainerState = SkillTrainerState.ReadCharacterSheetSkills; break; case SkillTrainerState.BuyingSkill: Logging.Log("SkillTrainer", "BuyingSkill", Logging.Debug); if (!SkillPlan.BuySkill(SkillPlan.buyingSkillTypeID)) { return; } _State.CurrentSkillTrainerState = SkillTrainerState.ReadCharacterSheetSkills; break; case SkillTrainerState.ReadCharacterSheetSkills: Logging.Log("SkillTrainer", "ReadCharacterSheetSkills", Logging.Debug); if (!SkillPlan.ReadMyCharacterSheetSkills()) { return; } _State.CurrentSkillTrainerState = SkillTrainerState.CheckTrainingQueue; break; case SkillTrainerState.CheckTrainingQueue: if (SkillPlan.skillWasInjected == true) { _State.CurrentSkillTrainerState = SkillTrainerState.ReadCharacterSheetSkills; SkillPlan.skillWasInjected = false; } if (SkillPlan.buyingSkill == true) { _State.CurrentSkillTrainerState = SkillTrainerState.BuyingSkill; } if (!SkillPlan.RetrieveSkillQueueInfo()) { return; } if (!SkillPlan.CheckTrainingQueue("SkillTrainer")) { return; } _State.CurrentSkillTrainerState = SkillTrainerState.Done; break; case SkillTrainerState.CloseQuestor: Logging.Log("Startup", "Done Training: Closing EVE", Logging.Orange); Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.CloseQuestorEndProcess = true; Settings.Instance.AutoStart = false; Cache.Instance.ReasonToStopQuestor = "Done Processing Skill Training Plan and adding skills as needed to the training queue"; Cache.Instance.SessionState = "Quitting"; Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); break; case SkillTrainerState.GenerateInnerspaceProfile: Logging.Log("SkillTrainer", "Generating Innerspace Profile for this toon: running [GenerateInnerspaceProfile.iss] from your innerspace scripts directory", Logging.Teal); if (Settings.Instance.UseInnerspace) { LavishScript.ExecuteCommand("echo runscript GenerateInnerspaceProfile \"" + Settings.Instance.CharacterName + "\""); } if (Settings.Instance.UseInnerspace) { LavishScript.ExecuteCommand("runscript GenerateInnerspaceProfile \"" + Settings.Instance.CharacterName + "\""); } _State.CurrentSkillTrainerState = SkillTrainerState.Idle; break; case SkillTrainerState.Error: Logging.Log("SkillTrainer", "Note: SkillTrainer just entered the Error State. There is likely a missing skill plan or broken contents of the skillplan!", Logging.Teal); _States.CurrentSkillTrainerState = SkillTrainerState.Done; break; case SkillTrainerState.Done: SkillPlan.attemptsToDoSomethingWithNonInjectedSkills = 0; SkillPlan.doneWithAllPlannedSKills = false; SkillPlan.injectSkillBookAttempts = 0; Cache.Instance.NextSkillTrainerAction = DateTime.UtcNow.AddHours(Cache.Instance.RandomNumber(3, 4)); _State.CurrentSkillTrainerState = SkillTrainerState.Idle; _States.CurrentQuestorState = QuestorState.Idle; break; } }
public ValueDumpUI() { Logging.Log("ValueDump", "Starting ValueDump", Logging.Orange); InitializeComponent(); _market = new Market(); #region Load DirectEVE // // Load DirectEVE // try { if (Cache.Instance.DirectEve == null) { // // DE now has cloaking enabled using EasyHook, If EasyHook DLLs are missing DE should complain. We check for and complain about missing EasyHook stuff before we get this far. // // //Logging.Log("Startup", "temporarily disabling the loading of DE for debugging purposes, halting", Logging.Debug); //while (Cache.Instance.DirectEve == null) //{ // System.Threading.Thread.Sleep(50); //this pauses forever... //} Cache.Instance.DirectEve = new DirectEve(); } } catch (Exception ex) { Logging.Log("ValueDump", "Error on Loading DirectEve, maybe server is down", Logging.Orange); Logging.Log("ValueDump", string.Format("DirectEVE: Exception {0}...", ex), Logging.White); Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.CloseQuestorEndProcess = true; Settings.Instance.AutoStart = true; Cache.Instance.ReasonToStopQuestor = "Error on Loading DirectEve, maybe server is down"; Cache.Instance.SessionState = "Quitting"; Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); return; } #endregion Load DirectEVE #region Verify DirectEVE Support Instances // // Verify DirectEVE Support Instances // try { if (Cache.Instance.DirectEve != null && Cache.Instance.DirectEve.HasSupportInstances()) { Logging.Log("ValueDump", "You have a valid directeve.lic file and have instances available", Logging.Orange); } else { Logging.Log("ValueDump", "You have 0 Support Instances available [ Cache.Instance.DirectEve.HasSupportInstances() is false ]", Logging.Orange); return; } } catch (Exception exception) { Logging.Log("ValueDump", "Exception while checking: _directEve.HasSupportInstances() - exception was: [" + exception + "]", Logging.Orange); return; } #endregion Verify DirectEVE Support Instances try { Cache.Instance.DirectEve.OnFrame += ValuedumpOnFrame; } catch (Exception ex) { Logging.Log("ValueDump", string.Format("DirectEVE.OnFrame: Exception {0}...", ex), Logging.White); return; } }
private static void Main(string[] args) { _maxRuntime = Int32.MaxValue; OptionSet p = new OptionSet { "Usage: questor [OPTIONS]", "Run missions and make uber ISK.", "", "Options:", { "u|user="******"the {USER} we are logging in as.", v => Logging._username = v }, { "p|password="******"the user's {PASSWORD}.", v => Logging._password = v }, { "c|character=", "the {CHARACTER} to use.", v => Logging._character = v }, { "s|script=", "a {SCRIPT} file to execute before login.", v => _scriptFile = v }, { "t|scriptAfterLogin="******"a {SCRIPT} file to execute after login.", v => _scriptAfterLoginFile = v }, { "l|loginOnly", "login only and exit.", v => _loginOnly = v != null }, { "x|chantling|scheduler", "use scheduler (thank you chantling!)", v => _chantlingScheduler = v != null }, { "n|loginNow", "Login using info in scheduler", v => _loginNowIgnoreScheduler = v != null }, { "h|help", "show this message and exit", v => _showHelp = v != null } }; try { Logging._QuestorParamaters = p.Parse(args); //Logging.Log(string.Format("questor: extra = {0}", string.Join(" ", extra.ToArray()))); } catch (OptionException ex) { Logging.Log("Startup", "questor: ", Logging.White); Logging.Log("Startup", ex.Message, Logging.White); Logging.Log("Startup", "Try `questor --help' for more information.", Logging.White); return; } _readyToStart = true; if (_showHelp) { System.IO.StringWriter sw = new System.IO.StringWriter(); p.WriteOptionDescriptions(sw); Logging.Log("Startup", sw.ToString(), Logging.White); return; } if (_loginNowIgnoreScheduler && !_chantlingScheduler) { _chantlingScheduler = true; } if (_chantlingScheduler && string.IsNullOrEmpty(Logging._character)) { Logging.Log("Startup", "Error: to use chantling's scheduler, you also need to provide a character name!", Logging.Red); return; } // // login using info from schedules.xml // if (_chantlingScheduler && !string.IsNullOrEmpty(Logging._character)) { Cache.Instance.ScheduleCharacterName = Logging._character; LoginUsingScheduler(); } // // direct login, no schedules.xml // if (!string.IsNullOrEmpty(Logging._username) && !string.IsNullOrEmpty(Logging._password) && !string.IsNullOrEmpty(Logging._character)) { Cache.Instance.ScheduleCharacterName = Logging._character; _readyToStart = true; } bool EasyHookExists = File.Exists(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "EasyHook.dll")); if (!EasyHookExists && !MissingEasyHookWarningGiven) { Logging.Log("Startup", "EasyHook DLL's are missing. Please copy them into the same directory as your questor.exe", Logging.Orange); Logging.Log("Startup", "halting!", Logging.Orange); MissingEasyHookWarningGiven = true; return; } #region Load DirectEVE // // Load DirectEVE // try { if (Cache.Instance.DirectEve == null) { // // DE now has cloaking enabled using EasyHook, If EasyHook DLLs are missing DE should complain. We check for and complain about missing EasyHook stuff before we get this far. // // //Logging.Log("Startup", "temporarily disabling the loading of DE for debugging purposes, halting", Logging.Debug); //while (Cache.Instance.DirectEve == null) //{ // System.Threading.Thread.Sleep(50); //this pauses forever... //} Cache.Instance.DirectEve = new DirectEve(); } } catch (Exception ex) { Logging.Log("Startup", "Error on Loading DirectEve, maybe server is down", Logging.Orange); Logging.Log("Startup", string.Format("DirectEVE: Exception {0}...", ex), Logging.White); Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.CloseQuestorEndProcess = true; Settings.Instance.AutoStart = true; Cache.Instance.ReasonToStopQuestor = "Error on Loading DirectEve, maybe server is down"; Cache.Instance.SessionState = "Quitting"; Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor, true); return; } #endregion Load DirectEVE #region Verify DirectEVE Support Instances // // Verify DirectEVE Support Instances // try { if (Cache.Instance.DirectEve != null && Cache.Instance.DirectEve.HasSupportInstances()) { Logging.Log("Startup", "You have a valid directeve.lic file and have instances available", Logging.Orange); } else { Logging.Log("Startup", "You have 0 Support Instances available [ Cache.Instance.DirectEve.HasSupportInstances() is false ]", Logging.Orange); } } catch (Exception exception) { Logging.Log("Questor", "Exception while checking: _directEve.HasSupportInstances() - exception was: [" + exception + "]", Logging.Orange); } #endregion Verify DirectEVE Support Instances try { Cache.Instance.DirectEve.OnFrame += LoginOnFrame; } catch (Exception ex) { Logging.Log("Startup", string.Format("DirectEVE.OnFrame: Exception {0}...", ex), Logging.White); } // Sleep until we're done while (!_done) { System.Threading.Thread.Sleep(50); //this runs while we wait to login } try { // // do not dispose here as we want to use the same DirectEve instance later in the main program // //_directEve.Dispose(); Cache.Instance.DirectEve.OnFrame -= LoginOnFrame; } catch (Exception ex) { Logging.Log("Startup", string.Format("DirectEVE.Dispose: Exception {0}...", ex), Logging.White); } if (_done) //this is just here for clarity, we are really held up in LoginUsingScheduler() or LoginUsingUserNamePassword(); until done == true { if (!string.IsNullOrEmpty(_scriptAfterLoginFile)) { Logging.Log("Startup", "Running Script After Login: [ timedcommand 150 runscript " + _scriptAfterLoginFile + " ]", Logging.Teal); LavishScript.ExecuteCommand("timedcommand 150 runscript " + _scriptAfterLoginFile); return; } // If the last parameter is false, then we only auto-login if (_loginOnly) { Logging.Log("Startup", "_loginOnly: done and exiting", Logging.Teal); return; } } StartTime = DateTime.Now; // // We should only get this far if run if we are already logged in... // launch questor // Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Logging.Log("Startup", "We are logged in: Launching Questor", Logging.Teal); Application.Run(new QuestorfrmMain()); }
private static void LoginOnFrame(object sender, EventArgs e) { // New frame, invalidate old cache Cache.Instance.InvalidateCache(); Cache.Instance.LastFrame = DateTime.UtcNow; Cache.Instance.LastSessionIsReady = DateTime.UtcNow; //update this regardless before we login there is no session //if (Cache.Instance.SessionState != "Quitting") //{ // // Update settings (settings only load if character name changed) // if (!Settings.Instance.DefaultSettingsLoaded) // { // Settings.Instance.LoadSettings(); // } //} if (DateTime.UtcNow < _nextPulse) { //Logging.Log("if (DateTime.UtcNow.Subtract(_lastPulse).TotalSeconds < _pulsedelay) then return"); return; } _nextPulse = DateTime.UtcNow.AddSeconds(_pulsedelay); if (!_readyToStart) { //Logging.Log("if (!_readyToStart) then return"); return; } if (_chantlingScheduler && !string.IsNullOrEmpty(Logging._character) && !_readyToStarta) { //Logging.Log("if (_chantlingScheduler && !string.IsNullOrEmpty(_character) && !_readyToStarta) then return"); return; } if (_humanInterventionRequired) { //Logging.Log("Startup", "OnFrame: _humanInterventionRequired is true (this will spam every second or so)", Logging.Orange); return; } // If the session is ready, then we are done :) if (Cache.Instance.DirectEve.Session.IsReady) { Logging.Log("Startup", "We have successfully logged in", Logging.White); Cache.Instance.LastSessionIsReady = DateTime.UtcNow; _done = true; return; } // We should not get any windows if (Cache.Instance.DirectEve.Windows.Count != 0) { foreach (DirectWindow window in Cache.Instance.DirectEve.Windows) { if (string.IsNullOrEmpty(window.Html)) { continue; } Logging.Log("Startup", "WindowTitles:" + window.Name + "::" + window.Html, Logging.White); // // Close these windows and continue // if (window.Name == "telecom") { Logging.Log("Startup", "Closing telecom message...", Logging.Yellow); Logging.Log("Startup", "Content of telecom window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.Yellow); window.Close(); continue; } // Modal windows must be closed // But lets only close known modal windows if (window.Name == "modal") { bool close = false; bool restart = false; bool needHumanIntervention = false; bool sayYes = false; bool sayOk = false; bool quit = false; //bool update = false; if (!string.IsNullOrEmpty(window.Html)) { //errors that are repeatable and unavoidable even after a restart of eve/questor needHumanIntervention = window.Html.Contains("reason: Account subscription expired"); //update |= window.Html.Contains("The update has been downloaded"); // Server going down //Logging.Log("[Startup] (1) close is: " + close); close |= window.Html.ToLower().Contains("please make sure your characters are out of harms way"); close |= window.Html.ToLower().Contains("accepting connections"); close |= window.Html.ToLower().Contains("could not connect"); close |= window.Html.ToLower().Contains("the connection to the server was closed"); close |= window.Html.ToLower().Contains("server was closed"); close |= window.Html.ToLower().Contains("make sure your characters are out of harm"); close |= window.Html.ToLower().Contains("connection to server lost"); close |= window.Html.ToLower().Contains("the socket was closed"); close |= window.Html.ToLower().Contains("the specified proxy or server node"); close |= window.Html.ToLower().Contains("starting up"); close |= window.Html.ToLower().Contains("unable to connect to the selected server"); close |= window.Html.ToLower().Contains("could not connect to the specified address"); close |= window.Html.ToLower().Contains("connection timeout"); close |= window.Html.ToLower().Contains("the cluster is not currently accepting connections"); close |= window.Html.ToLower().Contains("your character is located within"); close |= window.Html.ToLower().Contains("the transport has not yet been connected"); close |= window.Html.ToLower().Contains("the user's connection has been usurped"); close |= window.Html.ToLower().Contains("the EVE cluster has reached its maximum user limit"); close |= window.Html.ToLower().Contains("the connection to the server was closed"); close |= window.Html.ToLower().Contains("client is already connecting to the server"); //close |= window.Html.Contains("A client update is available and will now be installed"); // // eventually it would be nice to hit ok on this one and let it update // close |= window.Html.ToLower().Contains("client update is available and will now be installed"); close |= window.Html.ToLower().Contains("change your trial account to a paying account"); // // these windows require a restart of eve all together // restart |= window.Html.ToLower().Contains("the connection was closed"); restart |= window.Html.ToLower().Contains("connection to server lost."); //INFORMATION restart |= window.Html.ToLower().Contains("local cache is corrupt"); restart |= window.Html.ToLower().Contains("local session information is corrupt"); restart |= window.Html.ToLower().Contains("The client's local session"); // information is corrupt"); restart |= window.Html.ToLower().Contains("restart the client prior to logging in"); // // these windows require a quit of eve all together // quit |= window.Html.ToLower().Contains("the socket was closed"); // // Modal Dialogs the need "yes" pressed // //sayYes |= window.Html.Contains("There is a new build available. Would you like to download it now"); //sayOk |= window.Html.Contains("The update has been downloaded. The client will now close and the update process begin"); sayOk |= window.Html.Contains("The transport has not yet been connected, or authentication was not successful"); //Logging.Log("[Startup] (2) close is: " + close); //Logging.Log("[Startup] (1) window.Html is: " + window.Html); _pulsedelay = 60; } //if (update) //{ // int secRestart = (400 * 3) + Cache.Instance.RandomNumber(3, 18) * 100 + Cache.Instance.RandomNumber(1, 9) * 10; // LavishScript.ExecuteCommand("uplink exec Echo [${Time}] timedcommand " + secRestart + " OSExecute taskkill /IM launcher.exe"); //} if (sayYes) { Logging.Log("Startup", "Found a window that needs 'yes' chosen...", Logging.White); Logging.Log("Startup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.White); window.AnswerModal("Yes"); continue; } if (sayOk) { Logging.Log("Startup", "Found a window that needs 'ok' chosen...", Logging.White); Logging.Log("Startup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.White); window.AnswerModal("OK"); if (window.Html.Contains("The update has been downloaded. The client will now close and the update process begin")) { // // schedule the closing of launcher.exe via a timedcommand (10 min?) in the uplink... // } continue; } if (quit) { Logging.Log("Startup", "Restarting eve...", Logging.Red); Logging.Log("Startup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.Red); window.AnswerModal("quit"); //_directEve.ExecuteCommand(DirectCmd.CmdQuitGame); } if (restart) { Logging.Log("Startup", "Restarting eve...", Logging.Red); Logging.Log("Startup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.Red); window.AnswerModal("restart"); //_directEve.ExecuteCommand(DirectCmd.CmdQuitGame); continue; } if (close) { Logging.Log("Startup", "Closing modal window...", Logging.Yellow); Logging.Log("Startup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.Yellow); window.Close(); continue; } if (needHumanIntervention) { Logging.Log("Startup", "ERROR! - Human Intervention is required in this case: halting all login attempts - ERROR!", Logging.Red); Logging.Log("Startup", "window.Name is: " + window.Name, Logging.Red); Logging.Log("Startup", "window.Html is: " + window.Html, Logging.Red); Logging.Log("Startup", "window.Caption is: " + window.Caption, Logging.Red); Logging.Log("Startup", "window.Type is: " + window.Type, Logging.Red); Logging.Log("Startup", "window.ID is: " + window.Id, Logging.Red); Logging.Log("Startup", "window.IsDialog is: " + window.IsDialog, Logging.Red); Logging.Log("Startup", "window.IsKillable is: " + window.IsKillable, Logging.Red); Logging.Log("Startup", "window.Viewmode is: " + window.ViewMode, Logging.Red); Logging.Log("Startup", "ERROR! - Human Intervention is required in this case: halting all login attempts - ERROR!", Logging.Red); _humanInterventionRequired = true; return; } } if (string.IsNullOrEmpty(window.Html)) { continue; } if (window.Name == "telecom") { continue; } Logging.Log("Startup", "We have an unexpected window, auto login halted.", Logging.Red); Logging.Log("Startup", "window.Name is: " + window.Name, Logging.Red); Logging.Log("Startup", "window.Html is: " + window.Html, Logging.Red); Logging.Log("Startup", "window.Caption is: " + window.Caption, Logging.Red); Logging.Log("Startup", "window.Type is: " + window.Type, Logging.Red); Logging.Log("Startup", "window.ID is: " + window.Id, Logging.Red); Logging.Log("Startup", "window.IsDialog is: " + window.IsDialog, Logging.Red); Logging.Log("Startup", "window.IsKillable is: " + window.IsKillable, Logging.Red); Logging.Log("Startup", "window.Viewmode is: " + window.ViewMode, Logging.Red); Logging.Log("Startup", "We have got an unexpected window, auto login halted.", Logging.Red); _done = true; return; } return; } if (!string.IsNullOrEmpty(_scriptFile)) { try { // Replace this try block with the following once new DirectEve is pushed // _directEve.RunScript(_scriptFile); System.Reflection.MethodInfo info = Cache.Instance.DirectEve.GetType().GetMethod("RunScript"); if (info == null) { Logging.Log("Startup", "DirectEve.RunScript() does not exist. Upgrade DirectEve.dll!", Logging.Red); } else { Logging.Log("Startup", string.Format("Running {0}...", _scriptFile), Logging.White); info.Invoke(Cache.Instance.DirectEve, new Object[] { _scriptFile }); } } catch (System.Exception ex) { Logging.Log("Startup", string.Format("Exception {0}...", ex), Logging.White); _done = true; } finally { _scriptFile = null; } return; } if (Cache.Instance.DirectEve.Login.AtLogin && Cache.Instance.DirectEve.Login.ServerStatus != "Status: OK") { if (ServerStatusCheck <= 6) { Logging.Log("Startup", "Server status[" + Cache.Instance.DirectEve.Login.ServerStatus + "] != [OK] try later", Logging.Orange); ServerStatusCheck++; _nextPulse = DateTime.UtcNow.AddSeconds(30); return; } ServerStatusCheck = 0; Cache.Instance.ReasonToStopQuestor = "Server Status Check shows server still not ready after more than 3 min. Restarting Questor. ServerStatusCheck is [" + ServerStatusCheck + "]"; Logging.Log("Startup", Cache.Instance.ReasonToStopQuestor, Logging.Red); Cache.Instance.EnteredCloseQuestor_DateTime = DateTime.UtcNow; Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor, true); return; } if (Cache.Instance.DirectEve.Login.AtLogin && !Cache.Instance.DirectEve.Login.IsLoading && !Cache.Instance.DirectEve.Login.IsConnecting) { if (!Cache.Instance.DirectEve.HasSupportInstances()) { Logging.Log("Startup", "DirectEVE Requires Active Support Instances to use the convenient like Auto-Login, Market Functions (ValueDump and Market involving storylines) among other features.", Logging.White); Logging.Log("Startup", "Make sure you have support instances and that you have downloaded your directeve.lic file and placed it in the .net programs folder with your directeve.dll", Logging.White); _humanInterventionRequired = true; return; } if (DateTime.UtcNow.Subtract(AppStarted).TotalSeconds > 5) { Logging.Log("Startup", "Login account [" + Logging._username + "]", Logging.White); Cache.Instance.DirectEve.Login.Login(Logging._username, Logging._password); Logging.Log("Startup", "Waiting for Character Selection Screen", Logging.White); _pulsedelay = Time.Instance.QuestorBeforeLoginPulseDelay_seconds; return; } } if (Cache.Instance.DirectEve.Login.AtCharacterSelection && Cache.Instance.DirectEve.Login.IsCharacterSelectionReady && !Cache.Instance.DirectEve.Login.IsConnecting && !Cache.Instance.DirectEve.Login.IsLoading) { if (DateTime.UtcNow.Subtract(AppStarted).TotalSeconds > RandomNumber(Time.Instance.LoginDelayMinimum_seconds, Time.Instance.LoginDelayMaximum_seconds) && DateTime.UtcNow > NextSlotActivate) { foreach (DirectLoginSlot slot in Cache.Instance.DirectEve.Login.CharacterSlots) { if (slot.CharId.ToString(CultureInfo.InvariantCulture) != Logging._character && System.String.Compare(slot.CharName, Logging._character, System.StringComparison.OrdinalIgnoreCase) != 0) { continue; } Logging.Log("Startup", "Activating character [" + slot.CharName + "]", Logging.White); NextSlotActivate = DateTime.UtcNow.AddSeconds(30); slot.Activate(); return; } Logging.Log("Startup", "Character id/name [" + Logging._character + "] not found, retrying in 10 seconds", Logging.White); } } }