diff --git a/Wabbajack.Common/GameMetaData.cs b/Wabbajack.Common/GameMetaData.cs index b89f50ac..714d3cb1 100644 --- a/Wabbajack.Common/GameMetaData.cs +++ b/Wabbajack.Common/GameMetaData.cs @@ -1,5 +1,7 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; using System.Linq; using Alphaleonis.Win32.Filesystem; using Microsoft.Win32; @@ -68,6 +70,21 @@ namespace Wabbajack.Common // file to check if the game is present, useful when steamIds and gogIds dont help public List RequiredFiles { get; internal set; } public bool Disabled { get; internal set; } + + public string InstalledVersion + { + get + { + if (GameLocation() == null) + throw new GameNotInstalledException(this); + if (MainExecutable == null) + throw new NotImplementedException(); + + return FileVersionInfo.GetVersionInfo(Path.Combine(GameLocation(), MainExecutable)).ProductVersion; + } + } + + public string MainExecutable { get; internal set; } public string GameLocation() { @@ -79,6 +96,13 @@ namespace Wabbajack.Common } } + public class GameNotInstalledException : Exception + { + public GameNotInstalledException(GameMetaData gameMetaData) : base($"Game {gameMetaData.Game} does not appear to be installed.") + { + } + } + public class GameRegistry { public static GameMetaData GetByMO2ArchiveName(string gameName) @@ -125,7 +149,8 @@ namespace Wabbajack.Common RequiredFiles = new List { "oblivion.exe" - } + }, + MainExecutable = "Oblivion.exe" } }, @@ -143,7 +168,8 @@ namespace Wabbajack.Common { "falloutlauncher.exe", "data\\fallout3.esm" - } + }, + MainExecutable = "Fallout3.exe" } }, { @@ -159,7 +185,8 @@ namespace Wabbajack.Common RequiredFiles = new List { "FalloutNV.exe" - } + }, + MainExecutable = "FalloutNV.exe" } }, { @@ -175,7 +202,8 @@ namespace Wabbajack.Common RequiredFiles = new List { "tesv.exe" - } + }, + MainExecutable = "TESV.exe" } }, { @@ -191,7 +219,8 @@ namespace Wabbajack.Common RequiredFiles = new List { "SkyrimSE.exe" - } + }, + MainExecutable = "SkyrimSE.exe" } }, { @@ -207,7 +236,8 @@ namespace Wabbajack.Common RequiredFiles = new List { "Fallout4.exe" - } + }, + MainExecutable = "Fallout4.exe" } }, /*{ diff --git a/Wabbajack.Common/SteamHandler.cs b/Wabbajack.Common/SteamHandler.cs index 3dfbbec3..5e44f28e 100644 --- a/Wabbajack.Common/SteamHandler.cs +++ b/Wabbajack.Common/SteamHandler.cs @@ -132,8 +132,6 @@ namespace Wabbajack.Common return; if(l.Contains("\"name\"")) steamGame.Name = GetVdfValue(l); - if (l.Contains("\"buildid\"")) - steamGame.BuildId = GetVdfValue(l); if (l.Contains("\"installdir\"")) { var path = Path.Combine(p, "common", GetVdfValue(l)); diff --git a/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs b/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs index 680ae6bf..80c8eb63 100644 --- a/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs +++ b/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs @@ -37,6 +37,7 @@ namespace Wabbajack.Lib.Downloaders Game = GameRegistry.GetByMO2ArchiveName(gameName).Game, GameFile = gameFile, Hash = hash, + GameVersion = GameRegistry.GetByMO2ArchiveName(gameName).InstalledVersion }; } @@ -49,10 +50,12 @@ namespace Wabbajack.Lib.Downloaders public Game Game { get; set; } public string GameFile { get; set; } public string Hash { get; set; } + + public string GameVersion { get; set; } internal string SourcePath => Path.Combine(Game.MetaData().GameLocation(), GameFile); - public override object[] PrimaryKey { get => new object[] {Game, GameFile}; } + public override object[] PrimaryKey { get => new object[] {Game, GameVersion, GameFile}; } public override bool IsWhitelisted(ServerWhitelist whitelist) {