From cc967126fe553d204706abd4ab5883d0e372d902 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Sun, 17 Nov 2024 23:58:10 +1100 Subject: [PATCH] feat(p2p): Show p2p port in the config menu with love to my weblate people --- src/config.cpp | 10 ++++++++++ src/config.h | 1 + src/lang/en_US.lang | 1 + src/patches/game_peertopeer.cpp | 2 +- src/patches/game_peertopeer.h | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index 5f3b12a..d7e6ffc 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -20,11 +20,13 @@ #include "wut_extra.h" #include "utils/logger.h" #include "utils/sysconfig.h" +#include "patches/game_peertopeer.h" #include #include #include #include +#include #include #include @@ -32,6 +34,8 @@ #include #include +#include + bool Config::connect_to_network = true; bool Config::need_relaunch = false; bool Config::unregister_task_item_pressed = false; @@ -174,6 +178,12 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa res = network_cat->add(std::move(*connect_item), err); if (!res) return report_error(err); + { + std::string multiplayer_port_text = std::vformat(strings.multiplayer_port_display, std::make_format_args(peertopeer_port())); + res = network_cat->add(WUPSConfigItemStub::Create(multiplayer_port_text), err); + if (!res) return report_error(err); + } + res = root.add(std::move(*network_cat), err); if (!res) return report_error(err); diff --git a/src/config.h b/src/config.h index 2fa9812..51c888b 100644 --- a/src/config.h +++ b/src/config.h @@ -35,6 +35,7 @@ struct config_strings { std::string_view need_menu_action; std::string_view using_nintendo_network; std::string_view using_pretendo_network; + std::string_view multiplayer_port_display; }; config_strings get_config_strings(nn::swkbd::LanguageType language); diff --git a/src/lang/en_US.lang b/src/lang/en_US.lang index a50a37c..ed0e423 100644 --- a/src/lang/en_US.lang +++ b/src/lang/en_US.lang @@ -8,3 +8,4 @@ ,.need_menu_action = "From WiiU menu only" ,.using_nintendo_network = "Using Nintendo Network" ,.using_pretendo_network = "Using Pretendo Network" +,.multiplayer_port_display = "Using UDP port {} for multiplayer" diff --git a/src/patches/game_peertopeer.cpp b/src/patches/game_peertopeer.cpp index e51f2a2..01a6fc6 100644 --- a/src/patches/game_peertopeer.cpp +++ b/src/patches/game_peertopeer.cpp @@ -27,7 +27,7 @@ static inline int digit(char a) { return a - '0'; } -static unsigned short peertopeer_port() { +unsigned short peertopeer_port() { const char * serial = get_console_serial(); unsigned short port = 50000 + diff --git a/src/patches/game_peertopeer.h b/src/patches/game_peertopeer.h index 8211c00..e26862b 100644 --- a/src/patches/game_peertopeer.h +++ b/src/patches/game_peertopeer.h @@ -14,3 +14,4 @@ #pragma once void peertopeer_patch(); +unsigned short peertopeer_port();