From cefb66ca16c26b0278e04a710a41da6446daa064 Mon Sep 17 00:00:00 2001 From: MaxED Date: Fri, 31 Oct 2014 13:53:43 +0000 Subject: [PATCH] A warning is now displayed when an unclosed marker range is found in a WAD (e.g. when there's a S_START, but no S_END after it). --- Source/Core/Data/WADReader.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Source/Core/Data/WADReader.cs b/Source/Core/Data/WADReader.cs index 04e1a2aa..da66b1b1 100644 --- a/Source/Core/Data/WADReader.cs +++ b/Source/Core/Data/WADReader.cs @@ -172,6 +172,10 @@ namespace CodeImp.DoomBuilder.Data // This fills a ranges list private void FindRanges(List ranges, IDictionary rangeinfos, string rangename) { + Dictionary> failedranges = new Dictionary>(); //mxd + Dictionary successfulrangestarts = new Dictionary(); //mxd + Dictionary failedrangestarts = new Dictionary(); //mxd + foreach(DictionaryEntry r in rangeinfos) { // Read start and end @@ -188,16 +192,31 @@ namespace CodeImp.DoomBuilder.Data range.end = file.FindLumpIndex(rangeend, startindex); if(range.end > -1) { + if(!successfulrangestarts.ContainsKey(startindex)) successfulrangestarts.Add(startindex, false); //mxd ranges.Add(range); startindex = file.FindLumpIndex(rangestart, range.end); } else { + //mxd + if (!failedrangestarts.ContainsKey(startindex)) + { + failedranges.Add(range, new KeyValuePair(rangestart, rangeend)); //mxd + failedrangestarts.Add(startindex, false); + } + startindex = -1; } } } } + + //mxd. Display warnings for unclosed ranges + foreach (KeyValuePair> group in failedranges) + { + if(successfulrangestarts.ContainsKey(group.Key.start)) continue; + General.ErrorLogger.Add(ErrorType.Warning, "'" + group.Value.Key + "' range at index " + group.Key.start + " is not closed in '" + location.location + "' ('" + group.Value.Value + "' marker is missing)!"); + } } #endregion