Fix bootstrapper bug.

This commit is contained in:
Michael 2017-03-07 10:06:20 -05:00
parent 0ea74f3088
commit 17957f9bb8
2 changed files with 70 additions and 56 deletions

View file

@ -52,12 +52,12 @@ namespace ShiftOS.WinForms.Controls
public void Write(string text)
{
this.Text += Localization.Parse(text);
this.AppendText(Localization.Parse(text));
}
public void WriteLine(string text)
{
this.Text += Localization.Parse(text) + Environment.NewLine;
this.AppendText(Localization.Parse(text) + Environment.NewLine);
}
}
}

View file

@ -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,64 +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();
while(CurrentSave == null)
{
}
Shiftorium.Init();
while (CurrentSave.StoryPosition < 1)
{
}
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(() =>
{
TutorialManager.StartTutorial();
}));
while(TutorialManager.IsInTutorial == true) { }
GameReady?.Invoke();
}
else
{
GameReady?.Invoke();
}
}));
thread.IsBackground = true;
thread.Start();
}
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();
}
};
ReadSave();
while (CurrentSave == null)
{
}
Shiftorium.Init();
while (CurrentSave.StoryPosition < 1)
{
}
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(() =>
{
TutorialManager.StartTutorial();
}));
while (TutorialManager.IsInTutorial == true) { }
GameReady?.Invoke();
}
else
{
GameReady?.Invoke();
}
}
public delegate void EmptyEventHandler();
public static List<ClientSave> Users