core: Library cleanup (#1631)

* core: Split error codes into separate files

* Reduces build times and is cleaner

* core: Bring structs and enums to codebase style

* core: More style changes
This commit is contained in:
TheTurtle 2024-11-30 22:37:36 +02:00 committed by GitHub
parent 3d0aacd43d
commit 5b6e0ab238
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
114 changed files with 2158 additions and 2509 deletions

View file

@ -7,10 +7,10 @@
#include "common/logging/log.h"
#include "common/path_util.h"
#include "common/slot_vector.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include "np_trophy.h"
#include "trophy_ui.h"
#include "core/libraries/np_trophy/np_trophy.h"
#include "core/libraries/np_trophy/np_trophy_error.h"
#include "core/libraries/np_trophy/trophy_ui.h"
namespace Libraries::NpTrophy {

View file

@ -29,14 +29,14 @@ constexpr int ORBIS_NP_TROPHY_INVALID_HANDLE = -1;
constexpr int ORBIS_NP_TROPHY_INVALID_CONTEXT = -1;
constexpr int ORBIS_NP_TROPHY_INVALID_TROPHY_ID = -1;
typedef int32_t OrbisNpTrophyHandle;
typedef int32_t OrbisNpTrophyContext;
typedef int32_t OrbisNpTrophyId;
typedef uint32_t OrbisNpTrophyFlagMask;
using OrbisNpTrophyHandle = s32;
using OrbisNpTrophyContext = s32;
using OrbisNpTrophyId = s32;
using OrbisNpTrophyFlagMask = u32;
struct OrbisNpTrophyFlagArray {
OrbisNpTrophyFlagMask
flag_bits[ORBIS_NP_TROPHY_FLAG_SETSIZE >> ORBIS_NP_TROPHY_FLAG_BITS_SHIFT];
static constexpr int NumMasks = ORBIS_NP_TROPHY_FLAG_SETSIZE >> ORBIS_NP_TROPHY_FLAG_BITS_SHIFT;
std::array<OrbisNpTrophyFlagMask, NumMasks> flag_bits;
};
void ORBIS_NP_TROPHY_FLAG_ZERO(OrbisNpTrophyFlagArray* p);
@ -49,18 +49,18 @@ struct OrbisNpTrophyData {
size_t size;
OrbisNpTrophyId trophy_id;
bool unlocked;
uint8_t reserved[3];
u8 reserved[3];
Rtc::OrbisRtcTick timestamp;
};
typedef int32_t OrbisNpTrophyGrade;
using OrbisNpTrophyGrade = s32;
constexpr int ORBIS_NP_TROPHY_GRADE_UNKNOWN = 0;
constexpr int ORBIS_NP_TROPHY_GRADE_PLATINUM = 1;
constexpr int ORBIS_NP_TROPHY_GRADE_GOLD = 2;
constexpr int ORBIS_NP_TROPHY_GRADE_SILVER = 3;
constexpr int ORBIS_NP_TROPHY_GRADE_BRONZE = 4;
typedef int32_t OrbisNpTrophyGroupId;
using OrbisNpTrophyGroupId = s32;
constexpr int ORBIS_NP_TROPHY_BASE_GAME_GROUP_ID = -1;
constexpr int ORBIS_NP_TROPHY_INVALID_GROUP_ID = -2;
@ -70,29 +70,29 @@ struct OrbisNpTrophyDetails {
OrbisNpTrophyGrade trophy_grade;
OrbisNpTrophyGroupId group_id;
bool hidden;
uint8_t reserved[3];
u8 reserved[3];
char name[ORBIS_NP_TROPHY_NAME_MAX_SIZE];
char description[ORBIS_NP_TROPHY_DESCR_MAX_SIZE];
};
struct OrbisNpTrophyGameData {
size_t size;
uint32_t unlocked_trophies;
uint32_t unlocked_platinum;
uint32_t unlocked_gold;
uint32_t unlocked_silver;
uint32_t unlocked_bronze;
uint32_t progress_percentage;
u32 unlocked_trophies;
u32 unlocked_platinum;
u32 unlocked_gold;
u32 unlocked_silver;
u32 unlocked_bronze;
u32 progress_percentage;
};
struct OrbisNpTrophyGameDetails {
size_t size;
uint32_t num_groups;
uint32_t num_trophies;
uint32_t num_platinum;
uint32_t num_gold;
uint32_t num_silver;
uint32_t num_bronze;
u32 num_groups;
u32 num_trophies;
u32 num_platinum;
u32 num_gold;
u32 num_silver;
u32 num_bronze;
char title[ORBIS_NP_TROPHY_GAME_TITLE_MAX_SIZE];
char description[ORBIS_NP_TROPHY_GAME_DESCR_MAX_SIZE];
};
@ -100,23 +100,23 @@ struct OrbisNpTrophyGameDetails {
struct OrbisNpTrophyGroupData {
size_t size;
OrbisNpTrophyGroupId group_id;
uint32_t unlocked_trophies;
uint32_t unlocked_platinum;
uint32_t unlocked_gold;
uint32_t unlocked_silver;
uint32_t unlocked_bronze;
uint32_t progress_percentage;
u32 unlocked_trophies;
u32 unlocked_platinum;
u32 unlocked_gold;
u32 unlocked_silver;
u32 unlocked_bronze;
u32 progress_percentage;
uint8_t reserved[4];
};
struct OrbisNpTrophyGroupDetails {
size_t size;
OrbisNpTrophyGroupId group_id;
uint32_t num_trophies;
uint32_t num_platinum;
uint32_t num_gold;
uint32_t num_silver;
uint32_t num_bronze;
u32 num_trophies;
u32 num_platinum;
u32 num_gold;
u32 num_silver;
u32 num_bronze;
char title[ORBIS_NP_TROPHY_GROUP_TITLE_MAX_SIZE];
char description[ORBIS_NP_TROPHY_GROUP_DESCR_MAX_SIZE];
};
@ -133,7 +133,7 @@ int PS4_SYSV_ABI sceNpTrophyConfigGetTrophySetVersion();
int PS4_SYSV_ABI sceNpTrophyConfigGetTrophyTitleDetails();
int PS4_SYSV_ABI sceNpTrophyConfigHasGroupFeature();
s32 PS4_SYSV_ABI sceNpTrophyCreateContext(OrbisNpTrophyContext* context, int32_t user_id,
uint32_t service_label, uint64_t options);
u32 service_label, uint64_t options);
s32 PS4_SYSV_ABI sceNpTrophyCreateHandle(OrbisNpTrophyHandle* handle);
int PS4_SYSV_ABI sceNpTrophyDestroyContext(OrbisNpTrophyContext context);
s32 PS4_SYSV_ABI sceNpTrophyDestroyHandle(OrbisNpTrophyHandle handle);

View file

@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "core/libraries/error_codes.h"
// NpTrophy library
constexpr int ORBIS_NP_TROPHY_ERROR_UNKNOWN = 0x80551600;
constexpr int ORBIS_NP_TROPHY_ERROR_NOT_INITIALIZED = 0x80551601;
constexpr int ORBIS_NP_TROPHY_ERROR_ALREADY_INITIALIZED = 0x80551602;
constexpr int ORBIS_NP_TROPHY_ERROR_OUT_OF_MEMORY = 0x80551603;
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_ARGUMENT = 0x80551604;
constexpr int ORBIS_NP_TROPHY_ERROR_INSUFFICIENT_BUFFER = 0x80551605;
constexpr int ORBIS_NP_TROPHY_ERROR_EXCEEDS_MAX = 0x80551606;
constexpr int ORBIS_NP_TROPHY_ERROR_ABORT = 0x80551607;
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_HANDLE = 0x80551608;
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_CONTEXT = 0x80551609;
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_TROPHY_ID = 0x8055160A;
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_GROUP_ID = 0x8055160B;
constexpr int ORBIS_NP_TROPHY_ERROR_TROPHY_ALREADY_UNLOCKED = 0x8055160C;
constexpr int ORBIS_NP_TROPHY_ERROR_PLATINUM_CANNOT_UNLOCK = 0x8055160D;
constexpr int ORBIS_NP_TROPHY_ERROR_ACCOUNTID_NOT_MATCH = 0x8055160E;
constexpr int ORBIS_NP_TROPHY_ERROR_NOT_REGISTERED = 0x8055160F;
constexpr int ORBIS_NP_TROPHY_ERROR_ALREADY_REGISTERED = 0x80551610;
constexpr int ORBIS_NP_TROPHY_ERROR_BROKEN_DATA = 0x80551611;
constexpr int ORBIS_NP_TROPHY_ERROR_INSUFFICIENT_SPACE = 0x80551612;
constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_ALREADY_EXISTS = 0x80551613;
constexpr int ORBIS_NP_TROPHY_ERROR_ICON_FILE_NOT_FOUND = 0x80551614;
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_TRP_FILE_FORMAT = 0x80551616;
constexpr int ORBIS_NP_TROPHY_ERROR_UNSUPPORTED_TRP_FILE = 0x80551617;
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_TROPHY_CONF_FORMAT = 0x80551618;
constexpr int ORBIS_NP_TROPHY_ERROR_UNSUPPORTED_TROPHY_CONF = 0x80551619;
constexpr int ORBIS_NP_TROPHY_ERROR_TROPHY_NOT_UNLOCKED = 0x8055161A;
constexpr int ORBIS_NP_TROPHY_ERROR_USER_NOT_FOUND = 0x8055161C;
constexpr int ORBIS_NP_TROPHY_ERROR_USER_NOT_LOGGED_IN = 0x8055161D;
constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_USER_LOGOUT = 0x8055161E;
constexpr int ORBIS_NP_TROPHY_ERROR_USE_TRP_FOR_DEVELOPMENT = 0x8055161F;
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_NP_SERVICE_LABEL = 0x80551621;
constexpr int ORBIS_NP_TROPHY_ERROR_NOT_SUPPORTED = 0x80551622;
constexpr int ORBIS_NP_TROPHY_ERROR_CONTEXT_EXCEEDS_MAX = 0x80551623;
constexpr int ORBIS_NP_TROPHY_ERROR_HANDLE_EXCEEDS_MAX = 0x80551624;
constexpr int ORBIS_NP_TROPHY_ERROR_INVALID_USER_ID = 0x80551625;
constexpr int ORBIS_NP_TROPHY_ERROR_TITLE_CONF_NOT_INSTALLED = 0x80551626;
constexpr int ORBIS_NP_TROPHY_ERROR_BROKEN_TITLE_CONF = 0x80551627;
constexpr int ORBIS_NP_TROPHY_ERROR_INCONSISTENT_TITLE_CONF = 0x80551628;
constexpr int ORBIS_NP_TROPHY_ERROR_TITLE_BACKGROUND = 0x80551629;
constexpr int ORBIS_NP_TROPHY_ERROR_SCREENSHOT_DISABLED = 0x8055162B;
constexpr int ORBIS_NP_TROPHY_ERROR_SCREENSHOT_DISPLAY_BUFFER_NOT_IN_USE = 0x8055162D;