Remove the Network Connected/Shutdown popups. Replace with more info on pause screen

This commit is contained in:
Henrik Rydgård committed 2025-01-21 18:07:52 +01:00
1 parent 5ffd9a2d72
commit a710faf27b
5 files changed
+69 -56

No files matched your search

+11
View File
@@ -2437,3 +2437,14 @@ const char* getMatchingOpcodeStr(int code) {
return buf;
}
const char *AdhocCtlStateToString(int state) {
switch (state) {
case ADHOCCTL_STATE_DISCONNECTED: return "DISCONNECTED";
case ADHOCCTL_STATE_CONNECTED: return "CONNECTED";
case ADHOCCTL_STATE_SCANNING: return "SCANNING";
case ADHOCCTL_STATE_GAMEMODE: return "GAMEMODE";
case ADHOCCTL_STATE_DISCOVER: return "DISCOVER";
case ADHOCCTL_STATE_WOL: return "WOL";
default: return "(unk)";
}
}
+3
View File
@@ -1412,3 +1412,6 @@ const char* getMatchingEventStr(int code);
// Convert Matching Opcode ID to String
const char* getMatchingOpcodeStr(int code);
// Convert adhoc ctl state to string
const char *AdhocCtlStateToString(int state);
+47 -53
View File
@@ -276,6 +276,52 @@ bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) {
return true;
}
void LoadAutoDNS() {
if (!g_Config.bInfrastructureAutoDNS) {
return;
}
// Load the automatic DNS config for this game - or the defaults.
std::string discID = g_paramSFO.GetDiscID();
LoadDNSForGameID(discID, &g_infraDNSConfig);
// If dyn_dns is non-empty, try to use it to replace the specified DNS.
// If fails, we just use the dns. TODO: Do this in the background somehow...
const auto &dns = g_infraDNSConfig.dns;
const auto &dyn_dns = g_infraDNSConfig.dyn_dns;
if (!dyn_dns.empty()) {
// Try to look it up in system DNS
INFO_LOG(Log::sceNet, "DynDNS requested, trying to resolve '%s'...", dyn_dns.c_str());
addrinfo *resolved = nullptr;
std::string err;
if (!net::DNSResolve(dyn_dns, "", &resolved, err)) {
ERROR_LOG(Log::sceNet, "Error resolving, falling back to '%s'", dns.c_str());
} else if (resolved) {
bool found = false;
for (auto ptr = resolved; ptr && !found; ptr = ptr->ai_next) {
switch (ptr->ai_family) {
case AF_INET:
{
char ipstr[256];
if (inet_ntop(ptr->ai_family, &(((struct sockaddr_in*)ptr->ai_addr)->sin_addr), ipstr, sizeof(ipstr)) != 0) {
INFO_LOG(Log::sceNet, "Successfully resolved '%s' to '%s', overriding DNS.", dyn_dns.c_str(), ipstr);
if (g_infraDNSConfig.dns != ipstr) {
WARN_LOG(Log::sceNet, "Replacing specified DNS IP %s with dyndns %s!", g_infraDNSConfig.dns.c_str(), ipstr);
g_infraDNSConfig.dns = ipstr;
} else {
INFO_LOG(Log::sceNet, "DynDNS: %s already up to date", g_infraDNSConfig.dns.c_str());
}
found = true;
}
break;
}
}
}
net::DNSResolveFree(resolved);
}
}
}
void InitLocalhostIP() {
// The entire 127.*.*.* is reserved for loopback.
uint32_t localIP = 0x7F000001 + PPSSPP_ID - 1;
@@ -707,7 +753,6 @@ u32 Net_Term() {
static u32 sceNetTerm() {
auto n = GetI18NCategory(I18NCat::NETWORKING);
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("Network shutdown"), 2.0, "networkinit");
int retval = Net_Term();
@@ -771,63 +816,12 @@ static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netini
// Clear Socket Translator Memory
memset(&adhocSockets, 0, sizeof(adhocSockets));
if (g_Config.bInfrastructureAutoDNS) {
// Load the automatic DNS config for this game - or the defaults.
std::string discID = g_paramSFO.GetDiscID();
LoadDNSForGameID(discID, &g_infraDNSConfig);
// If dyn_dns is non-empty, try to use it to replace the specified DNS.
// If fails, we just use the dns. TODO: Do this in the background somehow...
const auto &dns = g_infraDNSConfig.dns;
const auto &dyn_dns = g_infraDNSConfig.dyn_dns;
if (!dyn_dns.empty()) {
// Try to look it up in system DNS
INFO_LOG(Log::sceNet, "DynDNS requested, trying to resolve '%s'...", dyn_dns.c_str());
addrinfo *resolved = nullptr;
std::string err;
if (!net::DNSResolve(dyn_dns, "", &resolved, err)) {
ERROR_LOG(Log::sceNet, "Error resolving, falling back to '%s'", dns.c_str());
} else if (resolved) {
bool found = false;
for (auto ptr = resolved; ptr && !found; ptr = ptr->ai_next) {
switch (ptr->ai_family) {
case AF_INET:
{
char ipstr[256];
if (inet_ntop(ptr->ai_family, &(((struct sockaddr_in*)ptr->ai_addr)->sin_addr), ipstr, sizeof(ipstr)) != 0) {
INFO_LOG(Log::sceNet, "Successfully resolved '%s' to '%s', overriding DNS.", dyn_dns.c_str(), ipstr);
if (g_infraDNSConfig.dns != ipstr) {
WARN_LOG(Log::sceNet, "Replacing specified DNS IP %s with dyndns %s!", g_infraDNSConfig.dns.c_str(), ipstr);
g_infraDNSConfig.dns = ipstr;
} else {
INFO_LOG(Log::sceNet, "DynDNS: %s already up to date", g_infraDNSConfig.dns.c_str());
}
found = true;
}
break;
}
}
}
net::DNSResolveFree(resolved);
}
}
}
LoadAutoDNS();
g_netInited = true;
auto n = GetI18NCategory(I18NCat::NETWORKING);
std::string msg(n->T("Network initialized"));
if (!msg.empty()) {
if (g_Config.bInfrastructureAutoDNS) {
msg += ": ";
msg += n->T("Auto DNS");
if (!g_infraDNSConfig.gameName.empty()) {
msg += " (" + g_infraDNSConfig.gameName + ")";
}
}
g_OSD.Show(OSDType::MESSAGE_INFO, msg, 2.0, "networkinit");
}
return hleLogSuccessI(Log::sceNet, 0);
}
+2
View File
@@ -545,6 +545,7 @@ static void DrawApctl(ImConfig &cfg) {
ImGui::End();
}
static void DrawAdhoc(ImConfig &cfg) {
if (!ImGui::Begin("AdHoc", &cfg.adhocOpen)) {
ImGui::End();
@@ -571,6 +572,7 @@ static void DrawAdhoc(ImConfig &cfg) {
ImGui::Text("sceNetAdhoc inited: %s", BoolStr(netAdhocInited));
ImGui::Text("sceNetAdhoc inited: %s", BoolStr(netAdhocInited));
ImGui::Text("sceNetAdhocctl inited: %s", BoolStr(netAdhocctlInited));
ImGui::Text("sceNetAdhocctl state: %s", AdhocCtlStateToString(NetAdhocctl_GetState()));
ImGui::Text("sceNetAdhocMatching inited: %s", BoolStr(netAdhocctlInited));
ImGui::Text("GameMode entered: %s", BoolStr(netAdhocGameModeEntered));
ImGui::Text("FriendFinder running: %s", BoolStr(g_adhocServerConnected));
+6 -3
View File
@@ -389,13 +389,15 @@ void GamePauseScreen::CreateViews() {
if (IsNetworkConnected()) {
leftColumnItems->Add(new NoticeView(NoticeLevel::INFO, nw->T("Network connected"), ""));
if (g_infraDNSConfig.loaded) {
if (g_infraDNSConfig.loaded && __NetApctlConnected()) {
leftColumnItems->Add(new NoticeView(NoticeLevel::INFO, nw->T("Infrastructure"), ""));
if (g_infraDNSConfig.state == InfraGameState::NotWorking) {
leftColumnItems->Add(new NoticeView(NoticeLevel::WARN, nw->T("Some network functionality in this game is not working"), ""));
} else if (g_infraDNSConfig.state == InfraGameState::Unknown) {
leftColumnItems->Add(new NoticeView(NoticeLevel::WARN, nw->T("Network functionality in this game is not guaranteed"), ""));
}
if (!g_infraDNSConfig.revivalTeam.empty() && netInetInited) {
if (!g_infraDNSConfig.revivalTeam.empty()) {
leftColumnItems->Add(new TextView(std::string(nw->T("Infrastructure Mode server by")) + ":"));
leftColumnItems->Add(new TextView(g_infraDNSConfig.revivalTeam));
if (!g_infraDNSConfig.revivalTeamURL.empty()) {
@@ -409,7 +411,8 @@ void GamePauseScreen::CreateViews() {
}
}
if (g_adhocServerConnected) {
if (NetAdhocctl_GetState() >= ADHOCCTL_STATE_CONNECTED) {
// Awkwardly re-using a string here
leftColumnItems->Add(new TextView(std::string(nw->T("AdHoc Server")) + ": " + std::string(nw->T("Connected"))));
}
}