Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Nov 26, 2024
2 parents 8a7179b + 8789ad0 commit a65ee9f
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 39 deletions.
4 changes: 1 addition & 3 deletions Mutagen.Bethesda.Core/Mutagen.Bethesda.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
<PackageReference Include="GameFinder.StoreHandlers.Steam" />
<PackageReference Include="GameFinder.StoreHandlers.Xbox" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'">
<DocumentationFile>obj\Release\net6.0\Mutagen.Bethesda.Core.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="Archives\Archive.cs" />
<Compile Include="Archives\Ba2\Ba2EntryType.cs" />
Expand Down Expand Up @@ -324,6 +321,7 @@
<Compile Include="Plugins\IO\PluginUtilityIO.cs" />
<Compile Include="Plugins\Masters\DI\FormIDTranslator.cs" />
<Compile Include="Plugins\Masters\DI\IKeyedMasterStyleReader.cs" />
<Compile Include="Plugins\Masters\DI\MasterFlagsLookupCompiler.cs" />
<Compile Include="Plugins\Masters\DI\MasterReferenceReaderFactory.cs">
<CodeLanguage>cs</CodeLanguage>
<DefaultPackFolder>content</DefaultPackFolder>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.IO.Abstractions;
using Mutagen.Bethesda.Environments.DI;
using Mutagen.Bethesda.Plugins.Binary.Headers;
using Mutagen.Bethesda.Plugins.Meta;
using Mutagen.Bethesda.Plugins.Records;

namespace Mutagen.Bethesda.Plugins.Masters.DI;

public class MasterFlagsLookupCompiler
{
private readonly IFileSystem _fileSystem;
private readonly IGameReleaseContext _gameReleaseContext;
private readonly IDataDirectoryProvider _dataDirectoryProvider;

public MasterFlagsLookupCompiler(
IFileSystem fileSystem,
IGameReleaseContext gameReleaseContext,
IDataDirectoryProvider dataDirectoryProvider)
{
_fileSystem = fileSystem;
_gameReleaseContext = gameReleaseContext;
_dataDirectoryProvider = dataDirectoryProvider;
}

public Noggog.Cache<IModMasterStyledGetter, ModKey>? ConstructFor(ModPath path)
{
Noggog.Cache<IModMasterStyledGetter, ModKey>? masterFlagsLookup = null;
if (GameConstants.Get(_gameReleaseContext.Release).SeparateMasterLoadOrders)
{
var dataDirectoryPath = _dataDirectoryProvider.Path;
var header = ModHeaderFrame.FromPath(path, _gameReleaseContext.Release, _fileSystem);
masterFlagsLookup = new Noggog.Cache<IModMasterStyledGetter, ModKey>(x => x.ModKey);
foreach (var master in header.Masters(path.ModKey).Select(x => x.Master))
{
var otherPath = Path.Combine(dataDirectoryPath, master.FileName);
var otherHeader = ModHeaderFrame.FromPath(otherPath, _gameReleaseContext.Release, _fileSystem);
masterFlagsLookup.Add(new KeyedMasterStyle(master, otherHeader.MasterStyle));
}
}
return masterFlagsLookup;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ void AddToListViaStyle(MasterStyle style, ModKey modKey)
}
}

