public Event GetEvent(int eventGroup) { Event e = Destiny.FindEvent(this, eventGroup); if (e == null) { ConsoleEx.Log("ERROR: No event found in destiny. Emptying queue and retrying."); blockedEvents.Clear(); e = Destiny.FindEvent(this, eventGroup); if (e == null) { ConsoleEx.Log("ERROR: No suitable event. Please check event filters for group id " + eventGroup + "."); return(null); } } return(e); }
public Event GetEvent(EventSpecial specialGroup) { Event e = Destiny.FindEvent(this, specialGroup); if (e == null) { ConsoleEx.Log("ERROR: No event found in destiny. Emptying queue and retrying."); blockedEvents.Clear(); e = Destiny.FindEvent(this, specialGroup); if (e == null) { ConsoleEx.Log("ERROR: No suitable event. Please check event filters for special event " + Enum.GetName(typeof(EventSpecial), specialGroup) + "."); return(null); } } return(e); }
static void Main(string[] args) { threadLibrary.Add(Thread.CurrentThread, ThreadId.Main); LogManager.CleanUpFiles(); ConsoleEx.Log("Thread started"); ConsoleEx.Log("Loading strings"); Localization.Load(); ConsoleEx.Log("Loading looters"); Looter.LoadItems(); ConsoleEx.Log("Loading destiny"); Destiny.LoadEvents(); ConsoleEx.Log("Loading planets"); Terraformer.LoadPlanets(); ConsoleEx.Log("Loading accounts"); Authorization.LoadAccounts(); ConsoleEx.Log("Rolling the dice"); Random.RollSeed(); ConsoleEx.Log("Creating the universe"); Universe.Create(); ConsoleEx.Log("Generating RSA keys"); WebSecurity.GenerateKeys(); ConsoleEx.Log("Collecting command line data"); CmdParser.Initialize(); ConsoleEx.Log("Initializing web thread"); Thread webThread = new Thread(WebCore.WebThread); WebCore.OnStart(); webThread.Start(); threadLibrary.Add(webThread, ThreadId.Web); ConsoleEx.Log("Initializing world thread"); Thread worldThread = new Thread(WorldCore.WorldThread); WorldCore.OnStart(); worldThread.Start(); threadLibrary.Add(worldThread, ThreadId.World); ConsoleEx.Log("Initializing disk thread"); Thread diskThread = new Thread(DiskCore.ThreadMain); DiskCore.OnStart(); diskThread.Start(); threadLibrary.Add(diskThread, ThreadId.Disk); ConsoleEx.Log("Initializing update thread"); Thread updateThread = new Thread(WebUpdaterCore.ThreadMain); WebUpdaterCore.OnStart(); updateThread.Start(); threadLibrary.Add(updateThread, ThreadId.Update); ConsoleEx.Log("Initializing GUI thread"); Thread guiThread = new Thread(GUICore.ThreadMain); GUICore.OnStart(); guiThread.Start(); threadLibrary.Add(guiThread, ThreadId.GUI); ConsoleEx.Log("Switching to graphical console"); HideConsole(); while (state != ThreadState.Stopping) { Thread.Sleep(1); } ConsoleEx.Log("Initializing shutdown sequence"); //ConsoleEx.Log("Switching back to native console"); //ShowConsole(); GUICore.OnStop(); ConsoleEx.Log("Shutting down update thread"); WebUpdaterCore.OnStop(); updateThread.Join(1000); updateThread.Abort(); ConsoleEx.Log("Shutting down disk thread"); DiskCore.OnStop(); diskThread.Join(1000); diskThread.Abort(); ConsoleEx.Log("Shutting down world thread"); WorldCore.OnStop(); worldThread.Join(1000); worldThread.Abort(); ConsoleEx.Log("Shutting down web thread"); WebCore.OnStop(); webThread.Join(1000); webThread.Abort(); ConsoleEx.Log("Shutting down main thread"); ConsoleEx.Log("Goodbye"); }
public static void Handle(string cmd) { bool handled = false; StringBuilder output = new StringBuilder(); // Formatting cmd = cmd.ToLower(); // Basic commands switch (cmd) { case "help": output.AppendLine("Available types:"); foreach (Type t in staticTypes) { output.AppendLine("- " + t.Name); } handled = true; break; case "event.reload": Destiny.FullReload(); break; case "exit": ConsoleWindow.CloseInstance(); handled = true; break; } // Still not handled if (!handled && cmd.Substring(0, 1) == "#") { string reflectionLine = ParseReflectionCommand(cmd.Substring(1)); if (reflectionLine != null && reflectionLine.Length > 0) { output.AppendLine(reflectionLine); handled = true; } foreach (Type t in staticTypes) { // Show all fields and properties /*if (t.Name.ToLower() == cmd.ToLower()) * { * output.AppendLine("Please note that the console functionality is still Work-In-Progress."); * var fields = t.GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); * foreach (FieldInfo field in fields) * { * output.AppendLine(field.Name + " = " + Parse(field.GetValue(null), 0)); * } * var properties = t.GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); * foreach (PropertyInfo property in properties) * { * output.AppendLine(property.Name + " = " + Parse(property.GetValue(null, null), 0)); * } * handled = true; * break; * }*/ } } // Unknown if (!handled) { output.AppendLine("Unknown command"); } // Remove last line break if (output.Length > 0) { output.Remove(output.Length - 2, 2); } // Flush to console ConsoleEx.Log(output.ToString(), false); }