diff --git a/Source/Core/Map/Linedef.cs b/Source/Core/Map/Linedef.cs index 79fb2e8..0178c9a 100644 --- a/Source/Core/Map/Linedef.cs +++ b/Source/Core/Map/Linedef.cs @@ -24,6 +24,7 @@ using CodeImp.DoomBuilder.Geometry; using System.Drawing; using System.Text.RegularExpressions; using CodeImp.DoomBuilder.IO; +using SlimDX.DirectWrite; #endregion @@ -819,32 +820,29 @@ namespace CodeImp.DoomBuilder.Map //Read translucency value from texture name (#000-#255) private int ParseTranslucency(string tex) { - int result = 128; - if (tex.StartsWith("#")) - { - int alpha; - if (int.TryParse(tex.Substring(1, 3), out alpha) && alpha >= 0 && alpha <= 255) result = alpha; - } - return result; + if (tex.StartsWith("#") && tex.Length >= 4 && int.TryParse(tex.Substring(1, 3), out int alpha)) + return General.Clamp(alpha, 0, 255); + else + return 128; } private bool ParseAdditive(string tex) { - if (tex.StartsWith("#") && tex.Length >= 5) - return int.TryParse(tex.Substring(4, 1), out int value) && value == 1; + if (tex.StartsWith("#") && tex.Length >= 5 && int.TryParse(tex.Substring(4, 1), out int value)) + return value == 1; else return false; } private bool ParseSubtractive(string tex) { - if (tex.StartsWith("#") && tex.Length >= 5) - return int.TryParse(tex.Substring(4, 1), out int value) && value == 2; + if (tex.StartsWith("#") && tex.Length >= 5 && int.TryParse(tex.Substring(4, 1), out int value)) + return value == 2; else return false; } private bool ParseReverseSubtractive(string tex) { - if (tex.StartsWith("#") && tex.Length >= 5) - return int.TryParse(tex.Substring(4, 1), out int value) && value == 3; + if (tex.StartsWith("#") && tex.Length >= 5 && int.TryParse(tex.Substring(4, 1), out int value)) + return value == 3; else return false; }