fix some clientside save softlocks

This commit is contained in:
Michael 2017-05-29 16:08:59 -04:00
parent 505073b693
commit ff47625d25
3 changed files with 31 additions and 18 deletions

View file

@ -313,21 +313,24 @@ namespace ShiftOS.WinForms.Applications
}
else if (a.KeyCode == Keys.Left)
{
var getstring = txt.Lines[txt.Lines.Length - 1];
var stringlen = getstring.Length + 1;
var header = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
var headerlen = header.Length + 1;
var selstart = txt.SelectionStart;
var remstrlen = txt.TextLength - stringlen;
var finalnum = selstart - remstrlen;
if (SaveSystem.CurrentSave != null)
{
var getstring = txt.Lines[txt.Lines.Length - 1];
var stringlen = getstring.Length + 1;
var header = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
var headerlen = header.Length + 1;
var selstart = txt.SelectionStart;
var remstrlen = txt.TextLength - stringlen;
var finalnum = selstart - remstrlen;
if (finalnum != headerlen)
{
AppearanceManager.CurrentPosition--;
}
else
{
a.SuppressKeyPress = true;
if (finalnum != headerlen)
{
AppearanceManager.CurrentPosition--;
}
else
{
a.SuppressKeyPress = true;
}
}
}
else if (a.KeyCode == Keys.Up)

View file

@ -207,14 +207,15 @@ namespace ShiftOS.WinForms
ServerMessageReceived smr = null;
smr = (msg) =>
{
ServerManager.MessageReceived -= smr;
if (msg.Name == "mud_savefile")
{
ServerManager.MessageReceived -= smr;
SaveSystem.CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
SaveSystem.SaveGame();
}
else if(msg.Name=="mud_login_denied")
{
ServerManager.MessageReceived -= smr;
LinkSaveFile(token);
}
};

View file

@ -214,13 +214,22 @@ namespace ShiftOS.Engine
savehandshake = (msg) =>
{
ServerManager.MessageReceived -= savehandshake;
if (msg.Name == "mud_savefile")
{
CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
}
ServerManager.MessageReceived -= savehandshake;
try
{
CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
}
catch
{
Console.WriteLine("[system] [SEVERE] Cannot parse configuration file.");
oobe.PromptForLogin();
}
}
else if (msg.Name == "mud_login_denied")
{
ServerManager.MessageReceived -= savehandshake;
oobe.PromptForLogin();
}
};