From 73191453c22336d4cbaa9dcd70c1a48236a80f58 Mon Sep 17 00:00:00 2001 From: Citrinate Date: Wed, 27 Nov 2024 12:18:27 -0500 Subject: [PATCH] Fix non-generic ASF crashes #27 --- BoosterManager/Boosters/BoosterDatabase.cs | 9 +++------ BoosterManager/Handlers/DataHandler.cs | 2 +- BoosterManager/Handlers/StatusReporter.cs | 5 +++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/BoosterManager/Boosters/BoosterDatabase.cs b/BoosterManager/Boosters/BoosterDatabase.cs index bf26344..801bc40 100644 --- a/BoosterManager/Boosters/BoosterDatabase.cs +++ b/BoosterManager/Boosters/BoosterDatabase.cs @@ -90,12 +90,9 @@ internal static BoosterDatabase CreateOrLoad(string filePath) { } internal void SetLastCraft(uint appID, DateTime craftTime) { - BoosterLastCraft newCraft = new BoosterLastCraft(craftTime); - BoosterLastCrafts.AddOrUpdate(appID, newCraft, (key, oldCraft) => { - oldCraft.CraftTime = craftTime; - - return oldCraft; - }); + if (!BoosterLastCrafts.TryAdd(appID, new BoosterLastCraft(craftTime))) { + BoosterLastCrafts[appID].CraftTime = craftTime; + } Utilities.InBackground(Save); } diff --git a/BoosterManager/Handlers/DataHandler.cs b/BoosterManager/Handlers/DataHandler.cs index effd96a..517cd7d 100644 --- a/BoosterManager/Handlers/DataHandler.cs +++ b/BoosterManager/Handlers/DataHandler.cs @@ -157,7 +157,7 @@ public static async Task SendMarketHistoryOnly(Bot bot, uint? numPages = } public static string StopSend(Bot bot) { - ForceStop.AddOrUpdate(bot.BotName, DateTime.Now, (_, _) => DateTime.Now); + ForceStop[bot.BotName] = DateTime.Now; return Commands.FormatBotResponse(bot, ArchiSteamFarm.Localization.Strings.Success); } diff --git a/BoosterManager/Handlers/StatusReporter.cs b/BoosterManager/Handlers/StatusReporter.cs index 9c6c87c..cfc9808 100644 --- a/BoosterManager/Handlers/StatusReporter.cs +++ b/BoosterManager/Handlers/StatusReporter.cs @@ -68,7 +68,8 @@ internal void Report(Bot reportingBot, string report, bool suppressDuplicateMess } } - Reports.AddOrUpdate(reportingBot, new List() { report }, (_, reports) => { reports.Add(report); return reports; }); + Reports.TryAdd(reportingBot, new List()); + Reports[reportingBot].Add(report); // I prefer to send all reports in as few messages as possible // As long as reports continue to come in, we wait (until some limit, to avoid possibly waiting forever) @@ -119,7 +120,7 @@ private async Task Send() { if (Reports.TryRemove(bot, out List? previousReports)) { if (previousReports != null) { - PreviousReports.AddOrUpdate(bot, previousReports, (_, _) => previousReports); + PreviousReports[bot] = previousReports; } } }