Skip to content

Commit

Permalink
Change ACF File to just be deleted and left for regeneration each launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Solxanich committed Aug 20, 2023
1 parent 35ac128 commit 9b007c2
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions patches/tModLoader/Terraria/Social/Steam/SteamedWraps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,18 +340,22 @@ public static void BeginPlaytimeTracking()

internal static void OnGameExitCleanup()
{
if (!SteamAvailable) {
CleanupACF();
return;
}
// PATH/Steamapps/workshop
string workshopFolder = WorkshopHelper.GetWorkshopFolder(ModLoader.Engine.Steam.TMLAppID_t);
// Steamapps/workshop/appworkshop_1281930.acf
string targetACF = Path.Combine(workshopFolder, $"appworkshop_{ModLoader.Engine.Steam.TMLAppID}.acf");

if (SteamClient) {
if (SteamClient)
SteamAPI.Shutdown();
else if (SteamAvailable)
GameServer.Shutdown();

if (!File.Exists(targetACF)) {
Logging.tML.Error($"Unable to locate tmodloader steam acf. Expected path: {targetACF}");
return;
}

GameServer.Shutdown();
CleanupACF();
File.Delete(targetACF);
}

public static uint GetWorkshopItemState(PublishedFileId_t publishId)
Expand Down Expand Up @@ -396,18 +400,6 @@ public static void UninstallWorkshopItem(PublishedFileId_t publishId, string ins

// Remove the files
Directory.Delete(installPath, true);

if (!SteamClient)
// Steam Game Server has to be terminated before the ACF file is modified, so we defer cleanup to end of game likse steam client.
deletedItems.Add(publishId);
}

private static List<PublishedFileId_t> deletedItems = new List<PublishedFileId_t>();

private static void CleanupACF()
{
foreach (var item in deletedItems)
UninstallACF(item);
}

private static void UninstallACF(PublishedFileId_t publishId)
Expand Down

0 comments on commit 9b007c2

Please sign in to comment.