From 82555617b92f8f36fd9b9ff627eee7fa4fc09d56 Mon Sep 17 00:00:00 2001 From: Drommedhar Date: Sat, 2 Nov 2024 11:44:07 +0100 Subject: [PATCH] Fix doubled games & anti cheat detection --- DlssUpdater/Singletons/GameContainer.cs | 38 +++++++++++++++++++++++-- DlssUpdater/changelog.md | 2 ++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/DlssUpdater/Singletons/GameContainer.cs b/DlssUpdater/Singletons/GameContainer.cs index fda4da0..7fa0ddf 100644 --- a/DlssUpdater/Singletons/GameContainer.cs +++ b/DlssUpdater/Singletons/GameContainer.cs @@ -1,4 +1,5 @@ -using System.Collections.ObjectModel; +using System; +using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Text.Json; @@ -148,14 +149,45 @@ private async Task loadGamesAsync() .Select(g => g.First()) .ToList(); + // We need to check our local list against the library games and remove + // the ones that are no longer reported + List gamesToDelete = []; + foreach (var item in Games) + { + if (item.LibraryType == LibraryType.Manual) + { + continue; + } + + var game = totalGames.FirstOrDefault(g => g.UniqueId == item.UniqueId); + if(game is null) + { + gamesToDelete.Add(item); + } + } + foreach (var item in gamesToDelete) + { + Games.Remove(item); + } + var amount = totalGames.Count; var current = 0; foreach (var item in totalGames) { current++; InfoMessage?.Invoke(this, $"Parsing games {current}/{amount}"); + var index = -1; + if(item.LibraryType != LibraryType.Manual) + { + // For library games, we check against the id, not the path + index = Games.IndexOf(g => g.UniqueId == item.UniqueId); + } + else + { + index = Games.IndexOf(g => g.GamePath == item.GamePath); + } - var index = Games.IndexOf(g => g.GamePath == item.GamePath); + if (index != -1) { var id = Games[index].UniqueId; @@ -164,11 +196,13 @@ private async Task loadGamesAsync() Games[index].UniqueId = id; Games[index].IsHidden = isHidden; await Games[index].GatherInstalledVersions(); + Games[index].Update(); } else { var info = new GameInfo(item); await info.GatherInstalledVersions(); + info.Update(); Games.Add(info); } _watcher.AddFile(item); diff --git a/DlssUpdater/changelog.md b/DlssUpdater/changelog.md index adf5d9b..33aa2d2 100644 --- a/DlssUpdater/changelog.md +++ b/DlssUpdater/changelog.md @@ -1,6 +1,8 @@ # 2.0.5.0 * Executable is now properly signed * Splashscreen shows progress for each library +* Correctly remove games from library if they are no logner reported by launcher +* Detect anti cheat on startup again # 2.0.4.0 * Improve speed of game gather step