From 6d99b5d3328cbb1544b52afdf246c65d66aabadb Mon Sep 17 00:00:00 2001 From: Vitor Kiguchi Date: Sat, 5 Jun 2021 18:34:15 -0300 Subject: [PATCH] service/frd: return cfg username on GetMyScreenName as some games apparently use this for the multiplayer display name --- src/core/hle/service/frd/frd.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index bd408420d..1e49a1e8b 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include "common/assert.h" #include "common/logging/log.h" @@ -10,6 +11,7 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/result.h" +#include "core/hle/service/cfg/cfg.h" #include "core/hle/service/frd/frd.h" #include "core/hle/service/frd/frd_a.h" #include "core/hle/service/frd/frd_u.h" @@ -93,16 +95,21 @@ void Module::Interface::GetMyScreenName(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(7, 0); struct ScreenName { - std::array name; + // 20 bytes according to 3dbrew + char16_t name[10]; }; - // TODO: (mailwl) get the name from config - ScreenName screen_name{u"Citra"}; + auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); + ASSERT_MSG(cfg, "CFG Module missing!"); + auto username = cfg->GetUsername(); + ASSERT_MSG(username.length() <= 10, "Username longer than expected!"); + ScreenName screen_name{0}; + std::memcpy(screen_name.name, username.data(), username.length() * sizeof(char16_t)); rb.Push(RESULT_SUCCESS); rb.PushRaw(screen_name); - LOG_WARNING(Service_FRD, "(STUBBED) called"); + LOG_INFO(Service_FRD, "returning the username defined in cfg"); } void Module::Interface::UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx) {