forked from MeloNX/MeloNX
* Implement NGC service * Use raw byte arrays instead of string for _wordSeparators * Silence IDE0230 for _wordSeparators * Try to silence warning about _rangeValuesCount not being read on SparseSet * Make AcType enum private * Add abstract methods and one TODO that I forgot * PR feedback * More PR feedback * More PR feedback
65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using Ryujinx.Horizon.Common;
|
|
using Ryujinx.Horizon.Sdk.Ngc;
|
|
using Ryujinx.Horizon.Sdk.Ngc.Detail;
|
|
using Ryujinx.Horizon.Sdk.Sf;
|
|
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
|
using System;
|
|
|
|
namespace Ryujinx.Horizon.Ngc.Ipc
|
|
{
|
|
partial class Service : INgcService
|
|
{
|
|
private readonly ProfanityFilter _profanityFilter;
|
|
|
|
public Service(ProfanityFilter profanityFilter)
|
|
{
|
|
_profanityFilter = profanityFilter;
|
|
}
|
|
|
|
[CmifCommand(0)]
|
|
public Result GetContentVersion(out uint version)
|
|
{
|
|
lock (_profanityFilter)
|
|
{
|
|
return _profanityFilter.GetContentVersion(out version);
|
|
}
|
|
}
|
|
|
|
[CmifCommand(1)]
|
|
public Result Check(out uint checkMask, ReadOnlySpan<byte> text, uint regionMask, ProfanityFilterOption option)
|
|
{
|
|
lock (_profanityFilter)
|
|
{
|
|
return _profanityFilter.CheckProfanityWords(out checkMask, text, regionMask, option);
|
|
}
|
|
}
|
|
|
|
[CmifCommand(2)]
|
|
public Result Mask(
|
|
out int maskedWordsCount,
|
|
[Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<byte> filteredText,
|
|
[Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<byte> text,
|
|
uint regionMask,
|
|
ProfanityFilterOption option)
|
|
{
|
|
lock (_profanityFilter)
|
|
{
|
|
int length = Math.Min(filteredText.Length, text.Length);
|
|
|
|
text[..length].CopyTo(filteredText[..length]);
|
|
|
|
return _profanityFilter.MaskProfanityWordsInText(out maskedWordsCount, filteredText, regionMask, option);
|
|
}
|
|
}
|
|
|
|
[CmifCommand(3)]
|
|
public Result Reload()
|
|
{
|
|
lock (_profanityFilter)
|
|
{
|
|
return _profanityFilter.Reload();
|
|
}
|
|
}
|
|
}
|
|
}
|