From b3b9e9040354fc597ccca55fb8ebf98279241b28 Mon Sep 17 00:00:00 2001 From: Katharine Chui Date: Wed, 18 Feb 2026 16:32:49 +0100 Subject: [PATCH] expand adhoc server list Add various data fields and logic to handle: - automatic adhoc data mode handling - future UI expension on server list - future support for automatically downloaded/user provided server list --- Core/Config.cpp | 46 ++++++++++++++++++++++++++++++++++++--- Core/Config.h | 21 +++++++++++++++++- Core/HLE/sceNetAdhoc.cpp | 17 +++++++++------ UI/GameSettingsScreen.cpp | 13 ++++++++--- UI/GameSettingsScreen.h | 5 +++-- 5 files changed, 86 insertions(+), 16 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index cf0c90473e..d3bdd104b3 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -72,10 +72,51 @@ static const std::string_view logSectionName = "LogDebug"; static const std::string_view logSectionName = "Log"; #endif -const std::vector defaultProAdhocServerList = { - "socom.cc", "psp.gameplayer.club", // TODO: Add some saved recent history too? +const std::vector defaultProAdhocServerList = { + {"Socom Adhoc Server", "socom.cc", "https://discord.com/invite/XtVYDr7", "France", "For players looking to play any games", AdhocDataMode::AemuPostoffice}, + {"Sony PSP & PSVita Fans", "psp.gameplayer.club", "https://psp.gameplayer.club/", "Unknown", "For players looking to play any games", AdhocDataMode::P2P}, + {"Madness Gaming Network", "psp.mgn.pub", "https://discord.com/invite/kaPScVrPes", "Alaska USA", "For players looking to play any games, has a good amount of Monster Hunter players, also provides VPN to work around connection issues as well as P2P mode", AdhocDataMode::AemuPostoffice}, + {"EA Nation Hub", "eahub.eu", "https://discord.com/invite/fwrQHHxrQQ", "France", "Mostly for Medal of Honor Heros 2 & Need For Speed Most Wanted players, but can be used for other games", AdhocDataMode::AemuPostoffice}, + {"Psi-Hate", "psi-hate.com", "https://discord.com/invite/wxeGVkM", "Minnesota USA", "For players looking to play any games", AdhocDataMode::AemuPostoffice}, + {"AlexGHD", "jpa36a7.glddns.com", "https://discord.com/invite/gp45nhdjQJ", "São Paulo Brazil", "For players looking to play any games", AdhocDataMode::AemuPostoffice}, }; +// TODO download the list from somewhere and probably cache it on disk +// should also make the url configurable and support file:/ local list besides https:// online lists +std::mutex downloadedProAdhocServerListMutex; +std::vector downloadedProAdhocServerList; + +static const char *get_data_mode_string(AdhocDataMode mode) { + switch(mode) { + case AdhocDataMode::P2P: + return "AdhocDataMode::P2P"; + case AdhocDataMode::AemuPostoffice: + return "AdhocDataMode::AemuPostoffice"; + } + return "unknown"; +} + +AdhocDataMode getAdhocServerDataMode(std::string &server) { + auto list = defaultProAdhocServerList; + + downloadedProAdhocServerListMutex.lock(); + if (downloadedProAdhocServerList.size() != 0) { + INFO_LOG(Log::sceNet, "Using downloaded adhoc server list"); + list = downloadedProAdhocServerList; + } + downloadedProAdhocServerListMutex.unlock(); + + for (const auto &item : list) { + if (strcmp(server.c_str(), item.hostname.c_str()) == 0) { + INFO_LOG(Log::sceNet, "server %s is in known list, using data mode %s", server.c_str(), get_data_mode_string(item.mode)); + return item.mode; + } + } + + INFO_LOG(Log::sceNet, "server %s is not in known list, using data mode %s", server.c_str(), get_data_mode_string(AdhocDataMode::P2P)); + return AdhocDataMode::P2P; +} + std::string GPUBackendToString(GPUBackend backend) { switch (backend) { case GPUBackend::OPENGL: @@ -1035,7 +1076,6 @@ static const ConfigSetting networkSettings[] = { ConfigSetting("EnableAdhocServer", SETTING(g_Config, bEnableAdhocServer), false, CfgFlag::PER_GAME), ConfigSetting("proAdhocServer", SETTING(g_Config, sProAdhocServer), "socom.cc", CfgFlag::PER_GAME), ConfigSetting("AdhocServerRelayMode", SETTING(g_Config, iAdhocServerRelayMode), (int)AdhocServerRelayMode::Auto, CfgFlag::PER_GAME), - ConfigSetting("proAdhocServerList", SETTING(g_Config, proAdhocServerList), &defaultProAdhocServerList, CfgFlag::DEFAULT), ConfigSetting("PortOffset", SETTING(g_Config, iPortOffset), 10000, CfgFlag::PER_GAME), ConfigSetting("PrimaryDNSServer", SETTING(g_Config, sInfrastructureDNSServer), "67.222.156.250", CfgFlag::PER_GAME), ConfigSetting("MinTimeout", SETTING(g_Config, iMinTimeout), 0, CfgFlag::PER_GAME), diff --git a/Core/Config.h b/Core/Config.h index a6e553298e..f7a67dc372 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -21,6 +21,7 @@ #include #include #include +#include #include "ppsspp_config.h" @@ -779,5 +780,23 @@ std::string CreateRandMAC(); extern http::RequestManager g_DownloadManager; extern Config g_Config; -extern const std::vector defaultProAdhocServerList; +enum class AdhocDataMode { + P2P = 0, + AemuPostoffice, +}; +struct AdhocServerListEntry{ + std::string name = ""; + std::string hostname = ""; + std::string community_link = ""; + std::string location = ""; + std::string note = ""; + AdhocDataMode mode = AdhocDataMode::P2P; +}; + +extern const std::vector defaultProAdhocServerList; + +extern std::mutex downloadedProAdhocServerListMutex; +extern std::vector downloadedProAdhocServerList; + +AdhocDataMode getAdhocServerDataMode(std::string &server); diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index 2f8c3d0b60..e8b196b7d6 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -1649,16 +1649,12 @@ u32 sceNetAdhocInit() { // Since we are deleting GameMode Master here, we should probably need to make sure GameMode resources all cleared too. deleteAllGMB(); - // If a server is in our default list, we know it supports relay. switch ((AdhocServerRelayMode)g_Config.iAdhocServerRelayMode) { case AdhocServerRelayMode::Auto: serverHasRelay = false; - // If it's in our default server list, we know it supports relay. - for (auto serverName : defaultProAdhocServerList) { - if (serverName == g_Config.sProAdhocServer) { - serverHasRelay = true; - break; - } + // Fetch data mode from server list + if (getAdhocServerDataMode(g_Config.sProAdhocServer) == AdhocDataMode::AemuPostoffice) { + serverHasRelay = true; } break; case AdhocServerRelayMode::AlwaysOn: @@ -1673,6 +1669,13 @@ u32 sceNetAdhocInit() { aemu_post_office_init(); } + auto n = GetI18NCategory(I18NCat::NETWORKING); + if (serverHasRelay) { + g_OSD.Show(OSDType::MESSAGE_INFO, n->T("Started adhoc networking in relay mode"), 0.0f, "adhoc started in relay mode"); + } else { + g_OSD.Show(OSDType::MESSAGE_INFO, n->T("Started adhoc networking in P2P mode"), 0.0f, "adhoc started in P2P mode"); + } + // Return Success return hleLogInfo(Log::sceNet, 0, "at %08x", currentMIPS->pc); } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 9069a94d26..e5af231ccc 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1058,7 +1058,13 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti networkingSettings->Add(new ItemHeader(n->T("Ad Hoc server"))); networkingSettings->Add(new CheckBox(&g_Config.bEnableAdhocServer, n->T("Enable built-in PRO Adhoc Server", "Enable built-in PRO Adhoc Server"))); networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sProAdhocServer, n->T("Change proAdhocServer Address"), I18NCat::NONE))->OnClick.Add([=](UI::EventParams &) { - screenManager()->push(new HostnameSelectScreen(&g_Config.sProAdhocServer, &g_Config.proAdhocServerList, n->T("proAdhocServer Address:"))); + auto list_to_use = defaultProAdhocServerList; + downloadedProAdhocServerListMutex.lock(); + if (downloadedProAdhocServerList.size() != 0) { + list_to_use = downloadedProAdhocServerList; + } + downloadedProAdhocServerListMutex.unlock(); + screenManager()->push(new HostnameSelectScreen(&g_Config.sProAdhocServer, list_to_use, n->T("proAdhocServer Address:"))); }); networkingSettings->Add(new SettingHint(n->T("Change proAdhocServer address hint"))); @@ -1879,9 +1885,10 @@ void HostnameSelectScreen::CreatePopupContents(UI::ViewGroup *parent) { buttonsRow2->Add(new Spacer(new LinearLayoutParams(1.0, Gravity::G_RIGHT))); std::vector listIP; - if (listItems_) { - listIP = *listItems_; + for (const auto &item : listItems_) { + listIP.push_back(item.hostname); } + // Add non-editable items listIP.push_back("localhost"); net::GetLocalIP4List(listIP); diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index c97cd106d8..67d36c1a5b 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -27,6 +27,7 @@ #include "Core/ConfigValues.h" #include "UI/BaseScreens.h" #include "UI/TabbedDialogScreen.h" +#include "Core/Config.h" class Path; @@ -114,7 +115,7 @@ private: class HostnameSelectScreen : public UI::PopupScreen { public: - HostnameSelectScreen(std::string *value, std::vector *listItems, std::string_view title) + HostnameSelectScreen(std::string *value, std::vector &listItems, std::string_view title) : UI::PopupScreen(title, T(I18NCat::DIALOG, "OK"), T(I18NCat::DIALOG, "Cancel")), listItems_(listItems), value_(value) { resolver_ = std::thread([](HostnameSelectScreen *thiz) { thiz->ResolverThread(); @@ -158,7 +159,7 @@ private: }; std::string *value_; - std::vector *listItems_; + std::vector listItems_; UI::TextEdit *addrView_ = nullptr; UI::TextView *progressView_ = nullptr; UI::LinearLayout *ipRows_ = nullptr;