Use a dummy NACP in EnsureSaveData if one is not loaded

This commit is contained in:
Alex Barney 2019-12-24 17:33:47 -07:00
commit 3e786baf61
2 changed files with 32 additions and 1 deletions

View file

@ -355,6 +355,10 @@ namespace Ryujinx.HLE.HOS
{ {
ReadControlData(controlNca); ReadControlData(controlNca);
} }
else
{
ControlData.ByteSpan.Clear();
}
return (mainNca, patchNca, controlNca); return (mainNca, patchNca, controlNca);
} }
@ -381,6 +385,10 @@ namespace Ryujinx.HLE.HOS
} }
} }
} }
else
{
ControlData.ByteSpan.Clear();
}
} }
public void LoadNca(string ncaFile) public void LoadNca(string ncaFile)
@ -511,6 +519,10 @@ namespace Ryujinx.HLE.HOS
{ {
ReadControlData(controlNca); ReadControlData(controlNca);
} }
else
{
ControlData.ByteSpan.Clear();
}
} }
private void LoadExeFs(IFileSystem codeFs, out Npdm metaData) private void LoadExeFs(IFileSystem codeFs, out Npdm metaData)

View file

@ -1,6 +1,8 @@
using LibHac; using LibHac;
using LibHac.Account; using LibHac.Account;
using LibHac.Common;
using LibHac.Ncm; using LibHac.Ncm;
using LibHac.Ns;
using Ryujinx.Common; using Ryujinx.Common;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Ipc;
@ -8,7 +10,6 @@ using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage; using Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage;
using Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService; using Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService;
using Ryujinx.HLE.Utilities;
using System; using System;
using static LibHac.Fs.ApplicationSaveDataManagement; using static LibHac.Fs.ApplicationSaveDataManagement;
@ -41,6 +42,24 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
Uid userId = context.RequestData.ReadStruct<Uid>(); Uid userId = context.RequestData.ReadStruct<Uid>();
TitleId titleId = new TitleId(context.Process.TitleId); TitleId titleId = new TitleId(context.Process.TitleId);
BlitStruct<ApplicationControlProperty> controlHolder = context.Device.System.ControlData;
ref ApplicationControlProperty control = ref controlHolder.Value;
if (Util.IsEmpty(controlHolder.ByteSpan))
{
// If the current application doesn't have a loaded control property, create a dummy one
// and set the savedata sizes so a user savedata will be created.
control = ref new BlitStruct<ApplicationControlProperty>(1).Value;
// The set sizes don't actually matter as long as they're non-zero because we use directory savedata.
control.UserAccountSaveDataSize = 0x4000;
control.UserAccountSaveDataJournalSize = 0x4000;
Logger.PrintWarning(LogClass.ServiceAm,
"No control file was found for this game. Using a dummy one instead. This may cause inaccuracies in some games.");
}
Result result = EnsureApplicationSaveData(context.Device.System.FsClient, out long requiredSize, titleId, Result result = EnsureApplicationSaveData(context.Device.System.FsClient, out long requiredSize, titleId,
ref context.Device.System.ControlData.Value, ref userId); ref context.Device.System.ControlData.Value, ref userId);