diff --git a/Directory.Packages.props b/Directory.Packages.props index 837e6d268d..1b739af89c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -136,7 +136,7 @@ - + diff --git a/src/NexusMods.Games.FileHashes/FileHashesService.cs b/src/NexusMods.Games.FileHashes/FileHashesService.cs index 60969e835e..be411294b4 100644 --- a/src/NexusMods.Games.FileHashes/FileHashesService.cs +++ b/src/NexusMods.Games.FileHashes/FileHashesService.cs @@ -300,7 +300,10 @@ private bool TryGetGameVersionDefinition(GameInstallation installation, IEnumera foreach (var gogId in locatorMetadata) { if (!ulong.TryParse(gogId, out var parsedId)) - throw new InvalidOperationException("GOG locator metadata is not a valid ulong"); + { + _logger.LogWarning("Unable to parse `{Raw}` as ulong", gogId); + return false; + } var gogBuild = GogBuild.FindByBuildId(Current, BuildId.From(parsedId)) .FirstOrDefault(); diff --git a/src/NexusMods.StandardGameLocators/HeroicGogLocator.cs b/src/NexusMods.StandardGameLocators/HeroicGogLocator.cs index a431f82be0..05039d3b1a 100644 --- a/src/NexusMods.StandardGameLocators/HeroicGogLocator.cs +++ b/src/NexusMods.StandardGameLocators/HeroicGogLocator.cs @@ -1,3 +1,4 @@ +using System.Runtime.InteropServices; using GameFinder.Launcher.Heroic; using GameFinder.StoreHandlers.GOG; using Microsoft.Extensions.DependencyInjection; @@ -45,13 +46,25 @@ public IEnumerable Find(ILocatableGame game) { if (!_cachedGames.TryGetValue(GOGGameId.From(id), out var found)) continue; var fs = found.Path.FileSystem; + var gamePath = found.Path; - if (found is HeroicGOGGame heroicGOGGame && heroicGOGGame.WinePrefixPath.DirectoryExists()) + if (found is HeroicGOGGame heroicGOGGame) { - fs = heroicGOGGame.GetWinePrefix().CreateOverlayFileSystem(fs); + var wineData = heroicGOGGame.WineData; + if (wineData is not null) + { + if (wineData.WinePrefixPath.DirectoryExists()) + fs = heroicGOGGame.GetWinePrefix()!.CreateOverlayFileSystem(fs); + } + + // NOTE(erri120): GOG builds for Linux are whack, the installer Heroic uses is whack, + // and this is a complete hack. See comments on https://github.com/Nexus-Mods/NexusMods.App/pull/2653 + // for details. + if (heroicGOGGame.Platform == OSPlatform.Linux) + gamePath = gamePath.Combine("game"); } - yield return new GameLocatorResult(found.Path, fs, GameStore.GOG, new HeroicGOGLocatorResultMetadata + yield return new GameLocatorResult(gamePath, fs, GameStore.GOG, new HeroicGOGLocatorResultMetadata { Id = id, BuildId = found.BuildId, diff --git a/src/NexusMods.StandardGameLocators/Services.cs b/src/NexusMods.StandardGameLocators/Services.cs index 9ce1adb2f9..9b5c5d206f 100644 --- a/src/NexusMods.StandardGameLocators/Services.cs +++ b/src/NexusMods.StandardGameLocators/Services.cs @@ -14,6 +14,7 @@ using GameFinder.Wine; using GameFinder.Wine.Bottles; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using NexusMods.Abstractions.GameLocators; using NexusMods.Abstractions.GameLocators.Stores.EGS; using NexusMods.Abstractions.GameLocators.Stores.GOG; @@ -103,7 +104,7 @@ public static IServiceCollection AddStandardGameLocators( onLinux: () => { services.AddSingleton>(provider => new SteamHandler(provider.GetRequiredService(), registry: null)); - services.AddSingleton(provider => new HeroicGOGHandler(provider.GetRequiredService())); + services.AddSingleton(provider => new HeroicGOGHandler(provider.GetRequiredService(), provider.GetRequiredService>())); if (registerWine) { diff --git a/tests/NexusMods.StandardGameLocators.TestHelpers/Services.cs b/tests/NexusMods.StandardGameLocators.TestHelpers/Services.cs index b951214678..fc8ef194d1 100644 --- a/tests/NexusMods.StandardGameLocators.TestHelpers/Services.cs +++ b/tests/NexusMods.StandardGameLocators.TestHelpers/Services.cs @@ -11,6 +11,7 @@ using GameFinder.Wine; using GameFinder.Wine.Bottles; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using NexusMods.Abstractions.Games; using NexusMods.Abstractions.Loadouts; using NexusMods.Extensions.DependencyInjection; @@ -158,7 +159,7 @@ public static IServiceCollection AddStubbedGameLocators(this IServiceCollection if (OSInformation.Shared.IsLinux) { - coll.AddSingleton(s => new HeroicGOGHandler(s.GetRequiredService())); + coll.AddSingleton(s => new HeroicGOGHandler(s.GetRequiredService(), s.GetRequiredService>())); coll.AddSingleton>(s => new StubbedWinePrefixManager(s.GetRequiredService(),