/// <summary> /// Start the entire ShiftOS engine. /// </summary> /// <param name="useDefaultUI">Whether ShiftOS should initiate it's Windows Forms front-end.</param> public static void Begin(bool useDefaultUI = true) { AppDomain.CurrentDomain.UnhandledException += (o, a) => { CrashHandler.Start((Exception)a.ExceptionObject); }; if (!System.IO.File.Exists(Paths.SaveFile)) { var root = new ShiftOS.Objects.ShiftFS.Directory(); root.Name = "System"; root.permissions = UserPermissions.Guest; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } if (Utils.Mounts.Count == 0) { Utils.Mount(System.IO.File.ReadAllText(Paths.SaveFile)); } Paths.Init(); Localization.SetupTHETRUEDefaultLocals(); SkinEngine.Init(); Random rnd = new Random(); int loadingJoke1 = rnd.Next(10); int loadingJoke2 = rnd.Next(11); TerminalBackend.OpenTerminal(); TerminalBackend.InStory = true; var thread = new Thread(new ThreadStart(() => { //Do not uncomment until I sort out the copyright stuff... - Michael //AudioManager.Init(); var defaultConf = new EngineConfig(); if (System.IO.File.Exists("engineconfig.json")) { defaultConf = JsonConvert.DeserializeObject <EngineConfig>(System.IO.File.ReadAllText("engineconfig.json")); } else { System.IO.File.WriteAllText("engineconfig.json", JsonConvert.SerializeObject(defaultConf, Formatting.Indented)); } Thread.Sleep(350); Console.WriteLine("{MISC_KERNELVERSION}"); Thread.Sleep(50); Console.WriteLine("Copyright (c) 2018 DevX. Licensed under MIT."); Console.WriteLine(""); Console.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); Console.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); Console.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"); Console.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"); Console.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"); Console.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"); Console.WriteLine("SOFTWARE."); Console.WriteLine(""); Thread.Sleep(250); Console.WriteLine("{MISC_KERNELBOOTED}"); Console.WriteLine("{MISC_SHIFTFSDRV}"); Thread.Sleep(350); Console.WriteLine("{MISC_SHIFTFSBLOCKSREAD}"); Console.WriteLine("{LOADINGMSG1_" + loadingJoke1 + "}"); Thread.Sleep(500); Console.WriteLine("{MISC_LOADINGCONFIG}"); Thread.Sleep(30); Console.WriteLine("{MISC_BUILDINGCMDS}"); TerminalBackend.PopulateTerminalCommands(); if (IsSandbox == false) { Console.WriteLine("{MISC_CONNECTINGTONETWORK}"); Ready.Reset(); if (PreDigitalSocietyConnection != null) { PreDigitalSocietyConnection?.Invoke(); Ready.WaitOne(); } ServerManager.GUIDReceived += (str) => { //Connection successful! Stop waiting! Console.WriteLine("{MISC_CONNECTIONSUCCESSFUL}"); Thread.Sleep(100); Console.WriteLine("{LOADINGMSG2_" + loadingJoke2 + "}"); Thread.Sleep(500); }; try { if (ServerManager.ServerOnline) { ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); // This halts the client until the connection is successful. ServerManager.guidReceiveARE.WaitOne(); Console.WriteLine("{MISC_DHCPHANDSHAKEFINISHED}"); } else { Console.WriteLine("{MISC_NONETWORK}"); Console.WriteLine("{LOADINGMSG2_" + loadingJoke2 + "}"); } FinishBootstrap(); } catch (Exception ex) { // "No errors, this never gets called." Console.WriteLine("[inetd] SEVERE: " + ex.Message); string dest = "Startup Exception " + DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + ".txt"; System.IO.File.WriteAllText(dest, ex.ToString()); Console.WriteLine("[inetd] Full exception details have been saved to: " + dest); Thread.Sleep(3000); System.Diagnostics.Process.GetCurrentProcess().Kill(); } //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. } else { Console.WriteLine("{MISC_SANDBOXMODE}"); CurrentSave = new Save { IsSandbox = true, Username = "******", Password = "******", SystemName = "shiftos", Users = new List <ClientSave> { new ClientSave { Username = "******", Password = "", Permissions = 0 } }, Class = 0, ID = new Guid(), Upgrades = new Dictionary <string, bool>(), CurrentLegions = null, IsMUDAdmin = false, IsPatreon = false, Language = "english", LastMonthPaid = 0, MajorVersion = 1, MinorVersion = 0, MusicEnabled = false, MusicVolume = 100, MyShop = "", PasswordHashed = false, PickupPoint = "", RawReputation = 0.0f, Revision = 0, ShiftnetSubscription = 0, SoundEnabled = true, StoriesExperienced = null, StoryPosition = 0, UniteAuthToken = "", }; CurrentUser = CurrentSave.Users.First(); Localization.SetupTHETRUEDefaultLocals(); Shiftorium.Init(); TerminalBackend.InStory = false; TerminalBackend.PrefixEnabled = true; Desktop.InvokeOnWorkerThread(new Action(() => { ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); })); Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); GameReady?.Invoke(); } })); thread.IsBackground = true; thread.Start(); }
/// <summary> /// Start the entire ShiftOS engine. /// </summary> /// <param name="useDefaultUI">Whether ShiftOS should initiate it's Windows Forms front-end.</param> public static void Begin(bool useDefaultUI = true) { if (!System.IO.File.Exists(Paths.SaveFile)) { var root = new ShiftOS.Objects.ShiftFS.Directory(); root.Name = "System"; root.permissions = Permissions.All; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } if (Utils.Mounts.Count == 0) { Utils.Mount(System.IO.File.ReadAllText(Paths.SaveFile)); } Paths.Init(); Localization.SetupTHETRUEDefaultLocals(); SkinEngine.Init(); TerminalBackend.OpenTerminal(); TerminalBackend.InStory = true; var thread = new Thread(new ThreadStart(() => { //Do not uncomment until I sort out the copyright stuff... - Michael //AudioManager.Init(); var defaultConf = new EngineConfig(); if (System.IO.File.Exists("engineconfig.json")) { defaultConf = JsonConvert.DeserializeObject <EngineConfig>(System.IO.File.ReadAllText("engineconfig.json")); } else { System.IO.File.WriteAllText("engineconfig.json", JsonConvert.SerializeObject(defaultConf, Formatting.Indented)); } Thread.Sleep(350); Console.WriteLine("Initiating kernel..."); Thread.Sleep(250); Console.WriteLine("Reading filesystem..."); Thread.Sleep(100); Console.WriteLine("Reading configuration..."); Console.WriteLine("{CONNECTING_TO_MUD}"); if (defaultConf.ConnectToMud == true) { try { bool guidReceived = false; ServerManager.GUIDReceived += (str) => { guidReceived = true; Console.WriteLine("{CONNECTION_SUCCESSFUL}"); }; ServerManager.Initiate("secondary4162.cloudapp.net", 13370); while (guidReceived == false) { } } catch (Exception ex) { Console.WriteLine("{ERROR}: " + ex.Message); Thread.Sleep(3000); ServerManager.StartLANServer(); } } else { ServerManager.StartLANServer(); } ServerManager.MessageReceived += (msg) => { if (msg.Name == "mud_savefile") { CurrentSave = JsonConvert.DeserializeObject <Save>(msg.Contents); } else if (msg.Name == "mud_login_denied") { oobe.PromptForLogin(); } }; ReadSave(); while (CurrentSave == null) { } Shiftorium.Init(); while (CurrentSave.StoryPosition < 5) { } Thread.Sleep(75); if (Shiftorium.UpgradeInstalled("desktop")) { Console.Write("{START_DESKTOP}"); Thread.Sleep(50); Console.WriteLine(" ...{DONE}."); } Story.Start(); Thread.Sleep(50); Console.WriteLine("{SYSTEM_INITIATED}"); TerminalBackend.InStory = false; Shiftorium.LogOrphanedUpgrades = true; Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); GameReady?.Invoke(); })); thread.IsBackground = true; thread.Start(); }