Fix crash when save file loaded has no valid players in it

This commit is contained in:
Cuyler36 2019-01-09 02:46:01 -05:00
parent 2665b40cdf
commit b7f2188ba5

View file

@ -11,7 +11,6 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using ACSE.Core.BitFields.Catalog;
using ACSE.Core.BitFields.Encyclopedia;
using ACSE.Core.BitFields.Museum;
@ -511,10 +510,10 @@ public void SetCurrentItem(Item newItem, bool buried = false)
if (selectedItem.SelectedValue == null)
{
if (oldSelectedItemId != null)
/*if (oldSelectedItemId != null)
{
selectedItem.SelectedValue = oldSelectedItemId;
}
}*/
}
else
{
@ -1266,6 +1265,16 @@ await Task.Run(() =>
{
MessageBox.Show("No Player was found on the file!", "Player Find Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
// If no player exists, stop loading & clear save file.
progressBar1.Value = 0;
SaveFile = null;
_loading = false;
loadingPanel.Enabled = false;
loadingPanel.Visible = false;
loadingPanel.SendToBack();
SetProgramTitle();
return;
}
SetPlayersEnabled();