diff --git a/Wabbajack.CLI.Builder/Wabbajack.CLI.Builder.csproj b/Wabbajack.CLI.Builder/Wabbajack.CLI.Builder.csproj index beb8a0c9..87e50f36 100644 --- a/Wabbajack.CLI.Builder/Wabbajack.CLI.Builder.csproj +++ b/Wabbajack.CLI.Builder/Wabbajack.CLI.Builder.csproj @@ -8,7 +8,7 @@ - + diff --git a/Wabbajack.CLI/Wabbajack.CLI.csproj b/Wabbajack.CLI/Wabbajack.CLI.csproj index b03bef55..fe9ebfc9 100644 --- a/Wabbajack.CLI/Wabbajack.CLI.csproj +++ b/Wabbajack.CLI/Wabbajack.CLI.csproj @@ -18,7 +18,7 @@ - + diff --git a/Wabbajack.DTOs/Game/GameMetaData.cs b/Wabbajack.DTOs/Game/GameMetaData.cs index 36dc7c9f..1b4a4061 100644 --- a/Wabbajack.DTOs/Game/GameMetaData.cs +++ b/Wabbajack.DTOs/Game/GameMetaData.cs @@ -21,7 +21,7 @@ public class GameMetaData public int[] SteamIDs { get; internal init; } = Array.Empty(); // to get gog ids: https://www.gogdb.org - public int[] GOGIDs { get; internal init; } = Array.Empty(); + public long[] GOGIDs { get; internal init; } = Array.Empty(); // to get these ids, split the numbers from the letters in file names found in // C:\ProgramData\Origin\LocalContent\{game name)\*.mfst diff --git a/Wabbajack.DTOs/Game/GameRegistry.cs b/Wabbajack.DTOs/Game/GameRegistry.cs index b202eebe..4bf839a3 100644 --- a/Wabbajack.DTOs/Game/GameRegistry.cs +++ b/Wabbajack.DTOs/Game/GameRegistry.cs @@ -14,7 +14,7 @@ public static class GameRegistry { Game = Game.Morrowind, SteamIDs = new[] {22320}, - GOGIDs = new[] {1440163901, 1435828767}, + GOGIDs = new long[] {1440163901, 1435828767}, NexusName = "morrowind", NexusGameId = 100, MO2Name = "Morrowind", @@ -38,7 +38,7 @@ public static class GameRegistry MO2Name = "Oblivion", MO2ArchiveName = "oblivion", SteamIDs = new[] {22330}, - GOGIDs = new[] {1458058109}, + GOGIDs = new long[] {1458058109}, RequiredFiles = new[] { "oblivion.exe".ToRelativePath() @@ -56,7 +56,7 @@ public static class GameRegistry MO2Name = "Fallout 3", MO2ArchiveName = "fallout3", SteamIDs = new[] {22300, 22370}, // base game and GotY - GOGIDs = new[] {1454315831}, // GotY edition + GOGIDs = new long[] {1454315831}, // GotY edition RequiredFiles = new[] { "Fallout3.exe".ToRelativePath() @@ -73,7 +73,7 @@ public static class GameRegistry MO2Name = "New Vegas", MO2ArchiveName = "falloutnv", SteamIDs = new[] {22380, 22490}, // normal and RU version - GOGIDs = new[] {1454587428}, + GOGIDs = new long[] {1454587428}, RequiredFiles = new[] { "FalloutNV.exe".ToRelativePath() @@ -107,7 +107,7 @@ public static class GameRegistry MO2Name = "Skyrim Special Edition", MO2ArchiveName = "skyrimse", SteamIDs = new[] {489830}, - GOGIDs = new[] + GOGIDs = new long[] { 1711230643,// The Elder Scrolls V: Skyrim Special Edition AKA Base Game 1801825368,// The Elder Scrolls V: Skyrim Anniversary Edition AKA The Store Bundle @@ -130,7 +130,7 @@ public static class GameRegistry MO2Name = "Fallout 4", MO2ArchiveName = "fallout4", SteamIDs = new[] {377160}, - GOGIDs = new []{1998527297}, + GOGIDs = new long[]{1998527297}, RequiredFiles = new[] { "Fallout4.exe".ToRelativePath() @@ -183,7 +183,7 @@ public static class GameRegistry MO2Name = "Enderal Special Edition", MO2ArchiveName = "enderalse", SteamIDs = new[] {976620}, - GOGIDs = new [] {1708684988}, + GOGIDs = new long[] {1708684988}, RequiredFiles = new[] { "SkyrimSE.exe".ToRelativePath() @@ -217,7 +217,7 @@ public static class GameRegistry MO2Name = "Darkest Dungeon", NexusGameId = 804, SteamIDs = new[] {262060}, - GOGIDs = new[] {1450711444}, + GOGIDs = new long[] {1450711444}, EpicGameStoreIDs = new[] {"b4eecf70e3fe4e928b78df7855a3fc2d"}, IsGenericMO2Plugin = true, RequiredFiles = new[] @@ -236,7 +236,7 @@ public static class GameRegistry MO2ArchiveName = "dishonored", NexusGameId = 802, SteamIDs = new[] {205100}, - GOGIDs = new[] {1701063787}, + GOGIDs = new long[] {1701063787}, RequiredFiles = new[] { @"Binaries\Win32\Dishonored.exe".ToRelativePath() @@ -253,7 +253,7 @@ public static class GameRegistry MO2Name = "The Witcher: Enhanced Edition", MO2ArchiveName = "witcher", SteamIDs = new[] {20900}, // normal and GotY - GOGIDs = new[] {1207658924}, // normal, GotY and both in packages + GOGIDs = new long[] {1207658924}, // normal, GotY and both in packages RequiredFiles = new[] { @"System\witcher.exe".ToRelativePath() @@ -270,7 +270,7 @@ public static class GameRegistry MO2Name = "The Witcher 3: Wild Hunt", MO2ArchiveName = "witcher3", SteamIDs = new[] {292030, 499450}, // normal and GotY - GOGIDs = new[] + GOGIDs = new long[] {1207664643, 1495134320, 1207664663, 1640424747}, // normal, GotY and both in packages RequiredFiles = new[] { @@ -288,7 +288,7 @@ public static class GameRegistry MO2ArchiveName = "stardewvalley", NexusGameId = 1303, SteamIDs = new[] {413150}, - GOGIDs = new[] {1453375253}, + GOGIDs = new long[] {1453375253}, IsGenericMO2Plugin = true, RequiredFiles = new[] { @@ -306,7 +306,7 @@ public static class GameRegistry MO2ArchiveName = "kingdomcomedeliverance", NexusGameId = 2298, SteamIDs = new[] {379430}, - GOGIDs = new[] {1719198803}, + GOGIDs = new long[] {1719198803}, IsGenericMO2Plugin = true, RequiredFiles = new[] { @@ -340,7 +340,7 @@ public static class GameRegistry NexusGameId = 1634, MO2Name = "No Man's Sky", SteamIDs = new[] {275850}, - GOGIDs = new[] {1446213994}, + GOGIDs = new long[] {1446213994}, RequiredFiles = new[] { @"Binaries\NMS.exe".ToRelativePath() @@ -357,7 +357,7 @@ public static class GameRegistry MO2Name = "Dragon Age: Origins", SteamIDs = new[] {47810}, OriginIDs = new[] {"DR:169789300", "DR:208591800"}, - GOGIDs = new[] {1949616134}, + GOGIDs = new long[] {1949616134}, RequiredFiles = new[] { @"bin_ship\daorigins.exe".ToRelativePath() @@ -405,7 +405,7 @@ public static class GameRegistry MO2Name = "Kerbal Space Program", NexusGameId = 272, SteamIDs = new[] {220200}, - GOGIDs = new[] {1429864849}, + GOGIDs = new long[] {1429864849}, IsGenericMO2Plugin = true, RequiredFiles = new[] { @@ -433,7 +433,7 @@ public static class GameRegistry { Game = Game.Cyberpunk2077, SteamIDs = new[] {1091500}, - GOGIDs = new [] {2093619782, 1423049311}, + GOGIDs = new long[] {2093619782, 1423049311}, EpicGameStoreIDs = new[] {"5beededaad9743df90e8f07d92df153f"}, MO2Name = "Cyberpunk 2077", NexusName = "cyberpunk2077", @@ -467,7 +467,7 @@ public static class GameRegistry { Game = Game.DragonsDogma, SteamIDs = new[] {367500 }, - GOGIDs = new []{1242384383}, + GOGIDs = new long[]{1242384383}, MO2Name = "Dragon's Dogma: Dark Arisen", MO2ArchiveName = "dragonsdogma", NexusName = "dragonsdogma", @@ -521,7 +521,7 @@ public static class GameRegistry MO2Name = "Mount & Blade II: Bannerlord", MO2ArchiveName = "mountandblade2bannerlord", SteamIDs = new[] { 261550 }, - GOGIDs = new [] { + GOGIDs = new long[] { 1564781494, //Mount & Blade II: Bannerlord : Game 1681929523, //Mount & Blade II: Bannerlord - Digital Deluxe : Package 1802539526, //Mount & Blade II: Bannerlord : Package diff --git a/Wabbajack.Downloaders.Dispatcher.Test/Wabbajack.Downloaders.Dispatcher.Test.csproj b/Wabbajack.Downloaders.Dispatcher.Test/Wabbajack.Downloaders.Dispatcher.Test.csproj index 6dda5734..9070839d 100644 --- a/Wabbajack.Downloaders.Dispatcher.Test/Wabbajack.Downloaders.Dispatcher.Test.csproj +++ b/Wabbajack.Downloaders.Dispatcher.Test/Wabbajack.Downloaders.Dispatcher.Test.csproj @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/Wabbajack.Downloaders.GameFile/GameLocator.cs b/Wabbajack.Downloaders.GameFile/GameLocator.cs index 2cf9aef9..8c2a9d94 100644 --- a/Wabbajack.Downloaders.GameFile/GameLocator.cs +++ b/Wabbajack.Downloaders.GameFile/GameLocator.cs @@ -5,6 +5,8 @@ using GameFinder.StoreHandlers.EGS; using GameFinder.StoreHandlers.GOG; using GameFinder.StoreHandlers.Origin; using GameFinder.StoreHandlers.Steam; +using GameFinder.StoreHandlers.Steam.Models; +using GameFinder.StoreHandlers.Steam.Models.ValueTypes; using Microsoft.Extensions.Logging; using Wabbajack.DTOs; using Wabbajack.Paths; @@ -19,10 +21,10 @@ public class GameLocator : IGameLocator private readonly EGSHandler? _egs; private readonly OriginHandler? _origin; - private readonly Dictionary _steamGames = new(); - private readonly Dictionary _gogGames = new(); - private readonly Dictionary _egsGames = new(StringComparer.OrdinalIgnoreCase); - private readonly Dictionary _originGames = new(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _steamGames = new(); + private readonly Dictionary _gogGames = new(); + private readonly Dictionary _egsGames = new(); + private readonly Dictionary _originGames = new(); private readonly Dictionary _locationCache; private readonly ILogger _logger; @@ -30,19 +32,20 @@ public class GameLocator : IGameLocator public GameLocator(ILogger logger) { _logger = logger; + var fileSystem = NexusMods.Paths.FileSystem.Shared; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var windowsRegistry = new WindowsRegistry(); - _steam = new SteamHandler(windowsRegistry); - _gog = new GOGHandler(windowsRegistry); - _egs = new EGSHandler(windowsRegistry); - _origin = new OriginHandler(); + _steam = new SteamHandler(fileSystem, windowsRegistry); + _gog = new GOGHandler(windowsRegistry, fileSystem); + _egs = new EGSHandler(windowsRegistry, fileSystem); + _origin = new OriginHandler(fileSystem); } else { - _steam = new SteamHandler(null); + _steam = new SteamHandler(fileSystem, null); } _locationCache = new Dictionary(); @@ -54,7 +57,7 @@ public class GameLocator : IGameLocator { try { - FindStoreGames(_steam, _steamGames, game => game.Path); + FindStoreGames(_steam, _steamGames, game => (AbsolutePath)game.Path.GetFullPath()); } catch (Exception e) { @@ -63,7 +66,7 @@ public class GameLocator : IGameLocator try { - FindStoreGames(_gog, _gogGames, game => game.Path); + FindStoreGames(_gog, _gogGames, game => (AbsolutePath)game.Path.GetFullPath()); } catch (Exception e) { @@ -72,7 +75,7 @@ public class GameLocator : IGameLocator try { - FindStoreGames(_egs, _egsGames, game => game.InstallLocation); + FindStoreGames(_egs, _egsGames, game => (AbsolutePath)game.InstallLocation.GetFullPath()); } catch (Exception e) { @@ -81,7 +84,7 @@ public class GameLocator : IGameLocator try { - FindStoreGames(_origin, _originGames, game => game.InstallPath); + FindStoreGames(_origin, _originGames, game => (AbsolutePath)game.InstallPath.GetFullPath()); } catch (Exception e) { @@ -92,8 +95,9 @@ public class GameLocator : IGameLocator private void FindStoreGames( AHandler? handler, Dictionary paths, - Func getPath) - where TGame : class + Func getPath) + where TGame : class, IGame + where TId : notnull { if (handler is null) return; @@ -103,7 +107,7 @@ public class GameLocator : IGameLocator { try { - var path = getPath(game).ToAbsolutePath(); + var path = getPath(game); if (!path.DirectoryExists()) { _logger.LogError("Game does not exist: {Game}", game); @@ -160,28 +164,28 @@ public class GameLocator : IGameLocator foreach (var id in metaData.SteamIDs) { - if (!_steamGames.TryGetValue(id, out var found)) continue; + if (!_steamGames.TryGetValue(AppId.From((uint)id), out var found)) continue; path = found; return true; } foreach (var id in metaData.GOGIDs) { - if (!_gogGames.TryGetValue(id, out var found)) continue; + if (!_gogGames.TryGetValue(GOGGameId.From(id), out var found)) continue; path = found; return true; } foreach (var id in metaData.EpicGameStoreIDs) { - if (!_egsGames.TryGetValue(id, out var found)) continue; + if (!_egsGames.TryGetValue(EGSGameId.From(id), out var found)) continue; path = found; return true; } foreach (var id in metaData.OriginIDs) { - if (!_originGames.TryGetValue(id, out var found)) continue; + if (!_originGames.TryGetValue(OriginGameId.From(id), out var found)) continue; path = found; return true; } diff --git a/Wabbajack.Downloaders.GameFile/Wabbajack.Downloaders.GameFile.csproj b/Wabbajack.Downloaders.GameFile/Wabbajack.Downloaders.GameFile.csproj index 10e8ff11..598216a2 100644 --- a/Wabbajack.Downloaders.GameFile/Wabbajack.Downloaders.GameFile.csproj +++ b/Wabbajack.Downloaders.GameFile/Wabbajack.Downloaders.GameFile.csproj @@ -18,10 +18,10 @@ - - - - + + + + diff --git a/Wabbajack.Downloaders.MediaFire/Wabbajack.Downloaders.MediaFire.csproj b/Wabbajack.Downloaders.MediaFire/Wabbajack.Downloaders.MediaFire.csproj index 8c5ff86f..883ad2d0 100644 --- a/Wabbajack.Downloaders.MediaFire/Wabbajack.Downloaders.MediaFire.csproj +++ b/Wabbajack.Downloaders.MediaFire/Wabbajack.Downloaders.MediaFire.csproj @@ -7,7 +7,7 @@ - + diff --git a/Wabbajack.FileExtractor.Test/Wabbajack.FileExtractor.Test.csproj b/Wabbajack.FileExtractor.Test/Wabbajack.FileExtractor.Test.csproj index f6fa6609..40378dd9 100644 --- a/Wabbajack.FileExtractor.Test/Wabbajack.FileExtractor.Test.csproj +++ b/Wabbajack.FileExtractor.Test/Wabbajack.FileExtractor.Test.csproj @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/Wabbajack.Installer.Test/Wabbajack.Installer.Test.csproj b/Wabbajack.Installer.Test/Wabbajack.Installer.Test.csproj index b80d41bd..590be299 100644 --- a/Wabbajack.Installer.Test/Wabbajack.Installer.Test.csproj +++ b/Wabbajack.Installer.Test/Wabbajack.Installer.Test.csproj @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/Wabbajack.Networking.NexusApi/Wabbajack.Networking.NexusApi.csproj b/Wabbajack.Networking.NexusApi/Wabbajack.Networking.NexusApi.csproj index 56feb5f9..500ad9fa 100644 --- a/Wabbajack.Networking.NexusApi/Wabbajack.Networking.NexusApi.csproj +++ b/Wabbajack.Networking.NexusApi/Wabbajack.Networking.NexusApi.csproj @@ -12,7 +12,7 @@ - + diff --git a/Wabbajack.Networking.Steam.Test/Wabbajack.Networking.Steam.Test.csproj b/Wabbajack.Networking.Steam.Test/Wabbajack.Networking.Steam.Test.csproj index f403df79..c7e6d73b 100644 --- a/Wabbajack.Networking.Steam.Test/Wabbajack.Networking.Steam.Test.csproj +++ b/Wabbajack.Networking.Steam.Test/Wabbajack.Networking.Steam.Test.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/Wabbajack.Services.OSIntegrated/Wabbajack.Services.OSIntegrated.csproj b/Wabbajack.Services.OSIntegrated/Wabbajack.Services.OSIntegrated.csproj index e1ee4667..2223ea6d 100644 --- a/Wabbajack.Services.OSIntegrated/Wabbajack.Services.OSIntegrated.csproj +++ b/Wabbajack.Services.OSIntegrated/Wabbajack.Services.OSIntegrated.csproj @@ -17,7 +17,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Wabbajack.VFS.Test/Wabbajack.VFS.Test.csproj b/Wabbajack.VFS.Test/Wabbajack.VFS.Test.csproj index 367e4b81..29e3421c 100644 --- a/Wabbajack.VFS.Test/Wabbajack.VFS.Test.csproj +++ b/Wabbajack.VFS.Test/Wabbajack.VFS.Test.csproj @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - +