Fixed sub editor crashing when attempting to use illegal characters in the filename. Closes #207

This commit is contained in:
Joonas Rikkonen
2018-01-08 15:34:33 +02:00
parent 32deb06e51
commit 778b1a78ad
2 changed files with 9 additions and 5 deletions

View File

@@ -378,12 +378,15 @@ namespace Barotrauma
nameBox.Flash();
return false;
}
if (nameBox.Text.Contains("../"))
foreach (char illegalChar in Path.GetInvalidFileNameChars())
{
DebugConsole.ThrowError("Illegal symbols in filename (../)");
nameBox.Flash();
return false;
if (nameBox.Text.Contains(illegalChar))
{
GUI.AddMessage(TextManager.Get("SubNameIllegalCharsWarning").Replace("[illegalchar]", illegalChar.ToString()), Color.Red, 3.0f);
nameBox.Flash();
return false;
}
}
string savePath = nameBox.Text + ".sub";

View File

@@ -226,6 +226,7 @@
<ShowGaps>Gaps</ShowGaps>
<PreviouslyUsedLabel>Previously used</PreviouslyUsedLabel>
<SubNameMissingWarning>Name your submarine before saving it.</SubNameMissingWarning>
<SubNameIllegalCharsWarning>Illegal symbols in filename ([illegalchar])</SubNameIllegalCharsWarning>
<SubSavedNotification>Submarine saved to [filepath].</SubSavedNotification>
<SaveSubDialogHeader>Save submarine</SaveSubDialogHeader>
<SaveSubDialogName>Name</SaveSubDialogName>