SteamHandler will skip broken acf files

This commit is contained in:
erri120 2019-11-30 11:31:41 +01:00
parent ebee179634
commit 7d9c80aef3
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -8,7 +8,7 @@ using Microsoft.Win32;
namespace Wabbajack.Common
{
[DebuggerDisplay("{Name}")]
[DebuggerDisplay("{" + nameof(Name) + "}")]
public class SteamGame
{
public int AppId;
@ -94,16 +94,26 @@ namespace Wabbajack.Common
Directory.EnumerateFiles(p, "*.acf", SearchOption.TopDirectoryOnly).Do(f =>
{
var steamGame = new SteamGame();
var valid = false;
File.ReadAllLines(f, Encoding.UTF8).Do(l =>
{
if(l.Contains("\"appid\""))
steamGame.AppId = int.Parse(GetVdfValue(l));
if (l.Contains("\"name\""))
steamGame.Name = GetVdfValue(l);
if (l.Contains("\"installdir\""))
steamGame.InstallDir = Path.Combine(p, "common", GetVdfValue(l));
if (!l.Contains("\"appid\""))
return;
if (!l.Contains("\"name\""))
return;
if (!l.Contains("\"installdir\""))
return;
steamGame.AppId = int.Parse(GetVdfValue(l));
steamGame.Name = GetVdfValue(l);
steamGame.InstallDir = Path.Combine(p, "common", GetVdfValue(l));
valid = true;
});
if (!valid)
return;
steamGame.Game = GameRegistry.Games.Values
.FirstOrDefault(g =>
g.SteamIDs.Contains(steamGame.AppId)