foreach (var master in masters.Masters.Select(x => x. Master))
foreach (var master in masters.Masters.Select(x => x.Master))
{
if (masterFlagLookup == null)
{
throw new MissingModMappingException();
throw new MissingModMappingException("Master flag lookup was not provided.");
}
if (!masterFlagLookup.TryGetValue(master, out var mod))
{
Expand Down
2 changes: 1 addition & 1 deletion Mutagen.Bethesda.Fallout4/Records/Major Records/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public static int[] ParseRecordLocations(OverlayStream stream, BinaryOverlayFact
ret.Add(stream.Position - startingPos);
stream.Position += (int)cellMeta.TotalLength;
if (stream.Complete) break;
if (stream.TryGetGroupHeader(out var groupMeta)
while (stream.TryGetGroupHeader(out var groupMeta)
&& groupMeta.GroupType == (int)GroupTypeEnum.CellChildren)
{
stream.Position += (int)groupMeta.TotalLength;
Expand Down
6 changes: 3 additions & 3 deletions Mutagen.Bethesda.Oblivion/Records/Major Records/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ public static int[] ParseRecordLocations(OverlayStream stream, BinaryOverlayFact
ret.Add(stream.Position - startingPos);
stream.Position += (int)cellMeta.TotalLength;
if (stream.Complete) break;
if (!stream.TryGetGroupHeader(out var groupFrame)) continue;
if (groupFrame.GroupType == (int)GroupTypeEnum.CellChildren)
while (stream.TryGetGroupHeader(out var groupMeta)
&& groupMeta.GroupType == (int)GroupTypeEnum.CellChildren)
{
stream.Position += (int)groupFrame.TotalLength;
stream.Position += (int)groupMeta.TotalLength;
}
}
return ret.ToArray();
Expand Down
2 changes: 1 addition & 1 deletion Mutagen.Bethesda.Skyrim/Records/Major Records/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public static int[] ParseRecordLocations(OverlayStream stream, BinaryOverlayFact
ret.Add(stream.Position - startingPos);
stream.Position += (int)cellMeta.TotalLength;
if (stream.Complete) break;
if (stream.TryGetGroupHeader(out var groupMeta)
while (stream.TryGetGroupHeader(out var groupMeta)
&& groupMeta.GroupType == (int)GroupTypeEnum.CellChildren)
{
stream.Position += (int)groupMeta.TotalLength;
Expand Down
4 changes: 2 additions & 2 deletions Mutagen.Bethesda.Starfield/Records/Major Records/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ public static int[] ParseRecordLocations(OverlayStream stream, BinaryOverlayFact
ret.Add(stream.Position - startingPos);
stream.Position += (int)cellMeta.TotalLength;
if (stream.Complete) break;
if (stream.TryGetGroupHeader(out var groupMeta)
&& groupMeta.GroupType == (int)GroupTypeEnum.CellChildren)
while (stream.TryGetGroupHeader(out var groupMeta)
&& groupMeta.GroupType == (int)GroupTypeEnum.CellChildren)
{
stream.Position += (int)groupMeta.TotalLength;
}
Expand Down
8 changes: 0 additions & 8 deletions Mutagen.Bethesda.Tests.GUI/Mutagen.Bethesda.Tests.GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,4 @@
<ProjectReference Include="..\Mutagen.Bethesda.Tests\Mutagen.Bethesda.Tests.csproj" />
</ItemGroup>

<Target Name="SetVersion" BeforeTargets="GetAssemblyVersion;GetPackageVersion" Condition="'$(ExcludeRestorePackageImports)' != 'true'">
<PropertyGroup>
<AssemblyVersion>0.0.1.0</AssemblyVersion>
<FileVersion>0.0.1.0</FileVersion>
<PackageVersion>0.0.1.0</PackageVersion>
<InformationalVersion>0.0.1.0</InformationalVersion>
</PropertyGroup>
</Target>
</Project>
25 changes: 8 additions & 17 deletions Mutagen.Bethesda.Tests/Passthrough Tests/PassthroughTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,6 @@ public Test BinaryPassthroughTest()
var strsProcessedPath = Path.Combine(tmp.Dir.Path, "Strings/Processed");
var trimmedPath = TrimmedFileName(tmp.Dir.Path);

var masterRefs = MasterReferenceCollection.FromPath(new ModPath(ModKey, FilePath.Path), GameRelease);

// Do normal
if (Settings.TestNormal)
{
Expand Down Expand Up @@ -333,9 +331,7 @@ public Test BinaryPassthroughTest()
{
await BuildWriter(
mod.BeginWrite
.ToPath(outputPath)
.WithDefaultLoadOrder(),
masterRefs,
.ToPath(outputPath),
stringsWriter)
.WriteAsync();
GC.Collect();
Expand Down Expand Up @@ -375,9 +371,7 @@ await BuildWriter(
{
await BuildWriter(
mod.BeginWrite
.ToPath(outputPath)
.WithDefaultLoadOrder(),
masterRefs,
.ToPath(outputPath),
stringsWriter)
.WriteAsync();
}
Expand Down Expand Up @@ -440,9 +434,7 @@ await BuildWriter(
{
await BuildWriter(
wrapper.BeginWrite
.ToPath(binaryOverlayPath)
.WithDefaultLoadOrder(),
masterRefs,
.ToPath(binaryOverlayPath),
stringsWriter)
.WriteAsync();
}
Expand Down Expand Up @@ -495,9 +487,7 @@ await BuildWriter(
{
await BuildWriter(
copyIn.BeginWrite
.ToPath(copyInPath)
.WithDefaultLoadOrder(),
masterRefs,
.ToPath(copyInPath),
stringsWriter)
.WriteAsync();
}
Expand Down Expand Up @@ -595,18 +585,19 @@ public static PassthroughTest Factory(TestingSettings settings, TargetGroup grou
}

public IBinaryModdedWriteBuilder BuildWriter(
IBinaryModdedWriteBuilder builder,
IReadOnlyMasterReferenceCollection masterRefs,
IBinaryModdedWriteBuilderLoadOrderChoice builder,
StringsWriter stringsWriter)
{
return builder
.WithLoadOrderFromHeaderMasters()
.WithDefaultDataFolder()
.WithStringsWriter(stringsWriter)
.NoModKeySync()
.WithMastersListContent(MastersListContentOption.NoCheck)
.WithRecordCount(RecordCountOption.NoCheck)
.NoNextFormIDProcessing()
.NoFormIDUniquenessCheck()
.WithMastersListOrdering(masterRefs)
.NoFormIDCompactnessCheck()
.SingleThread();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@
<ProjectReference Include="..\Mutagen.Bethesda\Mutagen.Bethesda.csproj" />
</ItemGroup>

<Target Name="SetVersion" />

</Project>

0 comments on commit a65ee9f

Please sign in to comment.