From 27ebdd8331267a8e3afd6573f8b3b5201a1fb191 Mon Sep 17 00:00:00 2001 From: Soul Shard <191157967+HvTcCore@users.noreply.github.com> Date: Fri, 14 Nov 2025 10:30:34 +0700 Subject: [PATCH] Fix EpicGames detect, possible fix stuck on Steam detect Fixed broken DLC detection for games from Epic Games. Probably fixed detection freezing on Steam games that are unavailable in certain regions. --- .github/workflows/autobuild.yml | 1 - .../Components/PlatformIdComparer.cs | 2 +- CreamInstaller/CreamInstaller.csproj | 2 +- CreamInstaller/Forms/SelectForm.cs | 13 ++++++---- CreamInstaller/Platforms/Epic/EpicLibrary.cs | 2 +- CreamInstaller/Platforms/Epic/EpicStore.cs | 24 ++++++++++++++++++- CreamInstaller/Utility/HttpClientManager.cs | 10 +++++++- 7 files changed, 44 insertions(+), 10 deletions(-) diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 4e7b9bb..174200b 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -2,7 +2,6 @@ name: Autobuild on: push: - branches: [ main ] tags: - '*' workflow_dispatch: diff --git a/CreamInstaller/Components/PlatformIdComparer.cs b/CreamInstaller/Components/PlatformIdComparer.cs index 8e3292c..2c87d13 100644 --- a/CreamInstaller/Components/PlatformIdComparer.cs +++ b/CreamInstaller/Components/PlatformIdComparer.cs @@ -22,7 +22,7 @@ internal sealed class StringComparer : IComparer { public int Compare(string a, string b) => !int.TryParse(a, out _) && !int.TryParse(b, out _) - ? string.Compare(a, b, StringComparison.CurrentCulture) + ? string.Compare(a, b, StringComparison.Ordinal) : !int.TryParse(a, out int A) ? 1 : !int.TryParse(b, out int B) diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 645a7e2..1c28dd9 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -4,7 +4,7 @@ net8.0-windows10.0.22621.0 True Resources\program.ico - 5.0.1.2 + 5.0.1.3 2021, pointfeev (https://github.com/pointfeev) CreamInstaller Automatic DLC Unlocker Installer & Configuration Generator diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 9ba24f5..481e850 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -109,7 +109,12 @@ internal sealed partial class SelectForm : CustomForm UpdateRemainingDLCs(); }); } - + private static async Task WithTimeout(Task task, int millisecondsTimeout) + { + if (await Task.WhenAny(task, Task.Delay(millisecondsTimeout)) == task) + return await task; + return default; + } private async Task GetApplicablePrograms(IProgress progress, bool uninstallAll = false) { if (!uninstallAll && (programsToScan is null || programsToScan.Count < 1)) @@ -199,7 +204,7 @@ internal sealed partial class SelectForm : CustomForm return; StoreAppData storeAppData = await SteamStore.QueryStoreAPI(appId); _ = Interlocked.Decrement(ref steamGamesToCheck); - CmdAppData cmdAppData = await SteamCMD.GetAppInfo(appId, branch, buildId); + CmdAppData cmdAppData = await WithTimeout(SteamCMD.GetAppInfo(appId, branch, buildId), 20000); if (storeAppData is null && cmdAppData is null) { RemoveFromRemainingGames(name); @@ -1099,7 +1104,7 @@ internal sealed partial class SelectForm : CustomForm private static bool CanLoadProxy() => ProgramData.ReadProxyChoices().Any(); - private bool CanLoadSelections() => CanLoadDlc() || CanLoadProxy(); + private static bool CanLoadSelections() => CanLoadDlc() || CanLoadProxy(); private void OnLoadSelections(object sender, EventArgs e) { @@ -1175,7 +1180,7 @@ internal sealed partial class SelectForm : CustomForm saveButton.Enabled = CanSaveSelections(); resetButton.Enabled = CanResetSelections(); proxyAllCheckBox.CheckedChanged -= OnProxyAllCheckBoxChanged; - proxyAllCheckBox.Checked = Selection.All.Keys.All(selection => selection.UseProxy); + proxyAllCheckBox.Checked = Selection.All.Keys.Count != 0 && Selection.All.Keys.All(selection => selection.UseProxy); proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged; } diff --git a/CreamInstaller/Platforms/Epic/EpicLibrary.cs b/CreamInstaller/Platforms/Epic/EpicLibrary.cs index f0f2ceb..539364c 100644 --- a/CreamInstaller/Platforms/Epic/EpicLibrary.cs +++ b/CreamInstaller/Platforms/Epic/EpicLibrary.cs @@ -20,7 +20,7 @@ internal static class EpicLibrary epicManifestsPath ??= Registry.GetValue(@"HKEY_CURRENT_USER\Software\Epic Games\EOS", "ModSdkMetadataDir", null) as string; epicManifestsPath ??= - Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Epic Games\EpicGamesLauncher", "AppDataPath", + Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Epic Games\EpicGamesLauncher", "AppDataPath", null) as string; if (epicManifestsPath is not null && epicManifestsPath.EndsWith(@"\Data", StringComparison.Ordinal)) epicManifestsPath += @"\Manifests"; diff --git a/CreamInstaller/Platforms/Epic/EpicStore.cs b/CreamInstaller/Platforms/Epic/EpicStore.cs index 763498f..4092277 100644 --- a/CreamInstaller/Platforms/Epic/EpicStore.cs +++ b/CreamInstaller/Platforms/Epic/EpicStore.cs @@ -8,6 +8,10 @@ using CreamInstaller.Platforms.Epic.GraphQL; using CreamInstaller.Utility; using Newtonsoft.Json; +#if DEBUG +using CreamInstaller.Forms; +#endif + namespace CreamInstaller.Platforms.Epic; internal static class EpicStore @@ -19,11 +23,22 @@ internal static class EpicStore { List<(string id, string name, string product, string icon, string developer)> dlcIds = []; string cacheFile = ProgramData.AppInfoPath + @$"\{categoryNamespace}.json"; + string fileContent = cacheFile.ReadFile(); + if (string.IsNullOrWhiteSpace(fileContent) || fileContent.Trim() == "null") + { + cacheFile.DeleteFile(); + } bool cachedExists = cacheFile.FileExists(); Response response = null; if (!cachedExists || ProgramData.CheckCooldown(categoryNamespace, Cooldown)) { response = await QueryGraphQL(categoryNamespace); +#if DEBUG + if (response is null) + { + DebugForm.Current.Log("ES: QueryGraphQL returned null"); + } +#endif try { cacheFile.WriteFile(JsonConvert.SerializeObject(response, Formatting.Indented)); @@ -114,6 +129,8 @@ internal static class EpicStore dlcIds.Add((id, title, product, icon, developer)); } + public static bool EpicBool = true; + private static async Task QueryGraphQL(string categoryNamespace) { try @@ -125,9 +142,14 @@ internal static class EpicStore content.Headers.ContentType = new("application/json"); HttpClient client = HttpClientManager.HttpClient; if (client is null) + { +#if DEBUG + DebugForm.Current.Log("ES: Client returned null"); +#endif return null; + } HttpResponseMessage httpResponse = - await client.PostAsync(new Uri("https://graphql.epicgames.com/graphql"), content); + await client.PostAsync(new Uri("https://launcher.store.epicgames.com/graphql"), content); _ = httpResponse.EnsureSuccessStatusCode(); string response = await httpResponse.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject(response); diff --git a/CreamInstaller/Utility/HttpClientManager.cs b/CreamInstaller/Utility/HttpClientManager.cs index 32aec57..ffca425 100644 --- a/CreamInstaller/Utility/HttpClientManager.cs +++ b/CreamInstaller/Utility/HttpClientManager.cs @@ -20,7 +20,15 @@ internal static class HttpClientManager internal static void Setup() { HttpClient = new(); - HttpClient.DefaultRequestHeaders.UserAgent.Add(new(Program.Name, Program.Version)); + if (CreamInstaller.Platforms.Epic.EpicStore.EpicBool) + { + HttpClient.DefaultRequestHeaders.UserAgent.Add(new("EpicGamesLauncher", "18.9.0-45233261+++Portal+Release-Live")); + CreamInstaller.Platforms.Epic.EpicStore.EpicBool = false; + } + else + { + HttpClient.DefaultRequestHeaders.UserAgent.Add(new(Program.Name, Program.Version)); + } HttpClient.DefaultRequestHeaders.AcceptLanguage.Add(new(CultureInfo.CurrentCulture.ToString())); }