Read XCIs with patches. Code style

This commit is contained in:
Alex Barney 2018-09-06 17:34:38 -05:00
commit d5cce6b50c

View file

@ -136,6 +136,7 @@ namespace Ryujinx.HLE.HOS
if (Nca == null) if (Nca == null)
{ {
Device.Log.PrintError(LogClass.Loader, "Unable to load XCI"); Device.Log.PrintError(LogClass.Loader, "Unable to load XCI");
return; return;
} }
@ -150,6 +151,7 @@ namespace Ryujinx.HLE.HOS
} }
Nca MainNca = null; Nca MainNca = null;
Nca PatchNca = null;
foreach (PfsFileEntry FileEntry in Xci.SecurePartition.Files.Where(x => x.Name.EndsWith(".nca"))) foreach (PfsFileEntry FileEntry in Xci.SecurePartition.Files.Where(x => x.Name.EndsWith(".nca")))
{ {
@ -158,9 +160,16 @@ namespace Ryujinx.HLE.HOS
Nca Nca = new Nca(KeySet, NcaStream, true); Nca Nca = new Nca(KeySet, NcaStream, true);
if (Nca.Header.ContentType == ContentType.Program) if (Nca.Header.ContentType == ContentType.Program)
{
if (Nca.Sections.Any(x => x?.Type == SectionType.Romfs))
{ {
MainNca = Nca; MainNca = Nca;
} }
else if (Nca.Sections.Any(x => x?.Type == SectionType.Bktr))
{
PatchNca = Nca;
}
}
} }
if (MainNca == null) if (MainNca == null)
@ -168,6 +177,8 @@ namespace Ryujinx.HLE.HOS
Device.Log.PrintError(LogClass.Loader, "Could not find an Application NCA in the provided XCI file"); Device.Log.PrintError(LogClass.Loader, "Could not find an Application NCA in the provided XCI file");
} }
MainNca.SetBaseNca(PatchNca);
return MainNca; return MainNca;
} }
@ -204,6 +215,7 @@ namespace Ryujinx.HLE.HOS
if (Nca.Header.ContentType == ContentType.Program) if (Nca.Header.ContentType == ContentType.Program)
{ {
LoadNca(Nca); LoadNca(Nca);
return; return;
} }
} }
@ -219,12 +231,14 @@ namespace Ryujinx.HLE.HOS
if (ExefsSection == null) if (ExefsSection == null)
{ {
Device.Log.PrintError(LogClass.Loader, "No ExeFS found in NCA"); Device.Log.PrintError(LogClass.Loader, "No ExeFS found in NCA");
return; return;
} }
if (RomfsSection == null) if (RomfsSection == null)
{ {
Device.Log.PrintError(LogClass.Loader, "No RomFS found in NCA"); Device.Log.PrintError(LogClass.Loader, "No RomFS found in NCA");
return; return;
} }