libraries: trophy: a better stubs implementation
This commit is contained in:
parent
acc4ef7b4c
commit
ff64dd74f6
|
@ -446,3 +446,10 @@ constexpr int ORBIS_USER_SERVICE_ERROR_BUFFER_TOO_SHORT = 0x8096000A;
|
||||||
|
|
||||||
// SystemService library
|
// SystemService library
|
||||||
constexpr int ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER = 0x80A10003;
|
constexpr int ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER = 0x80A10003;
|
||||||
|
|
||||||
|
// NpTrophy library
|
||||||
|
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT = 0x80551604;
|
||||||
|
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE = 0x80551608;
|
||||||
|
constexpr int ORBIS_NP_TROPHY_ERROR_HANDLE_EXCEEDS_MAX = 0x80551624;
|
||||||
|
constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_ALREADY_EXISTS = 0x80551613;
|
||||||
|
constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_EXCEEDS_MAX = 0x80551622;
|
||||||
|
|
|
@ -2,14 +2,34 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
// Generated By moduleGenerator
|
// Generated By moduleGenerator
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "common/slot_vector.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/error_codes.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "np_trophy.h"
|
#include "np_trophy.h"
|
||||||
|
|
||||||
namespace Libraries::NpTrophy {
|
namespace Libraries::NpTrophy {
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpTrophyAbortHandle() {
|
static constexpr auto MaxTrophyHandles = 4u;
|
||||||
|
static constexpr auto MaxTrophyContexts = 8u;
|
||||||
|
|
||||||
|
using ContextKey = std::pair<u32, u32>; // <user_id, service label>
|
||||||
|
struct ContextKeyHash {
|
||||||
|
size_t operator()(const ContextKey& key) const {
|
||||||
|
return key.first + (u64(key.second) << 32u);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TrophyContext {
|
||||||
|
u32 context_id;
|
||||||
|
};
|
||||||
|
static Common::SlotVector<u32> trophy_handles{};
|
||||||
|
static Common::SlotVector<ContextKey> trophy_contexts{};
|
||||||
|
static std::unordered_map<ContextKey, TrophyContext, ContextKeyHash> contexts_internal{};
|
||||||
|
|
||||||
|
static int PS4_SYSV_ABI sceNpTrophyAbortHandle() {
|
||||||
LOG_ERROR(Lib_NpTrophy, "(STUBBED) called");
|
LOG_ERROR(Lib_NpTrophy, "(STUBBED) called");
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
@ -64,14 +84,43 @@ int PS4_SYSV_ABI sceNpTrophyConfigHasGroupFeature() {
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpTrophyCreateContext() {
|
s32 PS4_SYSV_ABI sceNpTrophyCreateContext(u32* context, u32 user_id, u32 service_label,
|
||||||
LOG_ERROR(Lib_NpTrophy, "(STUBBED) called");
|
u64 options) {
|
||||||
|
ASSERT(options == 0ull);
|
||||||
|
if (!context) {
|
||||||
|
return ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trophy_contexts.size() >= MaxTrophyContexts) {
|
||||||
|
return ORBIS_NP_TROPHY_ERROR_CONTEXT_EXCEEDS_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& key = ContextKey{user_id, service_label};
|
||||||
|
if (contexts_internal.contains(key)) {
|
||||||
|
return ORBIS_NP_TROPHY_ERROR_CONTEXT_ALREADY_EXISTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto ctx_id = trophy_contexts.insert(user_id, service_label);
|
||||||
|
contexts_internal[key].context_id = ctx_id.index;
|
||||||
|
LOG_INFO(Lib_NpTrophy, "New context = {}, user_id = {} service label = {}", ctx_id.index,
|
||||||
|
user_id, service_label);
|
||||||
|
*context = ctx_id.index;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpTrophyCreateHandle() {
|
s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(u32* handle) {
|
||||||
LOG_ERROR(Lib_NpTrophy, "(STUBBED) called");
|
if (!handle) {
|
||||||
return -1;
|
return ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trophy_handles.size() >= MaxTrophyHandles) {
|
||||||
|
return ORBIS_NP_TROPHY_ERROR_HANDLE_EXCEEDS_MAX;
|
||||||
|
}
|
||||||
|
const auto handle_id = trophy_handles.insert();
|
||||||
|
LOG_INFO(Lib_NpTrophy, "New handle = {}", handle_id.index);
|
||||||
|
|
||||||
|
*handle = handle_id.index;
|
||||||
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpTrophyDestroyContext() {
|
int PS4_SYSV_ABI sceNpTrophyDestroyContext() {
|
||||||
|
@ -79,8 +128,13 @@ int PS4_SYSV_ABI sceNpTrophyDestroyContext() {
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpTrophyDestroyHandle() {
|
s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(u32 handle) {
|
||||||
LOG_ERROR(Lib_NpTrophy, "(STUBBED) called");
|
if (!trophy_handles.is_allocated({handle})) {
|
||||||
|
return ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
trophy_handles.erase({handle});
|
||||||
|
LOG_INFO(Lib_NpTrophy, "Handle {} destroyed", handle);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +168,10 @@ int PS4_SYSV_ABI sceNpTrophyGetTrophyInfo() {
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceNpTrophyGetTrophyUnlockState() {
|
s32 PS4_SYSV_ABI sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, u32* flags, u32* count) {
|
||||||
LOG_ERROR(Lib_NpTrophy, "(STUBBED) called");
|
LOG_ERROR(Lib_NpTrophy, "(STUBBED) called");
|
||||||
|
*flags = 0u;
|
||||||
|
*count = 0;
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,17 +22,18 @@ int PS4_SYSV_ABI sceNpTrophyConfigGetTrophySetInfoInGroup();
|
||||||
int PS4_SYSV_ABI sceNpTrophyConfigGetTrophySetVersion();
|
int PS4_SYSV_ABI sceNpTrophyConfigGetTrophySetVersion();
|
||||||
int PS4_SYSV_ABI sceNpTrophyConfigGetTrophyTitleDetails();
|
int PS4_SYSV_ABI sceNpTrophyConfigGetTrophyTitleDetails();
|
||||||
int PS4_SYSV_ABI sceNpTrophyConfigHasGroupFeature();
|
int PS4_SYSV_ABI sceNpTrophyConfigHasGroupFeature();
|
||||||
int PS4_SYSV_ABI sceNpTrophyCreateContext();
|
s32 PS4_SYSV_ABI sceNpTrophyCreateContext(u32* context, u32 user_id, u32 service_label,
|
||||||
int PS4_SYSV_ABI sceNpTrophyCreateHandle();
|
u64 options);
|
||||||
|
s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(u32* handle);
|
||||||
int PS4_SYSV_ABI sceNpTrophyDestroyContext();
|
int PS4_SYSV_ABI sceNpTrophyDestroyContext();
|
||||||
int PS4_SYSV_ABI sceNpTrophyDestroyHandle();
|
s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(u32 handle);
|
||||||
int PS4_SYSV_ABI sceNpTrophyGetGameIcon();
|
int PS4_SYSV_ABI sceNpTrophyGetGameIcon();
|
||||||
int PS4_SYSV_ABI sceNpTrophyGetGameInfo();
|
int PS4_SYSV_ABI sceNpTrophyGetGameInfo();
|
||||||
int PS4_SYSV_ABI sceNpTrophyGetGroupIcon();
|
int PS4_SYSV_ABI sceNpTrophyGetGroupIcon();
|
||||||
int PS4_SYSV_ABI sceNpTrophyGetGroupInfo();
|
int PS4_SYSV_ABI sceNpTrophyGetGroupInfo();
|
||||||
int PS4_SYSV_ABI sceNpTrophyGetTrophyIcon();
|
int PS4_SYSV_ABI sceNpTrophyGetTrophyIcon();
|
||||||
int PS4_SYSV_ABI sceNpTrophyGetTrophyInfo();
|
int PS4_SYSV_ABI sceNpTrophyGetTrophyInfo();
|
||||||
int PS4_SYSV_ABI sceNpTrophyGetTrophyUnlockState();
|
s32 PS4_SYSV_ABI sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, u32* flags, u32* count);
|
||||||
int PS4_SYSV_ABI sceNpTrophyGroupArrayGetNum();
|
int PS4_SYSV_ABI sceNpTrophyGroupArrayGetNum();
|
||||||
int PS4_SYSV_ABI sceNpTrophyIntAbortHandle();
|
int PS4_SYSV_ABI sceNpTrophyIntAbortHandle();
|
||||||
int PS4_SYSV_ABI sceNpTrophyIntCheckNetSyncTitles();
|
int PS4_SYSV_ABI sceNpTrophyIntCheckNetSyncTitles();
|
||||||
|
|
Loading…
Reference in New Issue