aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn/SaveSystem.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS_TheReturn/SaveSystem.cs')
-rw-r--r--ShiftOS_TheReturn/SaveSystem.cs104
1 files changed, 59 insertions, 45 deletions
diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs
index 9f0b9b7..b9633e5 100644
--- a/ShiftOS_TheReturn/SaveSystem.cs
+++ b/ShiftOS_TheReturn/SaveSystem.cs
@@ -109,6 +109,7 @@ namespace ShiftOS.Engine
bool guidReceived = false;
ServerManager.GUIDReceived += (str) =>
{
+ //Connection successful! Stop waiting!
guidReceived = true;
Console.WriteLine("Connection successful.");
};
@@ -117,20 +118,26 @@ namespace ShiftOS.Engine
{
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,69 @@ 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()
+ {
+ 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)
+ {
- }
+ }
+
+ Shiftorium.Init();
- Thread.Sleep(75);
+ while (CurrentSave.StoryPosition < 1)
+ {
+
+ }
- Thread.Sleep(50);
- Console.WriteLine("{SYSTEM_INITIATED}");
+ Thread.Sleep(75);
- TerminalBackend.InStory = false;
- TerminalBackend.PrefixEnabled = true;
- Shiftorium.LogOrphanedUpgrades = true;
+ 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();