mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-06 13:30:00 +00:00
Merge pull request #5852 from ErenYeager1836/fix/player-review-dialog-error-codes
fix(libSceCdlgPlayerReview): return error codes instead of throwing in initialize and terminate
This commit is contained in:
2 files changed
+10
-4
No files matched your search
@@ -1,6 +1,5 @@
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
|
||||
@@ -11,9 +10,11 @@ constexpr int COMMON_DIALOG_STATUS_NONE = 0;
|
||||
constexpr int COMMON_DIALOG_STATUS_RUNNING = 2;
|
||||
constexpr int COMMON_DIALOG_STATUS_FINISHED = 3;
|
||||
constexpr int COMMON_DIALOG_RESULT_USER_CANCELED = 1;
|
||||
constexpr int COMMON_DIALOG_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x80B80004u);
|
||||
constexpr int COMMON_DIALOG_ERROR_NOT_INITIALIZED = static_cast<int>(0x80B80003u);
|
||||
constexpr int COMMON_DIALOG_ERROR_NOT_FINISHED = static_cast<int>(0x80B80005u);
|
||||
constexpr int COMMON_DIALOG_ERROR_BUSY = static_cast<int>(0x80B80007u);
|
||||
constexpr int COMMON_DIALOG_ERROR_NOT_RUNNING = static_cast<int>(0x80B8000Bu);
|
||||
constexpr int COMMON_DIALOG_ERROR_ARG_NULL = static_cast<int>(0x80B8000Du);
|
||||
}
|
||||
|
||||
@@ -21,7 +22,7 @@ extern "C" {
|
||||
|
||||
int APS5_VABI scePlayerReviewDialogInitialize(void) {
|
||||
int expected = 0;
|
||||
if (!g_status.compare_exchange_strong(expected, 1)) throw std::logic_error("scePlayerReviewDialogInitialize: already initialized");
|
||||
if (!g_status.compare_exchange_strong(expected, 1)) return COMMON_DIALOG_ERROR_ALREADY_INITIALIZED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,8 +30,9 @@ int APS5_VABI scePlayerReviewDialogTerminate(void) {
|
||||
int expected = 1;
|
||||
if (g_status.compare_exchange_strong(expected, 0)) return 0;
|
||||
expected = COMMON_DIALOG_STATUS_FINISHED;
|
||||
if (!g_status.compare_exchange_strong(expected, 0)) throw std::logic_error("scePlayerReviewDialogTerminate: not initialized or still running");
|
||||
return 0;
|
||||
if (g_status.compare_exchange_strong(expected, 0)) return 0;
|
||||
if (g_status.load() == 0) return COMMON_DIALOG_ERROR_NOT_INITIALIZED;
|
||||
return COMMON_DIALOG_ERROR_NOT_RUNNING;
|
||||
}
|
||||
|
||||
int APS5_VABI scePlayerReviewDialogOpen(const void* param) {
|
||||
|
||||
@@ -18,6 +18,7 @@ constexpr int COMMON_DIALOG_STATUS_NONE = 0;
|
||||
constexpr int COMMON_DIALOG_STATUS_INITIALIZED = 1;
|
||||
constexpr int COMMON_DIALOG_STATUS_FINISHED = 3;
|
||||
constexpr int COMMON_DIALOG_RESULT_USER_CANCELED = 1;
|
||||
constexpr int COMMON_DIALOG_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x80B80004u);
|
||||
constexpr int COMMON_DIALOG_ERROR_NOT_INITIALIZED = static_cast<int>(0x80B80003u);
|
||||
constexpr int COMMON_DIALOG_ERROR_NOT_FINISHED = static_cast<int>(0x80B80005u);
|
||||
constexpr int COMMON_DIALOG_ERROR_ARG_NULL = static_cast<int>(0x80B8000Du);
|
||||
@@ -29,16 +30,19 @@ void Require(bool value) { if (!value) std::abort(); }
|
||||
int main() {
|
||||
std::uint8_t param[64] = {};
|
||||
std::int32_t result[8] = {};
|
||||
Require(scePlayerReviewDialogTerminate() == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
|
||||
Require(scePlayerReviewDialogGetStatus() == COMMON_DIALOG_STATUS_NONE);
|
||||
Require(scePlayerReviewDialogOpen(param) == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
|
||||
Require(scePlayerReviewDialogClose() == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
|
||||
Require(scePlayerReviewDialogGetResult(result) == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
|
||||
|
||||
Require(scePlayerReviewDialogInitialize() == 0);
|
||||
Require(scePlayerReviewDialogInitialize() == COMMON_DIALOG_ERROR_ALREADY_INITIALIZED);
|
||||
Require(scePlayerReviewDialogGetStatus() == COMMON_DIALOG_STATUS_INITIALIZED);
|
||||
Require(scePlayerReviewDialogUpdateStatus() == COMMON_DIALOG_STATUS_INITIALIZED);
|
||||
Require(scePlayerReviewDialogGetResult(result) == COMMON_DIALOG_ERROR_NOT_FINISHED);
|
||||
Require(scePlayerReviewDialogTerminate() == 0);
|
||||
Require(scePlayerReviewDialogTerminate() == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
|
||||
Require(scePlayerReviewDialogGetStatus() == COMMON_DIALOG_STATUS_NONE);
|
||||
|
||||
Require(scePlayerReviewDialogInitialize() == 0);
|
||||
|
||||
Reference in new issue
Block a user