Another SteamHandler null fix for if path was not set during parsing

This commit is contained in:
Justin Swanson 2020-01-03 20:49:22 -06:00
parent f9f9646cc8
commit da440d9dae

View File

@ -131,7 +131,7 @@ namespace Wabbajack.Common.StoreHandlers
Directory.EnumerateFiles(u, "*.acf", SearchOption.TopDirectoryOnly).Where(File.Exists).Do(f =>
{
var game = new SteamGame();
var valid = false;
var gotID = false;
File.ReadAllLines(f).Do(l =>
{
@ -140,6 +140,7 @@ namespace Wabbajack.Common.StoreHandlers
if (!int.TryParse(GetVdfValue(l), out var id))
return;
game.ID = id;
gotID = true;
}
if (l.Contains("\"name\""))
@ -149,19 +150,17 @@ namespace Wabbajack.Common.StoreHandlers
{
var path = Path.Combine(u, "common", GetVdfValue(l));
if (Directory.Exists(path))
{
game.Path = path;
else
return;
}
}
valid = true;
});
if (!valid) return;
if (!gotID || !Directory.Exists(game.Path)) return;
var gameMeta = GameRegistry.Games.Values.FirstOrDefault(g =>
{
return g.SteamIDs.Contains(game.ID)
return (g.SteamIDs?.Contains(game.ID) ?? false)
&& (g.RequiredFiles?.TrueForAll(file => File.Exists(Path.Combine(game.Path, file))) ?? true);
});