Skip to content

Commit

Permalink
Fix an extremely nasty bug in FMData.ini reading
Browse files Browse the repository at this point in the history
If "[FM]" was not the very first line in the file, the whole read would fail.
  • Loading branch information
FenPhoenix committed Jun 27, 2019
1 parent ade0cfb commit ffcac24
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion AngelLoader/Ini/FMData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Text;
using AngelLoader.Common.DataClasses;
using AngelLoader.Common.Utility;

namespace AngelLoader.Ini
{
internal static partial class Ini
Expand All @@ -17,6 +16,8 @@ internal static void ReadFMDataIni(string fileName, List<FanMission> fmsList)

if (fmsList.Count > 0) fmsList.Clear();

bool fmsListIsEmpty = true;

foreach (var line in iniLines)
{
var lineT = line.TrimStart();
Expand All @@ -26,11 +27,14 @@ internal static void ReadFMDataIni(string fileName, List<FanMission> 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.

Expand Down

0 comments on commit ffcac24

Please sign in to comment.