Skip to content

Commit

Permalink
Ensure masters are sorted when saving patch.
Browse files Browse the repository at this point in the history
Having these out of order looks to have been the cause of the curious load-order-freeze bug with the Finding Helgi mod and Hroggar's NPC record. Actual chain of causality is anyone's guess, but sorting masters fixes that problem, and potentially some others that are undiscovered/unreported.
  • Loading branch information
focustense committed Aug 28, 2021
1 parent 6de37c8 commit 071b0bd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Focus.Apps.EasyNpc/Build/Pipeline/PatchSaveTask.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Mutagen.Bethesda.Skyrim;
using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Plugins.Binary.Parameters;
using Mutagen.Bethesda.Skyrim;
using System;
using System.IO.Abstractions;
using System.Linq;
using System.Threading.Tasks;

namespace Focus.Apps.EasyNpc.Build.Pipeline
Expand All @@ -23,14 +26,16 @@ public delegate PatchSaveTask Factory(
PatchInitializationTask.Result patch, NpcFacesTask.Result faces, DewiggifyRecordsTask.Result wigs);

private readonly IFileSystem fs;
private readonly IGameSettings gameSettings;
private readonly PatchInitializationTask.Result patch;

public PatchSaveTask(
IFileSystem fs, PatchInitializationTask.Result patch, NpcFacesTask.Result faces,
IFileSystem fs, IGameSettings gameSettings, PatchInitializationTask.Result patch, NpcFacesTask.Result faces,
DewiggifyRecordsTask.Result wigs)
{
RunsAfter(faces, wigs);
this.fs = fs;
this.gameSettings = gameSettings;
this.patch = patch;
}

Expand All @@ -57,8 +62,12 @@ private void BackupPreviousMerge(string mergeFilePath)

private void SaveMod(SkyrimMod mod, string outputPath)
{
var loadOrder = gameSettings.PluginLoadOrder.Select(x => ModKey.FromNameAndExtension(x));
using var stream = fs.File.Create(outputPath);
mod.WriteToBinaryParallel(stream);
mod.WriteToBinaryParallel(stream, new BinaryWriteParameters
{
MastersListOrdering = new MastersListOrderingByLoadOrder(loadOrder)
});
}
}
}

0 comments on commit 071b0bd

Please sign in to comment.