Move the pre-loaded adhoc server address list logic to sceNetAdhoc.cpp

Yes, that file is growing too big...
This commit is contained in:
Henrik Rydgård committed 2026-03-05 10:05:08 +01:00
1 parent 417d51c05f
commit 0d8358827b
7 files changed
+79 -71

No files matched your search

+4
View File
@@ -130,3 +130,7 @@ inline bool isDisconnected(int errcode) { return (errcode == EPIPE || errcode ==
// Default value to 0x00 (do nothing) in systems where it's not supported.
#define MSG_NOSIGNAL 0x00
#endif
#ifdef ERROR
#undef ERROR
#endif
-50
View File
@@ -72,56 +72,6 @@ static const std::string_view logSectionName = "LogDebug";
static const std::string_view logSectionName = "Log";
#endif
const std::vector<AdhocServerListEntry> defaultProAdhocServerList = {
{"Socom Adhoc Server", "socom.cc", "https://discord.com/invite/XtVYDr7", "France", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"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},
{"Relay Brasileiro", "jpa36a7.glddns.com", "https://discord.com/invite/gp45nhdjQJ", "São Paulo Brazil", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"ArenaAnywhere SA", "relay-sa.arenaanywhere.site", "https://discord.gg/MxZrDHmrN", "South Africa", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"ArenaAnywhere EU", "relay.arenaanywhere.site", "https://discord.gg/MxZrDHmrN", "Europe", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"ArenaAnywhere Dubai", "relay-dubai.arenaanywhere.site", "https://discord.gg/MxZrDHmrN", "Dubai", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"Retroverze Relay Beta", "psp.retroverze.my.id", "https://retroverze.my.id/beta", "Unknown", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"Games Nexus", "adhoc.gamesnexus.ovh", "https://adhoc.gamesnexus.ovh", "Milan Italy", "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},
};
// 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<AdhocServerListEntry> 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(const 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 (equals(server, item.hostname)) {
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:
-21
View File
@@ -779,24 +779,3 @@ std::string CreateRandMAC();
// TODO: Find a better place for this.
extern http::RequestManager g_DownloadManager;
extern Config g_Config;
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<AdhocServerListEntry> defaultProAdhocServerList;
extern std::mutex downloadedProAdhocServerListMutex;
extern std::vector<AdhocServerListEntry> downloadedProAdhocServerList;
AdhocDataMode getAdhocServerDataMode(const std::string &server);
+52
View File
@@ -92,6 +92,58 @@ int gameModeNotifyEvent = -1;
#define AEMU_POSTOFFICE_PORT 27313
#define AEMU_POSTOFFICE_ID_BASE 2048
static const char *AdhocDataModeToString(AdhocDataMode mode) {
switch (mode) {
case AdhocDataMode::P2P:
return "AdhocDataMode::P2P";
case AdhocDataMode::AemuPostoffice:
return "AdhocDataMode::AemuPostoffice";
default:
break;
}
return "unknown";
}
const std::vector<AdhocServerListEntry> defaultProAdhocServerList = {
{"Socom Adhoc Server", "socom.cc", "https://discord.com/invite/XtVYDr7", "France", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"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},
{"Relay Brasileiro", "jpa36a7.glddns.com", "https://discord.com/invite/gp45nhdjQJ", "São Paulo Brazil", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"ArenaAnywhere SA", "relay-sa.arenaanywhere.site", "https://discord.gg/MxZrDHmrN", "South Africa", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"ArenaAnywhere EU", "relay.arenaanywhere.site", "https://discord.gg/MxZrDHmrN", "Europe", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"ArenaAnywhere Dubai", "relay-dubai.arenaanywhere.site", "https://discord.gg/MxZrDHmrN", "Dubai", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"Retroverze Relay Beta", "psp.retroverze.my.id", "https://retroverze.my.id/beta", "Unknown", "For players looking to play any games", AdhocDataMode::AemuPostoffice},
{"Games Nexus", "adhoc.gamesnexus.ovh", "https://adhoc.gamesnexus.ovh", "Milan Italy", "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},
};
AdhocDataMode getAdhocServerDataMode(const 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 (equals(server, item.hostname)) {
INFO_LOG(Log::sceNet, "server %s is in known list, using data mode %s", server.c_str(), AdhocDataModeToString(item.mode));
return item.mode;
}
}
INFO_LOG(Log::sceNet, "server %s is not in known list, using data mode %s", server.c_str(), AdhocDataModeToString(AdhocDataMode::P2P));
return AdhocDataMode::P2P;
}
// 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<AdhocServerListEntry> downloadedProAdhocServerList;
int AcceptPtpSocket(int ptpId, int newsocket, sockaddr_in& peeraddr, SceNetEtherAddr* addr, u16_le* port);
int PollAdhocSocket(SceNetAdhocPollSd* sds, int count, int timeout, int nonblock);
int FlushPtpSocket(int socketId);
+21
View File
@@ -18,6 +18,7 @@
#pragma once
#include <deque>
#include <string>
#include "Core/HLE/proAdhoc.h"
#ifdef _MSC_VER
@@ -97,6 +98,26 @@ enum AdhocDiscoverResult : int
NET_ADHOC_DISCOVER_RESULT_ABORTED = 3, // Internal Error occured?
};
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<AdhocServerListEntry> defaultProAdhocServerList;
extern std::mutex downloadedProAdhocServerListMutex;
extern std::vector<AdhocServerListEntry> downloadedProAdhocServerList;
AdhocDataMode getAdhocServerDataMode(const std::string &server);
class PointerWrap;
+1
View File
@@ -3,6 +3,7 @@
#include "Common/Net/Resolve.h"
#include "Common/UI/Root.h"
#include "Common/StringUtils.h"
#include "Core/HLE/sceNetAdhoc.h"
AdhocServerScreen::AdhocServerScreen(std::string *value, std::string_view title)
: UI::PopupScreen(title, T(I18NCat::DIALOG, "OK"), T(I18NCat::DIALOG, "Cancel")), value_(value) {
+1
View File
@@ -9,6 +9,7 @@
#include "Common/UI/PopupScreens.h"
#include "Core/Config.h" // for AdhocServerListEntry!
#include "Common/UI/Notice.h"
#include "Core/HLE/sceNetAdhoc.h"
class AdhocServerScreen : public UI::PopupScreen {
public: