From 778b1a78adf7d6d33c982f36e8ff34c6c33dfebf Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 8 Jan 2018 15:34:33 +0200 Subject: [PATCH] Fixed sub editor crashing when attempting to use illegal characters in the filename. Closes #207 --- .../Source/Screens/SubEditorScreen.cs | 13 ++++++++----- Barotrauma/BarotraumaShared/Content/Texts.xml | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs index a26782690..d92be993e 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs @@ -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"; diff --git a/Barotrauma/BarotraumaShared/Content/Texts.xml b/Barotrauma/BarotraumaShared/Content/Texts.xml index 718861ee7..c1140f639 100644 --- a/Barotrauma/BarotraumaShared/Content/Texts.xml +++ b/Barotrauma/BarotraumaShared/Content/Texts.xml @@ -226,6 +226,7 @@ Gaps Previously used Name your submarine before saving it. + Illegal symbols in filename ([illegalchar]) Submarine saved to [filepath]. Save submarine Name