diff options
| author | pfg <[email protected]> | 2017-03-07 17:33:44 -0800 |
|---|---|---|
| committer | pfg <[email protected]> | 2017-03-07 17:33:44 -0800 |
| commit | b20d77edd1227b2ce53b65b0752972bd65a36e84 (patch) | |
| tree | b15615591e009c9aa472ba5d95374a064c50e8b1 /ShiftOS_TheReturn/SaveSystem.cs | |
| parent | 4989356d6797335b44060ae94c9af34404773506 (diff) | |
| parent | 449d43d22c1d12ce6aa0243fbb4ea94481ff8f4c (diff) | |
| download | shiftos_thereturn-b20d77edd1227b2ce53b65b0752972bd65a36e84.tar.gz shiftos_thereturn-b20d77edd1227b2ce53b65b0752972bd65a36e84.tar.bz2 shiftos_thereturn-b20d77edd1227b2ce53b65b0752972bd65a36e84.zip | |
Merge branch 'master' of https://github.com/shiftos-game/ShiftOS
Diffstat (limited to 'ShiftOS_TheReturn/SaveSystem.cs')
| -rw-r--r-- | ShiftOS_TheReturn/SaveSystem.cs | 110 |
1 files changed, 63 insertions, 47 deletions
diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 9ae18a9..df4c6d6 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -109,28 +109,35 @@ namespace ShiftOS.Engine bool guidReceived = false; ServerManager.GUIDReceived += (str) => { + //Connection successful! Stop waiting! guidReceived = true; - Console.WriteLine("{CONNECTION_SUCCESSFUL}"); + Console.WriteLine("Connection successful."); }; try { ServerManager.Initiate("secondary4162.cloudapp.net", 13370); - while(guidReceived == false) + //This haults the client until the connection is successful. + while (ServerManager.thisGuid == new Guid()) { } + Console.WriteLine("GUID received - bootstrapping complete."); + FinishBootstrap(); } catch (Exception ex) { + //No errors, this never gets called. Console.WriteLine("{ERROR}: " + ex.Message); Thread.Sleep(3000); ServerManager.StartLANServer(); - while (guidReceived == false) + while (ServerManager.thisGuid == new Guid()) { } + Console.WriteLine("GUID received - bootstrapping complete."); + FinishBootstrap(); } } else @@ -138,62 +145,71 @@ namespace ShiftOS.Engine 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(); - } - }; + //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. - ReadSave(); + + })); + thread.IsBackground = true; + thread.Start(); + } - while(CurrentSave == null) - { + public static void FinishBootstrap() + { + KernelWatchdog.Log("mud_handshake", "handshake successful: kernel watchdog access code is \"" + ServerManager.thisGuid.ToString() + "\""); + ServerManager.MessageReceived += (msg) => + { + if (msg.Name == "mud_savefile") + { + CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents); + } + else if (msg.Name == "mud_login_denied") + { + oobe.PromptForLogin(); } + }; - Shiftorium.Init(); + ReadSave(); - while (CurrentSave.StoryPosition < 1) - { + while (CurrentSave == null) + { - } + } - Thread.Sleep(75); + Shiftorium.Init(); - Thread.Sleep(50); - Console.WriteLine("{SYSTEM_INITIATED}"); + while (CurrentSave.StoryPosition < 1) + { - TerminalBackend.InStory = false; - TerminalBackend.PrefixEnabled = true; - Shiftorium.LogOrphanedUpgrades = true; + } + + Thread.Sleep(75); + + Thread.Sleep(50); + Console.WriteLine("{SYSTEM_INITIATED}"); + + TerminalBackend.InStory = false; + TerminalBackend.PrefixEnabled = true; + Shiftorium.LogOrphanedUpgrades = true; + Desktop.InvokeOnWorkerThread(new Action(() => + { + ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); + })); + Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); + if (CurrentSave.StoryPosition == 1) + { Desktop.InvokeOnWorkerThread(new Action(() => { - ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); + TutorialManager.StartTutorial(); + })); - Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); - if (CurrentSave.StoryPosition == 1) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - TutorialManager.StartTutorial(); - - })); - while(TutorialManager.IsInTutorial == true) { } - GameReady?.Invoke(); - } - else - { - GameReady?.Invoke(); - } - })); - thread.IsBackground = true; - thread.Start(); + while (TutorialManager.IsInTutorial == true) { } + GameReady?.Invoke(); + } + else + { + GameReady?.Invoke(); + } } public delegate void EmptyEventHandler(); @@ -299,7 +315,7 @@ namespace ShiftOS.Engine System.IO.File.WriteAllText(Paths.SaveFile, Utils.ExportMount(0)); } - public static void TransferCodepointsFrom(string who, int amount) + public static void TransferCodepointsFrom(string who, long amount) { NotificationDaemon.AddNotification(NotificationType.CodepointsReceived, amount); CurrentSave.Codepoints += amount; |
