private static void Main(string[] args) { Logging.Log("GoToBM","Started",Logging.white); if (args.Length == 0 || args[0].Length < 1) { Logging.Log("GoToBM"," You need to supply a bookmark name",Logging.white); Logging.Log("GoToBM"," Ended",Logging.white); return; } _BM = args[0]; _BM = _BM.ToLower(); _directEve = new DirectEve(); Cache.Instance.DirectEve = _directEve; _directEve.OnFrame += OnFrame; _traveler = new Traveler(); _cleanup = new Cleanup(); _defense = new Defense(); while (!_done) { System.Threading.Thread.Sleep(50); } _directEve.Dispose(); Logging.Log("GoToBM"," Exiting",Logging.white); return; }
private static void Main(string[] args) { if (args.Length == 0) { Logging.Log("BuyLPI", "Syntax:", Logging.white); Logging.Log("BuyLPI", "DotNet BuyLPI BuyLPI <TypeName or TypeId> [Quantity]", Logging.white); Logging.Log("BuyLPI", "(Quantity is optional)", Logging.white); Logging.Log("BuyLPI", "", Logging.white); Logging.Log("BuyLPI", "Example:", Logging.white); Logging.Log("BuyLPI", "DotNet BuyLPI BuyLPI \"Caldari Navy Mjolnir Torpedo\" 10", Logging.white); Logging.Log("BuyLPI", "*OR*", Logging.white); Logging.Log("BuyLPI", "DotNet BuyLPI BuyLPI 27339 10", Logging.white); return; } if (args.Length >= 1) { _type = args[0]; } if (args.Length >= 2) { int dummy; if (!int.TryParse(args[1], out dummy)) { Logging.Log("BuyLPI", "Quantity must be an integer, 0 - " + int.MaxValue, Logging.white); return; } if (dummy < 0) { Logging.Log("BuyLPI", "Quantity must be a positive number", Logging.white); return; } _quantity = dummy; _totalquantityoforders = dummy; } Logging.Log("BuyLPI", "Starting BuyLPI...", Logging.white); _cleanup = new Cleanup(); _directEve = new DirectEve(); Cache.Instance.DirectEve = _directEve; _directEve.OnFrame += OnFrame; // Sleep until we're done while (_done.AddSeconds(5) > DateTime.Now) Thread.Sleep(50); _directEve.Dispose(); Logging.Log("BuyLPI", "BuyLPI finished.", Logging.white); }
private static void Main(string[] args) { DateTimeForLogs = DateTime.Now; //Logging.Log("BuyLPI", "BuyLPI: Test", Logging.White); //InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTimeForLogs, "BuyLPI: Test2")); if (args.Length == 0) { ////InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTimeForLogs, "BuyLPI: 0 arguments")); //Logging.Log("QuestorTest1", "Syntax:", Logging.White); //Logging.Log("QuestorTest1", "DotNet BuyLPI BuyLPI <TypeName or TypeId> [Quantity]", Logging.White); //Logging.Log("QuestorTest1", "(Quantity is optional)", Logging.White); //Logging.Log("QuestorTest1", "", Logging.White); //Logging.Log("QuestorTest1", "Example:", Logging.White); //Logging.Log("QuestorTest1", "DotNet BuyLPI BuyLPI \"Caldari Navy Mjolnir Torpedo\" 10", Logging.White); //Logging.Log("QuestorTest1", "*OR*", Logging.White); //Logging.Log("QuestorTest1", "DotNet BuyLPI BuyLPI 27339 10", Logging.White); //return; } if (args.Length >= 1) { //_type = args[0]; } if (args.Length >= 2) { //int dummy; //if (!int.TryParse(args[1], out dummy)) //{ // Logging.Log("QuestorTest1", "Quantity must be an integer, 0 - " + int.MaxValue, Logging.White); // return; //} // //if (dummy < 0) //{ // Logging.Log("QuestorTest1", "Quantity must be a positive number", Logging.White); // return; //} // //_quantity = dummy; //_totalQuantityOfOrders = dummy; } Cache.Instance.QuestorStarted_DateTime = DateTime.UtcNow; InnerspaceCommands.CreateLavishCommands(); //InnerspaceEvents.CreateLavishEvents(); //InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTimeForLogs, "Starting BuyLPI... - innerspace Echo")); Logging.Log("QuestorTest1", "Starting QuestorTest1...", Logging.White); _cleanup = new Cleanup(); Cache.Instance.DirectEve = new DirectEve(); Cache.Instance.DirectEve.OnFrame += OnFrame; // Sleep until we're done while (_done.AddSeconds(5) > DateTime.UtcNow) { Thread.Sleep(50); } Cache.Instance.DirectEve.Dispose(); Logging.Log("QuestorTest1", "QuestorTest1 finished.", Logging.White); //InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTimeForLogs, "BuyLPI: Finished 2")); }
public void ProcessState() { if (DateTime.UtcNow < _lastCleanupProcessState.AddMilliseconds(100) || Settings.Instance.DebugDisableCleanup) //if it has not been 100ms since the last time we ran this ProcessState return. We can't do anything that close together anyway { return; } _lastCleanupProcessState = DateTime.UtcNow; if (DateTime.UtcNow < Cache.Instance.LastSessionChange.AddSeconds(10)) { if (Settings.Instance.DebugCleanup) { Logging.Log("Cleanup", "last session change was at [" + Cache.Instance.LastSessionChange + "] waiting until 20 sec have passed", Logging.Teal); } return; } if (Cache.Instance.InSpace) { // When in warp there's nothing we can do, so ignore everything if (Cache.Instance.InWarp) { if (Settings.Instance.DebugCleanup) { Logging.Log("Cleanup", "Processstate: we are in warp: do nothing", Logging.Teal); } _States.CurrentSalvageState = SalvageState.Idle; return; } if (Settings.Instance.DebugCleanup) { Logging.Log("Cleanup", "Processstate: we are in space", Logging.Teal); } if (DateTime.UtcNow < Cache.Instance.LastInStation.AddSeconds(10)) { if (Settings.Instance.DebugCleanup) { Logging.Log("Cleanup", "Processstate: last in station time is [" + Cache.Instance.LastInStation + " waiting until 10 seconds have passed", Logging.Teal); } return; } } if (Cache.Instance.InStation) { if (Settings.Instance.DebugCleanup) { Logging.Log("Cleanup", "Processstate: we are in station", Logging.Teal); } if (DateTime.UtcNow < Cache.Instance.LastInSpace.AddSeconds(10)) { if (Settings.Instance.DebugCleanup) { Logging.Log("Cleanup", "Processstate: last in space time is [" + Cache.Instance.LastInSpace + " waiting until 10 seconds have passed", Logging.Teal); } return; } } switch (_States.CurrentCleanupState) { case CleanupState.Idle: //Cleanup State should only run every 4 seconds if (DateTime.UtcNow.Subtract(_lastCleanupAction).TotalSeconds < 4) { return; } _States.CurrentCleanupState = CleanupState.CheckModalWindows; break; case CleanupState.CheckModalWindows: // // go through *every* window // if (!Cache.Instance.InSpace && !Cache.Instance.InStation && Settings.Instance.CharacterName != "AtLoginScreenNoCharactersLoggedInYet") { if (Settings.Instance.DebugCleanup) { Logging.Log("Cleanup", "CheckModalWindows: We are in a session change, waiting 4 seconds", Logging.White); } _lastCleanupAction = DateTime.UtcNow; _States.CurrentCleanupState = CleanupState.Idle; return; } if (Settings.Instance.CharacterName == "AtLoginScreenNoCharactersLoggedInYet" && Cache.Instance.LastInStation.AddHours(1) > DateTime.UtcNow) { Cache.Instance.ReasonToStopQuestor = "we are no longer in a valid session (not logged in) and we had been logged in. restarting"; Logging.Log("Cleanup", Cache.Instance.ReasonToStopQuestor, Logging.White); Settings.Instance.SecondstoWaitAfterExitingCloseQuestorBeforeExitingEVE = 0; Cache.Instance.SessionState = "Quitting"; Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); return; } if (Cache.Instance.Windows == null || !Cache.Instance.Windows.Any()) { if (Settings.Instance.DebugCleanup) { Logging.Log("Cleanup", "CheckModalWindows: Cache.Instance.Windows returned null or empty", Logging.White); } _lastCleanupAction = DateTime.UtcNow; _States.CurrentCleanupState = CleanupState.Idle; return; } if (Settings.Instance.DebugCleanup) { Logging.Log("Cleanup", "Checking Each window in Cache.Instance.Windows", Logging.Teal); } foreach (DirectWindow window in Cache.Instance.Windows) { // Telecom messages are generally mission info messages: close them if (window.Name == "telecom") { Logging.Log("Cleanup", "Closing telecom message...", Logging.White); Logging.Log("Cleanup", "Content of telecom window (HTML): [" + (window.Html ?? string.Empty).Replace("\n", "").Replace("\r", "") + "]", Logging.White); window.Close(); } // Modal windows must be closed // But lets only close known modal windows if (window.Name == "modal") { bool close = false; bool restart = false; bool restartHarsh = false; bool gotoBaseNow = false; bool sayYes = false; bool sayOk = false; bool pause = false; bool stackHangars = false; //bool sayno = false; if (!string.IsNullOrEmpty(window.Html)) { // Server going down /unscheduled/ potentially very soon! // CCP does not reboot in the middle of the day because the server is behaving // dock now to avoid problems gotoBaseNow |= window.Html.Contains("for a short unscheduled reboot"); //fitting window errors - DO NOT undock if this happens! people should fix the fits they load to not move more modules than necessary as that causes problems and requires extra modules //if (_States.CurrentQuestorState == QuestorState.BackgroundBehavior) //{ // // we do not care about fitting errors when using the BackgroundBehavior // // sayOk |= window.Html.Contains("Not all the items could be fitted"); //} //else //{ pause |= window.Html.Contains("Not all the items could be fitted"); //} pause |= window.Html.Contains("Cannot move"); if (window.Type == "form.MessageBox" && window.IsDialog && window.IsModal && window.IsKillable) { sayOk |= window.Html.Contains("If you decline of fail a mission from an agent he/she might become displeased and lower your standing towards him/her. You can decline a mission every four hours without penalty"); //4 hours without penalty } // quitting eve? close |= window.Html.Contains("Do you really want to quit now?"); // Server going down close |= window.Html.Contains("Please make sure your characters are out of harm"); close |= window.Html.Contains("the servers are down for 30 minutes each day for maintenance and updates"); // In space "shit" close |= window.Html.Contains("Item cannot be moved back to a loot container."); close |= window.Html.Contains("you do not have the cargo space"); close |= window.Html.Contains("cargo units would be required to complete this operation."); close |= window.Html.Contains("You are too far away from the acceleration gate to activate it!"); close |= window.Html.Contains("maximum distance is 2500 meters"); // agent mission decline warning (ok button) close |= window.Html.Contains("If you decline of fail a mission from an agent he/she might become displeased and lower your standing towards him/her. You can decline a mission every four hours without penalty"); //4 hours without penalty // Stupid warning, lets see if we can find it close |= window.Html.Contains("Do you wish to proceed with this dangerous action?"); // Yes we know the mission is not complete, Questor will just redo the mission close |= window.Html.Contains("weapons in that group are already full"); //close |= window.Html.Contains("You have to be at the drop off location to deliver the items in person"); //fitting window message(s) close |= window.Html.Contains("No rigs were added to or removed from the ship"); //In station - Flying Between Hangars close |= window.Html.Contains("You can't fly your active ship into someone else's hangar"); // Lag :/ close |= window.Html.Contains("This gate is locked!"); close |= window.Html.Contains("The Zbikoki's Hacker Card"); close |= window.Html.Contains(" units free."); close |= window.Html.Contains("already full"); //windows that can be disabled, but may not yet be disabled //why are we reloading an already full weapon? close |= window.Html.Contains("All the weapons in this group are already full"); //trial account close |= window.Html.Contains("At any time you can log in to the account management page and change your trial account to a paying account"); restartHarsh |= window.Html.Contains("The user's connection has been usurped on the proxy"); restartHarsh |= window.Html.Contains("The connection to the server was closed"); //CONNECTION LOST restartHarsh |= window.Html.Contains("server was closed"); //CONNECTION LOST restartHarsh |= window.Html.Contains("The socket was closed"); //CONNECTION LOST restartHarsh |= window.Html.Contains("The connection was closed"); //CONNECTION LOST restartHarsh |= window.Html.Contains("Connection to server lost"); //CONNECTION LOST restartHarsh |= window.Html.Contains("The user connection has been usurped on the proxy"); //CONNECTION LOST restartHarsh |= window.Html.Contains("The transport has not yet been connected, or authentication was not successful"); //CONNECTION LOST restartHarsh |= window.Html.Contains("Your client has waited"); //SOUL-CRUSHING LAG - Your client has waited x minutes for a remote call to complete. restartHarsh |= window.Html.Contains("This could mean the server is very loaded"); //SOUL-CRUSHING LAG - Your client has waited x minutes for a remote call to complete. // // restart the client if these are encountered // restart |= window.Html.Contains("Local cache is corrupt"); restart |= window.Html.Contains("Local session information is corrupt"); // // Modal Dialogs the need "yes" pressed // sayYes |= window.Html.Contains("objectives requiring a total capacity"); sayYes |= window.Html.Contains("your ship only has space for"); sayYes |= window.Html.Contains("Are you sure you want to remove location"); // // Accept fleet invites from this specific character // sayYes |= window.Html.Contains(Settings.Instance.CharacterToAcceptInvitesFrom + " wants you to join their fleet"); //sayyes |= window.Html.Contains("Repairing these items will cost"); sayYes |= window.Html.Contains("Are you sure you would like to decline this mission"); //sayyes |= window.Html.Contains("You can decline a mission every four hours without penalty"); sayYes |= window.Html.Contains("has no other missions to offer right now. Are you sure you want to decline"); // // LP Store "Accept offer" dialog // sayOk |= window.Html.Contains("Are you sure you want to accept this offer?"); sayOk |= window.Html.Contains("Repairing these items will cost"); sayOk |= window.Html.Contains("You do not have an outstanding invitation to this fleet."); sayOk |= window.Html.Contains("You have already selected a character for this session."); sayOk |= window.Html.Contains("If you decline or fail a mission from an agent"); // // Not Enough Shelf Space // "You can't add the Militants as there are simply too many items here already." // stackHangars |= window.Html.Contains("as there are simply too many items here already"); // // Modal Dialogs the need "no" pressed // //sayno |= window.Html.Contains("Do you wish to proceed with this dangerous action } if (restartHarsh) { Logging.Log("Cleanup: RestartWindow", "Restarting eve...", Logging.White); Logging.Log("Cleanup: RestartWindow", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.White); Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.CloseQuestorEndProcess = true; Cache.Instance.ReasonToStopQuestor = "A message from ccp indicated we were disconnected"; Settings.Instance.SecondstoWaitAfterExitingCloseQuestorBeforeExitingEVE = 0; Cache.Instance.SessionState = "Quitting"; Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); return; } if (restart) { Logging.Log("Cleanup", "Restarting eve...", Logging.White); Logging.Log("Cleanup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.White); Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.CloseQuestorEndProcess = false; Cache.Instance.ReasonToStopQuestor = "A message from ccp indicated we were should restart"; Cache.Instance.SessionState = "Quitting"; Settings.Instance.SecondstoWaitAfterExitingCloseQuestorBeforeExitingEVE = 30; window.Close(); Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); return; } if (sayYes) { Logging.Log("Cleanup", "Found a window that needs 'yes' chosen...", Logging.White); Logging.Log("Cleanup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.White); window.AnswerModal("Yes"); continue; } if (sayOk) { Logging.Log("Cleanup", "Found a window that needs 'ok' chosen...", Logging.White); Logging.Log("Cleanup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.White); if (window.Html.Contains("Repairing these items will cost")) { Cache.Instance.doneUsingRepairWindow = true; } window.AnswerModal("OK"); continue; } if (stackHangars) { if (!Cache.Instance.StackAmmoHangar("Cleanup")) { return; } if (!Cache.Instance.StackLootHangar("Cleanup")) { return; } //if (!Cache.Instance.StackItemhangar("Cleanup")) return; continue; } if (gotoBaseNow) { Logging.Log("Cleanup", "Evidently the cluster is dieing... and CCP is restarting the server", Logging.White); Logging.Log("Cleanup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.White); Cache.Instance.GotoBaseNow = true; Settings.Instance.AutoStart = false; // // do not close eve, let the shutdown of the server do that // //Cache.Instance.CloseQuestorCMDLogoff = false; //Cache.Instance.CloseQuestorCMDExitGame = true; //Cache.Instance.ReasonToStopQuestor = "A message from ccp indicated we were disconnected"; //Cache.Instance.SessionState = "Quitting"; window.Close(); continue; } if (pause) { Logging.Log("Cleanup", "This window indicates an error fitting the ship. pausing", Logging.White); Cache.Instance.Paused = true; } if (close) { Logging.Log("Cleanup", "Closing modal window...", Logging.White); Logging.Log("Cleanup", "Content of modal window (HTML): [" + (window.Html).Replace("\n", "").Replace("\r", "") + "]", Logging.White); window.Close(); continue; } } if (Cache.Instance.InSpace) { if (FoundDuelInvitation && window.IsDialog && window.IsModal && window.Caption == "Duel Invitation") { if (DateTime.UtcNow > FoundDuelInvitationTime.AddSeconds(Cache.Instance.RandomNumber(4, 25))) { //window.AnswerModal("yes"); //window.Close(); FoundDuelInvitation = true; } } if (window.IsDialog && window.IsModal && window.Caption == "Duel Invitation") { FoundDuelInvitation = true; FoundDuelInvitationTime = DateTime.UtcNow; } if (window.Name.Contains("_ShipDroneBay_") && window.Caption == "Drone Bay") { if (Settings.Instance.UseDrones && (Cache.Instance.ActiveShip.GroupId != (int)Group.Shuttle && Cache.Instance.ActiveShip.GroupId != (int)Group.Industrial && Cache.Instance.ActiveShip.GroupId != (int)Group.TransportShip && _droneBayClosingAttempts <= 1)) { _lastCleanupAction = DateTime.UtcNow; _droneBayClosingAttempts++; // Close the drone bay, its not required in space. window.Close(); } } else { _droneBayClosingAttempts = 0; } } } _States.CurrentCleanupState = CleanupState.CleanupTasks; break; case CleanupState.CleanupTasks: if (Settings.Instance.EVEMemoryManager) //https://github.com/VendanAndrews/EveMemManager { if (!MemoryManagerHasBeenRunThisIteration && Cache.Instance.InStation && DateTime.UtcNow > Cache.Instance.LastInSpace.AddSeconds(20)) { // get the current process Process currentProcess = System.Diagnostics.Process.GetCurrentProcess(); // get the physical mem usage (this only runs between missions) Cache.Instance.TotalMegaBytesOfMemoryUsed = ((currentProcess.WorkingSet64 / 1024) / 1024); Logging.Log("Questor", "EVE instance: totalMegaBytesOfMemoryUsed - " + Cache.Instance.TotalMegaBytesOfMemoryUsed + " MB", Logging.White); string MemoryManagerCommandToRun = "dotnet m1 memmanager.exe " + Settings.Instance.MemoryManagerTrimThreshold; Logging.Log("Cleanup.CleanupTasks", "EVEMemoryManager: running [ " + MemoryManagerCommandToRun + " ]", Logging.White); if (Settings.Instance.UseInnerspace) { LavishScript.ExecuteCommand(MemoryManagerCommandToRun); } MemoryManagerHasBeenRunThisIteration = true; } if (MemoryManagerHasBeenRunThisIteration && Cache.Instance.InSpace && DateTime.UtcNow > Cache.Instance.LastInStation.AddSeconds(300)) { // // reset the flag so that MemManager.exe will run again when we are next in station. // MemoryManagerHasBeenRunThisIteration = false; } } if (DateTime.UtcNow > Cache.Instance.LastSessionChange.AddSeconds(30) && ( _States.CurrentQuestorState == QuestorState.CombatMissionsBehavior || _States.CurrentQuestorState == QuestorState.CombatHelperBehavior || _States.CurrentQuestorState == QuestorState.DedicatedBookmarkSalvagerBehavior || _States.CurrentQuestorState == QuestorState.Idle || _States.CurrentQuestorState == QuestorState.Cleanup) && string.Compare(Cache.Instance.FilterPath(Settings.Instance.CharacterName).ToUpperInvariant(), Cache.Instance.FilterPath(Cache.Instance.DirectEve.Me.Name).ToUpperInvariant(), StringComparison.OrdinalIgnoreCase) == 1 ) { Logging.Log("Cleanup", "DebugInfo: Settings.Instance.CharacterName [" + Settings.Instance.CharacterName + "]", Logging.White); Logging.Log("Cleanup", "DebugInfo: Cache.Instance.DirectEve.Me.Name [" + Cache.Instance.DirectEve.Me.Name + "]", Logging.White); Cache.Instance.ReasonToStopQuestor = "CharacterName not defined! - Are we still logged in? Did we lose connection to eve? Questor should be restarting here."; Logging.Log("Cleanup", "CharacterName not defined! - Are we still logged in? Did we lose connection to eve? Questor should be restarting here.", Logging.White); Settings.Instance.CharacterName = "NoCharactersLoggedInAnymore"; Cache.Instance.EnteredCloseQuestor_DateTime = DateTime.UtcNow; Cache.Instance.SessionState = "Quitting"; _States.CurrentQuestorState = QuestorState.CloseQuestor; Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); return; } _lastCleanupAction = DateTime.UtcNow; _States.CurrentCleanupState = CleanupState.Idle; break; default: // Next state _States.CurrentCleanupState = CleanupState.Idle; break; } }