1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-10 13:01:44 +00:00

aoc: Fixes some inconsistencies (#2434)

* aoc: Fixes some inconsistencies

This PR fixes an wrong returned value (introduced in #2414) which cause some DLC not recognized in some games like Super Robot War T.
Additionnally to that, I've removed the EventHandle check too, because it could cause some issues, but sadly it doesn't do the job so I reverted the changes. It should fix Diablo III: Eternal Collection.

* Fix loop

* Revert TitleLanguage change

* write only available ids
This commit is contained in:
Ac_K 2021-07-06 20:17:06 +02:00 committed by GitHub
parent 091edcebb4
commit b72f7de405
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 14 deletions

View file

@ -11,6 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc
class IAddOnContentManager : IpcService
{
private readonly KEvent _addOnContentListChangedEvent;
private int _addOnContentListChangedEventHandle;
private ulong _addOnContentBaseId;
@ -190,19 +191,19 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc
// If QuestFlag is true, counts some extra titles.
uint startIndex = context.RequestData.ReadUInt32();
uint counter = context.RequestData.ReadUInt32();
uint indexNumber = context.RequestData.ReadUInt32();
ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
ulong bufferSize = context.Request.ReceiveBuff[0].Size;
// TODO: This should use _addOnContentBaseId;
uint aocCount = (uint)context.Device.System.ContentManager.GetAocCount();
uint aocTotalCount = (uint)context.Device.System.ContentManager.GetAocCount();
if (counter > bufferSize / sizeof(uint))
if (indexNumber > bufferSize / sizeof(uint))
{
return ResultCode.InvalidBufferSize;
}
if (aocCount <= startIndex)
if (aocTotalCount <= startIndex)
{
context.ResponseData.Write(0);
@ -213,12 +214,19 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc
GetAddOnContentBaseIdFromTitleId(context, titleId);
for (int i = 0; i < aocCount - startIndex; i++)
uint indexCounter = 0;
for (int i = 0; i < indexNumber; i++)
{
context.Memory.Write(bufferPosition + (ulong)i * 4, (uint)(aocTitleIds[i + (int)startIndex] - _addOnContentBaseId));
if (i + (int)startIndex < aocTitleIds.Count)
{
context.Memory.Write(bufferPosition + (ulong)i * sizeof(uint), (uint)(aocTitleIds[i + (int)startIndex] - _addOnContentBaseId));
indexCounter++;
}
}
context.ResponseData.Write(aocCount);
context.ResponseData.Write(indexCounter);
return ResultCode.Success;
}
@ -268,12 +276,15 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc
private ResultCode GetAddOnContentListChangedEventImpl(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_addOnContentListChangedEvent.ReadableEvent, out int addOnContentListChangedEventHandle) != KernelResult.Success)
if (_addOnContentListChangedEventHandle == 0)
{
throw new InvalidOperationException("Out of handles!");
if (context.Process.HandleTable.GenerateHandle(_addOnContentListChangedEvent.ReadableEvent, out _addOnContentListChangedEventHandle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(addOnContentListChangedEventHandle);
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_addOnContentListChangedEventHandle);
return ResultCode.Success;
}

View file

@ -55,11 +55,11 @@ namespace Ryujinx.HLE.HOS.SystemState
DesiredTitleLanguage = language switch
{
SystemLanguage.Taiwanese => TitleLanguage.Taiwanese,
SystemLanguage.TraditionalChinese or
SystemLanguage.Taiwanese or
SystemLanguage.TraditionalChinese => TitleLanguage.Taiwanese,
SystemLanguage.Chinese or
SystemLanguage.SimplifiedChinese => TitleLanguage.Chinese,
_ => Enum.Parse<TitleLanguage>(Enum.GetName(typeof(SystemLanguage), language)),
SystemLanguage.SimplifiedChinese => TitleLanguage.Chinese,
_ => Enum.Parse<TitleLanguage>(Enum.GetName(typeof(SystemLanguage), language)),
};
}