username changes to onlineid once connected (#4633)

This commit is contained in:
georgemoralis 2026-06-27 17:03:55 +03:00 committed by GitHub
parent bd741ec57f
commit bf98eaa982
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,6 +10,7 @@
#include "common/singleton.h" #include "common/singleton.h"
#include "core/emulator_settings.h" #include "core/emulator_settings.h"
#include "core/libraries/libs.h" #include "core/libraries/libs.h"
#include "core/libraries/np/np_handler.h"
#include "core/libraries/np/np_manager.h" #include "core/libraries/np/np_manager.h"
#include "core/libraries/system/userservice.h" #include "core/libraries/system/userservice.h"
#include "core/libraries/system/userservice_error.h" #include "core/libraries/system/userservice_error.h"
@ -18,6 +19,8 @@
namespace Libraries::UserService { namespace Libraries::UserService {
static bool g_shadnet_enabled = false;
int PS4_SYSV_ABI sceUserServiceInitializeForShellCore() { int PS4_SYSV_ABI sceUserServiceInitializeForShellCore() {
LOG_ERROR(Lib_UserService, "(STUBBED) called"); LOG_ERROR(Lib_UserService, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
@ -1102,6 +1105,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetUserName(int user_id, char* user_name, std::si
LOG_ERROR(Lib_UserService, "user_name is null"); LOG_ERROR(Lib_UserService, "user_name is null");
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT; return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
} }
std::string name = "shadPS4"; std::string name = "shadPS4";
auto const* u = UserManagement.GetUserByID(user_id); auto const* u = UserManagement.GetUserByID(user_id);
if (u != nullptr) { if (u != nullptr) {
@ -1109,7 +1113,16 @@ s32 PS4_SYSV_ABI sceUserServiceGetUserName(int user_id, char* user_name, std::si
} else { } else {
LOG_ERROR(Lib_UserService, "No user found"); LOG_ERROR(Lib_UserService, "No user found");
} }
if (size < name.length()) { // once signed in shadnet onlineid is set as username
if (g_shadnet_enabled && Libraries::Np::NpHandler::GetInstance().IsPsnSignedIn(user_id)) {
const auto np_id = Libraries::Np::NpHandler::GetInstance().GetNpId(user_id);
const std::size_t handle_len = strnlen(np_id.handle.data, sizeof(np_id.handle.data));
if (handle_len > 0) {
name.assign(np_id.handle.data, handle_len);
}
}
if (size < name.length() + 1) {
LOG_ERROR(Lib_UserService, "buffer is too short"); LOG_ERROR(Lib_UserService, "buffer is too short");
return ORBIS_USER_SERVICE_ERROR_BUFFER_TOO_SHORT; return ORBIS_USER_SERVICE_ERROR_BUFFER_TOO_SHORT;
} }
@ -2203,6 +2216,7 @@ int PS4_SYSV_ABI Func_D2B814603E7B4477() {
} }
void RegisterLib(Core::Loader::SymbolsResolver* sym) { void RegisterLib(Core::Loader::SymbolsResolver* sym) {
g_shadnet_enabled = EmulatorSettings.IsShadNetEnabled();
LIB_FUNCTION("Psl9mfs3duM", "libSceUserServiceForShellCore", 1, "libSceUserService", LIB_FUNCTION("Psl9mfs3duM", "libSceUserServiceForShellCore", 1, "libSceUserService",
sceUserServiceInitializeForShellCore); sceUserServiceInitializeForShellCore);
LIB_FUNCTION("CydP+QtA0KI", "libSceUserServiceForShellCore", 1, "libSceUserService", LIB_FUNCTION("CydP+QtA0KI", "libSceUserServiceForShellCore", 1, "libSceUserService",