mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
Improve sceNpEula
This commit is contained in:
parent
47ae192cf8
commit
74e084c893
@ -1,74 +1,96 @@
|
||||
#include "stdafx.h"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "cellSysutil.h"
|
||||
#include "sceNp.h"
|
||||
#include "Emu/IdManager.h"
|
||||
|
||||
LOG_CHANNEL(cellSysutilNpEula);
|
||||
|
||||
struct sceNpEulaStructUnk0
|
||||
enum SceNpEulaStatus
|
||||
{
|
||||
char buf[0xc];
|
||||
SCE_NP_EULA_UNKNOWN = 0,
|
||||
SCE_NP_EULA_ACCEPTED = 1,
|
||||
SCE_NP_EULA_ALREADY_ACCEPTED = 2,
|
||||
SCE_NP_EULA_REJECTED = 3,
|
||||
SCE_NP_EULA_ABORTED = 4,
|
||||
SCE_NP_EULA_ERROR = 5,
|
||||
};
|
||||
|
||||
// All error codes are unknown at this point in implementation and just guesses
|
||||
enum cellSysutilNpEulaError : u32
|
||||
using SceNpEulaVersion = u32;
|
||||
using SceNpEulaCheckEulaStatusCallback = void(SceNpEulaStatus status, u32 errorCode, SceNpEulaVersion version, vm::ptr<void> arg);
|
||||
|
||||
struct sceNpEulaCallbacksRegistered
|
||||
{
|
||||
CELL_SYSUTIL_NP_EULA_NOT_INIT = 0x8002E500,
|
||||
CELL_SYSUTIL_NP_EULA_INVALID_PARAM = 0x8002E501,
|
||||
CELL_SYSUTIL_NP_EULA_UNKNOWN_502 = 0x8002E502,
|
||||
CELL_SYSUTIL_NP_EULA_UNKNOWN_503 = 0x8002E503,
|
||||
atomic_t<SceNpEulaStatus> status = SCE_NP_EULA_UNKNOWN;
|
||||
atomic_t<bool> sceNpEulaCheckEulaStatus_callback_registered = false;
|
||||
atomic_t<bool> sceNpEulaShowCurrentEula_callback_registered = false;
|
||||
};
|
||||
|
||||
template<>
|
||||
void fmt_class_string<cellSysutilNpEulaError>::format(std::string& out, u64 arg)
|
||||
error_code sceNpEulaCheckEulaStatus(vm::cptr<SceNpCommunicationId> communicationId, u32 arg2, u64 arg3, vm::ptr<SceNpEulaCheckEulaStatusCallback> cbFunc, vm::ptr<void> cbFuncArg)
|
||||
{
|
||||
format_enum(out, arg, [](auto error)
|
||||
cellSysutilNpEula.warning("sceNpEulaCheckEulaStatus(communicationId=*0x%x, arg2=0x%x, arg3=0x%x, cbFunc=*0x%x, cbFuncArg=*0x%x)", communicationId, arg2, arg3, cbFunc, cbFuncArg);
|
||||
|
||||
if (!communicationId || !cbFunc)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
STR_CASE(CELL_SYSUTIL_NP_EULA_NOT_INIT);
|
||||
STR_CASE(CELL_SYSUTIL_NP_EULA_INVALID_PARAM);
|
||||
STR_CASE(CELL_SYSUTIL_NP_EULA_UNKNOWN_502);
|
||||
STR_CASE(CELL_SYSUTIL_NP_EULA_UNKNOWN_503);
|
||||
}
|
||||
return SCE_NP_EULA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return unknown;
|
||||
auto& cb_infos = g_fxo->get<sceNpEulaCallbacksRegistered>();
|
||||
|
||||
if (cb_infos.sceNpEulaCheckEulaStatus_callback_registered || cb_infos.sceNpEulaShowCurrentEula_callback_registered)
|
||||
{
|
||||
return SCE_NP_EULA_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
cb_infos.sceNpEulaCheckEulaStatus_callback_registered = true;
|
||||
cb_infos.status = SCE_NP_EULA_ALREADY_ACCEPTED;
|
||||
|
||||
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
auto& cb_infos = g_fxo->get<sceNpEulaCallbacksRegistered>();
|
||||
cbFunc(cb_ppu, cb_infos.status, CELL_OK, 1, cbFuncArg);
|
||||
cb_infos.sceNpEulaCheckEulaStatus_callback_registered = false;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
// Seen on: Resistance 3, Uncharted 2
|
||||
error_code sceNpEulaCheckEulaStatus(vm::ptr<sceNpEulaStructUnk0> arg1, u32 arg2, u64 arg3, u32 arg4, vm::ptr<CellSysutilCallback> callback1)
|
||||
{
|
||||
cellSysutilNpEula.todo("sceNpEulaCheckEulaStatus(arg1=*0x%x, arg2=0x%x, arg3=0x%x, arg4=0x%x, callback1=*0x%x)", arg1, arg2, arg3, arg4, callback1);
|
||||
|
||||
if (!arg1)
|
||||
return CELL_SYSUTIL_NP_EULA_INVALID_PARAM;
|
||||
|
||||
if (arg4 == 0)
|
||||
return CELL_SYSUTIL_NP_EULA_INVALID_PARAM;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
// Seen on: Resistance 3
|
||||
error_code sceNpEulaAbort()
|
||||
{
|
||||
cellSysutilNpEula.todo("sceNpEulaAbort()");
|
||||
cellSysutilNpEula.warning("sceNpEulaAbort()");
|
||||
|
||||
// Can return CELL_SYSUTIL_NP_EULA_NOT_INIT
|
||||
auto& cb_infos = g_fxo->get<sceNpEulaCallbacksRegistered>();
|
||||
|
||||
if (!cb_infos.sceNpEulaCheckEulaStatus_callback_registered && !cb_infos.sceNpEulaShowCurrentEula_callback_registered)
|
||||
{
|
||||
return SCE_NP_EULA_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
// It would forcefully abort the dialog/process of getting the eula but since we don't show the dialog, just alter the status returned
|
||||
cb_infos.status = SCE_NP_EULA_ABORTED;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
// Seen on: Resistance 3, Uncharted 2
|
||||
error_code sceNpEulaShowCurrentEula(vm::ptr<sceNpEulaStructUnk0> arg1, u64 arg2, vm::ptr<CellSysutilCallback> callback1, vm::ptr<CellSysutilCallback> callback2)
|
||||
error_code sceNpEulaShowCurrentEula(vm::cptr<SceNpCommunicationId> communicationId, u64 arg2, vm::ptr<CellSysutilCallback> cbFunc, vm::ptr<void> cbFuncArg)
|
||||
{
|
||||
cellSysutilNpEula.todo("sceNpEulaShowCurrentEula(arg1=*0x%x, arg2=0x%x, callback1=*0x%x, callback2=*0x%x)", arg1, arg2, callback1, callback2);
|
||||
cellSysutilNpEula.todo("sceNpEulaShowCurrentEula(communicationId=*0x%x, arg2=0x%x, cbFunc=*0x%x, cbFuncArg=*0x%x)", communicationId, arg2, cbFunc, cbFuncArg);
|
||||
|
||||
if (!arg1)
|
||||
return CELL_SYSUTIL_NP_EULA_INVALID_PARAM;
|
||||
if (!communicationId || !cbFunc)
|
||||
{
|
||||
return SCE_NP_EULA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (!callback1)
|
||||
return CELL_SYSUTIL_NP_EULA_INVALID_PARAM;
|
||||
auto& cb_infos = g_fxo->get<sceNpEulaCallbacksRegistered>();
|
||||
|
||||
if (cb_infos.sceNpEulaCheckEulaStatus_callback_registered || cb_infos.sceNpEulaShowCurrentEula_callback_registered)
|
||||
{
|
||||
return SCE_NP_EULA_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
// Call callback (Unknown parameters)
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -398,6 +398,21 @@ void fmt_class_string<SceNpError>::format(std::string& out, u64 arg)
|
||||
STR_CASE(SCE_NP_CUSTOM_MENU_ERROR_NOT_REGISTERED);
|
||||
STR_CASE(SCE_NP_CUSTOM_MENU_ERROR_EXCEEDS_MAX);
|
||||
STR_CASE(SCE_NP_CUSTOM_MENU_ERROR_INVALID_CHARACTER);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_UNKNOWN);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_INVALID_ARGUMENT);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_NOT_INITIALIZED);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_ALREADY_INITIALIZED);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_OUT_OF_MEMORY);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_BUSY);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_EULA_NOT_FOUND);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_NET_OUT_OF_MEMORY);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_CONF_FORMAT);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_CONF_INVALID_FILENAME);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_CONF_TOO_MANY_EULA_FILES);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_CONF_INVALID_LANGUAGE);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_CONF_INVALID_COUNTRY);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_CONF_INVALID_NPCOMMID);
|
||||
STR_CASE(SCE_NP_EULA_ERROR_CONF_INVALID_EULA_VERSION);
|
||||
}
|
||||
|
||||
return unknown;
|
||||
|
@ -454,6 +454,23 @@ enum SceNpError : u32
|
||||
SCE_NP_CUSTOM_MENU_ERROR_NOT_REGISTERED = 0x80023b0b,
|
||||
SCE_NP_CUSTOM_MENU_ERROR_EXCEEDS_MAX = 0x80023b0c,
|
||||
SCE_NP_CUSTOM_MENU_ERROR_INVALID_CHARACTER = 0x80023b0d,
|
||||
|
||||
// EULA
|
||||
SCE_NP_EULA_ERROR_UNKNOWN = 0x8002e500,
|
||||
SCE_NP_EULA_ERROR_INVALID_ARGUMENT = 0x8002e501,
|
||||
SCE_NP_EULA_ERROR_NOT_INITIALIZED = 0x8002e502,
|
||||
SCE_NP_EULA_ERROR_ALREADY_INITIALIZED = 0x8002e503,
|
||||
SCE_NP_EULA_ERROR_OUT_OF_MEMORY = 0x8002E504,
|
||||
SCE_NP_EULA_ERROR_BUSY = 0x8002e505,
|
||||
SCE_NP_EULA_ERROR_EULA_NOT_FOUND = 0x8002e5a0,
|
||||
SCE_NP_EULA_ERROR_NET_OUT_OF_MEMORY = 0x8002e5a1,
|
||||
SCE_NP_EULA_ERROR_CONF_FORMAT = 0x8002e5b0,
|
||||
SCE_NP_EULA_ERROR_CONF_INVALID_FILENAME = 0x8002e5b1,
|
||||
SCE_NP_EULA_ERROR_CONF_TOO_MANY_EULA_FILES = 0x8002e5b2,
|
||||
SCE_NP_EULA_ERROR_CONF_INVALID_LANGUAGE = 0x8002e5b3,
|
||||
SCE_NP_EULA_ERROR_CONF_INVALID_COUNTRY = 0x8002e5b4,
|
||||
SCE_NP_EULA_ERROR_CONF_INVALID_NPCOMMID = 0x8002e5b5,
|
||||
SCE_NP_EULA_ERROR_CONF_INVALID_EULA_VERSION = 0x8002e5b6,
|
||||
};
|
||||
|
||||
// Basic presence options
|
||||
|
Loading…
Reference in New Issue
Block a user