/// <summary> /// Applied after Update runs. /// </summary> internal static void Postfix() { if (ModUpdateDetails.ScrubConfig()) { UpdateMainMenu(); } }
/// <summary> /// Replace the Update function of SteamUGCService with this version that actually /// waits for the return and uses the same API as Mod Updater's regular mode. /// </summary> public void Process() { var toQuery = ListPool <PublishedFileId_t, SteamUGCServiceFixed> .Allocate(); var toRemove = ListPool <PublishedFileId_t, SteamUGCServiceFixed> .Allocate(); var toAdd = HashSetPool <PublishedFileId_t, SteamUGCServiceFixed> .Allocate(); var toUpdate = HashSetPool <PublishedFileId_t, SteamUGCServiceFixed> .Allocate(); var loadPreviews = ListPool <SteamUGCService.Mod, SteamUGCServiceFixed> .Allocate(); int n = clients.Count; // Mass request the details of all mods at once foreach (var pair in allMods) { var mod = pair.Value; var id = pair.Key; switch (mod.state) { case SteamModState.NeedsDetails: toQuery.Add(id); break; case SteamModState.PendingDestroy: toRemove.Add(id); break; case SteamModState.DetailsDirty: // Details were downloaded, send out a quick update of all the mod names // in mass at the beginning even if some downloads are pending if (mod.clientSeen) { toUpdate.Add(id); } else { toAdd.Add(id); } mod.state = SteamModState.Subscribed; break; default: break; } if (mod.previewDirty) { loadPreviews.Add(mod.ugcMod); mod.previewDirty = false; } } if (toQuery.Count > 0 && onQueryComplete == null) { QueryUGCDetails(toQuery.ToArray()); } toQuery.Recycle(); bool idle = download.Idle; if (idle) { // Avoid spamming by only notifying when all outstanding mods are downloaded foreach (var pair in allMods) { var mod = pair.Value; var id = pair.Key; if (mod.state == SteamModState.Updated) { mod.Summon(); if (mod.clientSeen) { toUpdate.Add(id); } else { toAdd.Add(id); } mod.state = SteamModState.Subscribed; } } } if (toAdd.Count > 0 || toUpdate.Count > 0 || toRemove.Count > 0 || loadPreviews. Count > 0) { firstEvent = true; // Event needs to be triggered for (int i = 0; i < n; i++) { clients[i].UpdateMods(toAdd, toUpdate, toRemove, loadPreviews); } if (n > 0) { foreach (var added in toAdd) { // Mods that were successfully added will be updated in the future if (allMods.TryGetValue(added, out ModInfo info)) { info.clientSeen = true; } } } } // Actually destroy all pending destroy mods foreach (var id in toRemove) { if (allMods.TryRemove(id, out ModInfo destroyed)) { destroyed.Dispose(); } } loadPreviews.Recycle(); toAdd.Recycle(); toUpdate.Recycle(); toRemove.Recycle(); if (wasIdle != idle || ModUpdateDetails.ScrubConfig()) { // Runs on foreground thread wasIdle = idle; ModUpdateDatePatches.UpdateMainMenu(); } }