mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-02-04 23:04:41 +01:00
sceNpBasicLimitedSendMessage
Some checks failed
Generate Translation Template / Generate Translation Template (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux-aarch64.sh, gcc, rpcs3/rpcs3-ci-jammy-aarch64:1.7, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.7, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.7, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.7, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (0, 51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, Intel) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (1, 8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, Apple Silicon) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows (push) Has been cancelled
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (aarch64, clang, clangarm64, ARM64, windows-11-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (x86_64, clang, clang64, X64, windows-2025) (push) Has been cancelled
Build RPCS3 / RPCS3 FreeBSD (push) Has been cancelled
Some checks failed
Generate Translation Template / Generate Translation Template (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux-aarch64.sh, gcc, rpcs3/rpcs3-ci-jammy-aarch64:1.7, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.7, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.7, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.7, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (0, 51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, Intel) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (1, 8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, Apple Silicon) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows (push) Has been cancelled
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (aarch64, clang, clangarm64, ARM64, windows-11-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (x86_64, clang, clang64, X64, windows-2025) (push) Has been cancelled
Build RPCS3 / RPCS3 FreeBSD (push) Has been cancelled
This commit is contained in:
parent
818b11fd2f
commit
0e2584fc9f
|
|
@ -1118,10 +1118,35 @@ error_code sceNpBasicSetPresenceDetails2(vm::cptr<SceNpBasicPresenceDetails2> pr
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
error_code sceNpBasicSendMessage(vm::cptr<SceNpId> to, vm::cptr<void> data, u32 size)
|
||||
{
|
||||
sceNp.warning("sceNpBasicSendMessage(to=*0x%x, data=*0x%x, size=%d)", to, data, size);
|
||||
u64 sys_time_get_system_time();
|
||||
|
||||
error_code acquire_time_slot(u64* time_array, usz array_size, u64 slot_duration)
|
||||
{
|
||||
static shared_mutex mutex;
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
const u64 current_time = sys_time_get_system_time();
|
||||
|
||||
for (usz index = 0; index < array_size; index++)
|
||||
{
|
||||
if (time_array[index] == 0)
|
||||
{
|
||||
time_array[index] = current_time;
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
if (current_time > (time_array[index] + slot_duration))
|
||||
{
|
||||
time_array[index] = current_time;
|
||||
return CELL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return SCE_NP_BASIC_ERROR_BUSY;
|
||||
}
|
||||
|
||||
error_code _sceNpBasicSendMessage(vm::cptr<SceNpId> to, vm::cptr<void> data, u32 size, bool rate_limited)
|
||||
{
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP_init)
|
||||
|
|
@ -1144,6 +1169,22 @@ error_code sceNpBasicSendMessage(vm::cptr<SceNpId> to, vm::cptr<void> data, u32
|
|||
return SCE_NP_BASIC_ERROR_EXCEEDS_MAX;
|
||||
}
|
||||
|
||||
if (rate_limited)
|
||||
{
|
||||
struct sceNpBasicSendMessage_time_slots
|
||||
{
|
||||
sceNpBasicSendMessage_time_slots(sceNpBasicSendMessage_time_slots&&) = delete;
|
||||
std::array<u64, 20> data{};
|
||||
};
|
||||
|
||||
auto& time_slots = g_fxo->get<sceNpBasicSendMessage_time_slots>();
|
||||
|
||||
if (auto error = acquire_time_slot(time_slots.data.data(), time_slots.data.size(), 60000000); error != CELL_OK)
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
if (nph.get_psn_status() != SCE_NP_MANAGER_STATUS_ONLINE)
|
||||
{
|
||||
return not_an_error(SCE_NP_BASIC_ERROR_NOT_CONNECTED);
|
||||
|
|
@ -1164,6 +1205,19 @@ error_code sceNpBasicSendMessage(vm::cptr<SceNpId> to, vm::cptr<void> data, u32
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
error_code sceNpBasicSendMessage(vm::cptr<SceNpId> to, vm::cptr<void> data, u32 size)
|
||||
{
|
||||
sceNp.warning("sceNpBasicSendMessage(to=*0x%x, data=*0x%x, size=%d)", to, data, size);
|
||||
return _sceNpBasicSendMessage(to, data, size, false);
|
||||
}
|
||||
|
||||
// This function is sceNpBasicSendMessage + a rate limiter that will return SCE_NP_BASIC_ERROR_BUSY if it too many messages have been sent
|
||||
error_code sceNpBasicLimited_0xEB42E2E6(vm::cptr<SceNpId> to, vm::cptr<void> data, u32 size)
|
||||
{
|
||||
sceNp.warning("sceNpBasicLimited_0xEB42E2E6(to=*0x%x, data=*0x%x, size=%d)", to, data, size);
|
||||
return _sceNpBasicSendMessage(to, data, size, true);
|
||||
}
|
||||
|
||||
error_code sceNpBasicSendMessageGui(ppu_thread& ppu, vm::cptr<SceNpBasicMessageDetails> msg, sys_memory_container_t containerId)
|
||||
{
|
||||
sceNp.warning("sceNpBasicSendMessageGui(msg=*0x%x, containerId=%d)", msg, containerId);
|
||||
|
|
@ -7289,6 +7343,11 @@ s32 _Z32_sce_np_sysutil_cxml_prepare_docPN16sysutil_cxmlutil11FixedMemoryERN4cxm
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
DECLARE(ppu_module_manager::sceNpBasicLimited)
|
||||
("sceNpBasicLimited", []() {
|
||||
ppu_module_manager::register_static_function<&sceNpBasicLimited_0xEB42E2E6>("sceNpBasicLimited", ppu_select_name("sceNpBasicLimited", "sceNpBasicLimited_0xEB42E2E6"), BIND_FUNC_WITH_BLR(sceNpBasicLimited_0xEB42E2E6, "sceNpBasicLimited"), 0xEB42E2E6);
|
||||
});
|
||||
|
||||
DECLARE(ppu_module_manager::sceNp)
|
||||
("sceNp", []() {
|
||||
REG_FUNC(sceNp, sceNpInit);
|
||||
|
|
|
|||
|
|
@ -314,6 +314,7 @@ static void ppu_initialize_modules(ppu_linkage_info* link, utils::serial* ar = n
|
|||
&ppu_module_manager::libsnd3,
|
||||
&ppu_module_manager::libsynth2,
|
||||
&ppu_module_manager::sceNp,
|
||||
&ppu_module_manager::sceNpBasicLimited,
|
||||
&ppu_module_manager::sceNp2,
|
||||
&ppu_module_manager::sceNpClans,
|
||||
&ppu_module_manager::sceNpCommerce2,
|
||||
|
|
|
|||
|
|
@ -283,6 +283,7 @@ public:
|
|||
static const ppu_static_module libsnd3;
|
||||
static const ppu_static_module libsynth2;
|
||||
static const ppu_static_module sceNp;
|
||||
static const ppu_static_module sceNpBasicLimited;
|
||||
static const ppu_static_module sceNp2;
|
||||
static const ppu_static_module sceNpClans;
|
||||
static const ppu_static_module sceNpCommerce2;
|
||||
|
|
|
|||
Loading…
Reference in a new issue