From ffcac247cd6f201137ffec97ee4d2d447167a1d3 Mon Sep 17 00:00:00 2001 From: FenPhoenix Date: Wed, 26 Jun 2019 23:07:07 -0700 Subject: [PATCH] Fix an extremely nasty bug in FMData.ini reading If "[FM]" was not the very first line in the file, the whole read would fail. --- AngelLoader/Ini/FMData.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AngelLoader/Ini/FMData.cs b/AngelLoader/Ini/FMData.cs index 53c90b95e..87f8f7823 100644 --- a/AngelLoader/Ini/FMData.cs +++ b/AngelLoader/Ini/FMData.cs @@ -5,7 +5,6 @@ using System.Text; using AngelLoader.Common.DataClasses; using AngelLoader.Common.Utility; - namespace AngelLoader.Ini { internal static partial class Ini @@ -17,6 +16,8 @@ internal static void ReadFMDataIni(string fileName, List fmsList) if (fmsList.Count > 0) fmsList.Clear(); + bool fmsListIsEmpty = true; + foreach (var line in iniLines) { var lineT = line.TrimStart(); @@ -26,11 +27,14 @@ internal static void ReadFMDataIni(string fileName, List fmsList) if (lineT.Length >= 4 && lineT[1] == 'F' && lineT[2] == 'M' && lineT[3] == ']') { fmsList.Add(new FanMission()); + if (fmsListIsEmpty) fmsListIsEmpty = false; } continue; } + if (fmsListIsEmpty) continue; + // Comment chars (;) and blank lines will be rejected implicitly. // Since they're rare cases, checking for them would only slow us down.