mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-21 12:45:47 +00:00
chore: Overall code cleanup
Update NuGet packages, fix version string in plist for macOS
This commit is contained in:
@@ -36,7 +36,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
|
||||
public static ProcessResult Load(this IFileSystem exeFs, Switch device, BlitStruct<ApplicationControlProperty> nacpData, MetaLoader metaLoader, byte programIndex, bool isHomebrew = false)
|
||||
{
|
||||
ulong programId = metaLoader.GetProgramId();
|
||||
ulong programId = metaLoader.ProgramId;
|
||||
|
||||
// Replace the whole ExeFs partition by the modded one.
|
||||
if (device.Configuration.VirtualFileSystem.ModLoader.ReplaceExefsPartition(programId, ref exeFs))
|
||||
@@ -118,13 +118,13 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
modLoadResult.Hash,
|
||||
true,
|
||||
programName,
|
||||
metaLoader.GetProgramId(),
|
||||
programId,
|
||||
programIndex,
|
||||
null,
|
||||
nsoExecutables);
|
||||
|
||||
// TODO: This should be stored using ProcessId instead.
|
||||
device.System.LibHacHorizonManager.ArpIReader.ApplicationId = new LibHac.ApplicationId(metaLoader.GetProgramId());
|
||||
device.System.LibHacHorizonManager.ArpIReader.ApplicationId = new LibHac.ApplicationId(programId);
|
||||
|
||||
return processResult;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
{
|
||||
MetaLoader metaLoader = exeFs.GetNpdm();
|
||||
BlitStruct<ApplicationControlProperty> nacpData = new(1);
|
||||
ulong programId = metaLoader.GetProgramId();
|
||||
ulong programId = metaLoader.ProgramId;
|
||||
|
||||
device.Configuration.VirtualFileSystem.ModLoader.CollectMods([programId]);
|
||||
|
||||
|
||||
@@ -1,61 +1,15 @@
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.Loader;
|
||||
using LibHac.Util;
|
||||
using Ryujinx.Common;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
{
|
||||
public static class MetaLoaderExtensions
|
||||
{
|
||||
public static ulong GetProgramId(this MetaLoader metaLoader)
|
||||
{
|
||||
metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure();
|
||||
|
||||
return npdm.Aci.ProgramId.Value;
|
||||
}
|
||||
|
||||
public static string GetProgramName(this MetaLoader metaLoader)
|
||||
{
|
||||
metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure();
|
||||
|
||||
return StringUtils.Utf8ZToString(npdm.Meta.ProgramName);
|
||||
}
|
||||
|
||||
public static bool IsProgram64Bit(this MetaLoader metaLoader)
|
||||
{
|
||||
metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure();
|
||||
|
||||
return (npdm.Meta.Flags & 1) != 0;
|
||||
}
|
||||
|
||||
public static void LoadDefault(this MetaLoader metaLoader)
|
||||
{
|
||||
byte[] npdmBuffer = EmbeddedResources.Read("Ryujinx.HLE/Homebrew.npdm");
|
||||
|
||||
metaLoader.Load(npdmBuffer).ThrowIfFailure();
|
||||
}
|
||||
|
||||
public static void LoadFromFile(this MetaLoader metaLoader, IFileSystem fileSystem, string path = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = ProcessConst.MainNpdmPath;
|
||||
}
|
||||
|
||||
using UniqueRef<IFile> npdmFile = new();
|
||||
|
||||
fileSystem.OpenFile(ref npdmFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
npdmFile.Get.GetSize(out long fileSize).ThrowIfFailure();
|
||||
|
||||
Span<byte> npdmBuffer = new byte[fileSize];
|
||||
|
||||
npdmFile.Get.Read(out _, 0, npdmBuffer).ThrowIfFailure();
|
||||
|
||||
metaLoader.Load(npdmBuffer).ThrowIfFailure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
|
||||
// Collecting mods related to AocTitleIds and ProgramId.
|
||||
device.Configuration.VirtualFileSystem.ModLoader.CollectMods(
|
||||
device.Configuration.ContentManager.GetAocTitleIds().Prepend(metaLoader.GetProgramId()),
|
||||
device.Configuration.ContentManager.GetAocTitleIds().Prepend(metaLoader.ProgramId),
|
||||
ModLoader.GetModsBasePath(),
|
||||
ModLoader.GetSdModsBasePath());
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
|
||||
*/
|
||||
|
||||
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader, (byte)nca.GetProgramIndex());
|
||||
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader, (byte)nca.ProgramIndex);
|
||||
|
||||
// Load RomFS.
|
||||
if (romFs == null)
|
||||
@@ -99,38 +99,6 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
return processResult;
|
||||
}
|
||||
|
||||
public static ulong GetProgramIdBase(this Nca nca)
|
||||
{
|
||||
return nca.Header.TitleId & ~0x1FFFUL;
|
||||
}
|
||||
|
||||
public static int GetProgramIndex(this Nca nca)
|
||||
{
|
||||
return (int)(nca.Header.TitleId & 0xF);
|
||||
}
|
||||
|
||||
public static bool IsProgram(this Nca nca)
|
||||
{
|
||||
return nca.Header.ContentType == NcaContentType.Program;
|
||||
}
|
||||
|
||||
public static bool IsMain(this Nca nca)
|
||||
{
|
||||
return nca.IsProgram() && !nca.IsPatch();
|
||||
}
|
||||
|
||||
public static bool IsPatch(this Nca nca)
|
||||
{
|
||||
int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program);
|
||||
|
||||
return nca.IsProgram() && nca.SectionExists(NcaSectionType.Data) && nca.Header.GetFsHeader(dataIndex).IsPatchSection();
|
||||
}
|
||||
|
||||
public static bool IsControl(this Nca nca)
|
||||
{
|
||||
return nca.Header.ContentType == NcaContentType.Control;
|
||||
}
|
||||
|
||||
public static (Nca, Nca) GetUpdateData(this Nca mainNca, VirtualFileSystem fileSystem, IntegrityCheckLevel checkLevel, int programIndex, out string updatePath)
|
||||
{
|
||||
updatePath = null;
|
||||
@@ -140,7 +108,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
Nca updateControlNca = null;
|
||||
|
||||
// Clear the program index part.
|
||||
ulong titleIdBase = mainNca.GetProgramIdBase();
|
||||
ulong titleIdBase = mainNca.ProgramIdBase;
|
||||
|
||||
// Load update information if exists.
|
||||
string titleUpdateMetadataPath = Path.Combine(AppDataManager.GamesDirPath, titleIdBase.ToString("x16"), "updates.json");
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
device.Configuration.ContentManager.ClearAocData();
|
||||
|
||||
// Load DownloadableContents.
|
||||
string addOnContentMetadataPath = System.IO.Path.Combine(AppDataManager.GamesDirPath, mainNca.GetProgramIdBase().ToString("x16"), "dlc.json");
|
||||
string addOnContentMetadataPath = System.IO.Path.Combine(AppDataManager.GamesDirPath, mainNca.ProgramIdBase.ToString("x16"), "dlc.json");
|
||||
if (File.Exists(addOnContentMetadataPath))
|
||||
{
|
||||
List<DownloadableContentContainer> dlcContainerList = JsonHelper.DeserializeFromFile(addOnContentMetadataPath, _contentSerializerContext.ListDownloadableContentContainer);
|
||||
@@ -149,14 +149,5 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
|
||||
return (false, ProcessResult.Failed);
|
||||
}
|
||||
|
||||
public static Nca GetNca(this IFileSystem fileSystem, KeySet keySet, string path)
|
||||
{
|
||||
using UniqueRef<IFile> ncaFile = new();
|
||||
|
||||
fileSystem.OpenFile(ref ncaFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
return new Nca(keySet, ncaFile.Release().AsStorage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.HLE.Loaders.Executables;
|
||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Arp;
|
||||
using System;
|
||||
@@ -44,12 +43,12 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
{
|
||||
Nca nca = partitionFileSystem.GetNca(device.FileSystem.KeySet, fileEntry.FullPath);
|
||||
|
||||
if (!nca.IsProgram())
|
||||
if (!nca.IsProgram)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ulong currentMainProgramId = nca.GetProgramIdBase();
|
||||
ulong currentMainProgramId = nca.ProgramIdBase;
|
||||
|
||||
if (applicationId == 0 && currentMainProgramId != 0)
|
||||
{
|
||||
@@ -66,7 +65,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
break;
|
||||
}
|
||||
|
||||
hasIndex[nca.GetProgramIndex()] = true;
|
||||
hasIndex[nca.ProgramIndex] = true;
|
||||
}
|
||||
|
||||
if (programCount == 0)
|
||||
@@ -365,7 +364,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
|
||||
string displayVersion;
|
||||
|
||||
if (metaLoader.GetProgramId() > 0x0100000000007FFF)
|
||||
if (metaLoader.ProgramId > 0x0100000000007FFF)
|
||||
{
|
||||
displayVersion = applicationControlProperties.Value.DisplayVersionString.ToString();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
|
||||
if (metaLoader is not null)
|
||||
{
|
||||
ulong programId = metaLoader.GetProgramId();
|
||||
ulong programId = metaLoader.ProgramId;
|
||||
|
||||
Name = ApplicationControlProperties.Title[(int)titleLanguage].NameString.ToString();
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
DisplayVersion = ApplicationControlProperties.DisplayVersionString.ToString();
|
||||
ProgramId = programId;
|
||||
ProgramIdText = $"{programId:x16}";
|
||||
Is64Bit = metaLoader.IsProgram64Bit();
|
||||
Is64Bit = metaLoader.IsProgram64Bit;
|
||||
}
|
||||
|
||||
DiskCacheEnabled = diskCacheEnabled;
|
||||
|
||||
Reference in New Issue
Block a user