Fix some DLCs crashing due to stream loader change

This commit is contained in:
KeatonTheBot 2025-08-27 15:01:30 -05:00
parent 8ea79ae5d5
commit a62deb8cfd
2 changed files with 8 additions and 6 deletions

View file

@ -42,12 +42,14 @@ namespace Ryujinx.HLE.FileSystem
private readonly struct AocItem private readonly struct AocItem
{ {
public readonly string ContainerPath;
public readonly Stream ContainerStream; public readonly Stream ContainerStream;
public readonly string NcaPath; public readonly string NcaPath;
public readonly string Extension; public readonly string Extension;
public AocItem(Stream containerStream, string ncaPath, string extension) public AocItem(string containerPath, Stream containerStream, string ncaPath, string extension)
{ {
ContainerPath = containerPath;
ContainerStream = containerStream; ContainerStream = containerStream;
Extension = extension; Extension = extension;
NcaPath = ncaPath; NcaPath = ncaPath;
@ -189,10 +191,10 @@ namespace Ryujinx.HLE.FileSystem
} }
} }
public void AddAocItem(ulong titleId, Stream containerStream, string ncaPath, string extension, bool mergedToContainer = false) public void AddAocItem(ulong titleId, string containerPath, Stream containerStream, string ncaPath, string extension, bool mergedToContainer = false)
{ {
// TODO: Check Aoc version. // TODO: Check Aoc version.
if (!AocData.TryAdd(titleId, new AocItem(containerStream, ncaPath, extension))) if (!AocData.TryAdd(titleId, new AocItem(containerPath, containerStream, ncaPath, extension)))
{ {
Logger.Warning?.Print(LogClass.Application, $"Duplicate AddOnContent detected. TitleId {titleId:X16}"); Logger.Warning?.Print(LogClass.Application, $"Duplicate AddOnContent detected. TitleId {titleId:X16}");
} }
@ -227,6 +229,7 @@ namespace Ryujinx.HLE.FileSystem
if (AocData.TryGetValue(aocTitleId, out AocItem aoc)) if (AocData.TryGetValue(aocTitleId, out AocItem aoc))
{ {
var file = new FileStream(aoc.ContainerPath, FileMode.Open, FileAccess.Read);
using var ncaFile = new UniqueRef<IFile>(); using var ncaFile = new UniqueRef<IFile>();
switch (aoc.Extension) switch (aoc.Extension)
@ -237,7 +240,7 @@ namespace Ryujinx.HLE.FileSystem
break; break;
case ".nsp": case ".nsp":
var pfs = new PartitionFileSystem(); var pfs = new PartitionFileSystem();
pfs.Initialize(aoc.ContainerStream.AsStorage()); pfs.Initialize(file.AsStorage());
pfs.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); pfs.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
break; break;
default: default:
@ -709,7 +712,6 @@ namespace Ryujinx.HLE.FileSystem
FileInfo info = new(firmwarePackage); FileInfo info = new(firmwarePackage);
if (info.Extension == ".zip" || info.Extension == ".xci") if (info.Extension == ".zip" || info.Extension == ".xci")
{ {
using FileStream file = File.OpenRead(firmwarePackage); using FileStream file = File.OpenRead(firmwarePackage);

View file

@ -131,7 +131,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
{ {
if (downloadableContentNca.Enabled) if (downloadableContentNca.Enabled)
{ {
device.Configuration.ContentManager.AddAocItem(downloadableContentNca.TitleId, stream, downloadableContentNca.FullPath, System.IO.Path.GetExtension(downloadableContentContainer.ContainerPath)); device.Configuration.ContentManager.AddAocItem(downloadableContentNca.TitleId, downloadableContentContainer.ContainerPath, stream, downloadableContentNca.FullPath, System.IO.Path.GetExtension(downloadableContentContainer.ContainerPath));
} }
} }
else else