From 57b6850ea0f76b6419dd0d2757c544a7fd219bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 22 Jan 2025 11:50:01 +0100 Subject: [PATCH] Pause screen improvements --- Core/HLE/proAdhoc.cpp | 3 +++ Core/HLE/sceNet.cpp | 4 ++++ Core/HLE/sceNet.h | 3 +++ Core/HLE/sceNetInet.cpp | 16 ++++++++++++---- Core/HLE/scePower.cpp | 3 ++- UI/PauseScreen.cpp | 14 ++++++++++++-- UI/PauseScreen.h | 1 + 7 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index b15c01971d..4db5c5854a 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -159,6 +159,9 @@ bool isPTPPortInUse(uint16_t port, bool forListen, SceNetEtherAddr* dstmac, uint std::string ip2str(in_addr in, bool maskPublicIP) { char str[INET_ADDRSTRLEN] = "..."; u8* ipptr = (u8*)∈ +#ifdef _DEBUG + maskPublicIP = false; +#endif if (maskPublicIP && !isPrivateIP(in.s_addr)) snprintf(str, sizeof(str), "%u.%u.xx.%u", ipptr[0], ipptr[1], ipptr[3]); else diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 3d401ba301..0a6483eccd 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -210,10 +210,13 @@ bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) { bool found = false; + std::vector workingIDs; + std::vector ids; if (workingIdsNode) { JsonGet(workingIdsNode->value).getStringVector(&ids); for (auto &id : ids) { + workingIDs.push_back(id); if (id == gameID) { found = true; dns->state = InfraGameState::Working; @@ -248,6 +251,7 @@ bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) { continue; } + dns->workingIDs = workingIDs; dns->gameName = game.getStringOr("name", ""); dns->dns = game.getStringOr("dns", dns->dns.c_str()); dns->dyn_dns = game.getStringOr("dyn_dns", ""); diff --git a/Core/HLE/sceNet.h b/Core/HLE/sceNet.h index 46d35b511d..a9afcc6cb0 100644 --- a/Core/HLE/sceNet.h +++ b/Core/HLE/sceNet.h @@ -161,6 +161,9 @@ struct InfraDNSConfig { std::string revivalTeam; std::string revivalTeamURL; + // PPSSPP can suggest other version of the game if one is known not to work. + std::vector workingIDs; + bool connectAdHocForGrouping; }; diff --git a/Core/HLE/sceNetInet.cpp b/Core/HLE/sceNetInet.cpp index 3d5db7183d..895d6d4763 100644 --- a/Core/HLE/sceNetInet.cpp +++ b/Core/HLE/sceNetInet.cpp @@ -40,7 +40,7 @@ static int UpdateErrnoFromHost(int hostErrno, const char *func) { ERROR_LOG(Log::sceNet, "BAD: errno cleared (previously %s) in %s. Functions should not clear errno.", convertInetErrno2str(g_inetLastErrno), func); g_inetLastErrno = 0; } else if (g_inetLastErrno == newErrno) { - DEBUG_LOG(Log::sceNet, "errno remained %s in %s (host: %d)", convertInetErrno2str(newErrno), func, hostErrno); + VERBOSE_LOG(Log::sceNet, "errno remained %s in %s (host: %d)", convertInetErrno2str(newErrno), func, hostErrno); } else { INFO_LOG(Log::sceNet, "errno set to %s in %s (host: %d)", convertInetErrno2str(newErrno), func, hostErrno); g_inetLastErrno = newErrno; @@ -73,7 +73,11 @@ static int sceNetInetTerm() { } static int sceNetInetGetErrno() { - return hleLogSuccessInfoI(Log::sceNet, g_inetLastErrno, "returning %s at %08x", convertInetErrno2str(g_inetLastErrno), currentMIPS->pc); + if (g_inetLastErrno == ERROR_INET_EAGAIN) { + return hleLogVerbose(Log::sceNet, g_inetLastErrno, "returning %s at %08x", convertInetErrno2str(g_inetLastErrno), currentMIPS->pc); + } else { + return hleLogDebug(Log::sceNet, g_inetLastErrno, "returning %s at %08x", convertInetErrno2str(g_inetLastErrno), currentMIPS->pc); + } } static int sceNetInetGetPspError() { @@ -619,7 +623,7 @@ static int sceNetInetBind(int socket, u32 namePtr, int namelen) { // TODO: Make use Port Offset only for PPSSPP to PPSSPP communications (ie. IP addresses available in the group/friendlist), otherwise should be considered as Online Service thus should use the port as is. //saddr.in.sin_port = htons(ntohs(saddr.in.sin_port) + portOffset); - DEBUG_LOG(Log::sceNet, "Bind: Family = %s, Address = %s, Port = %d", inetSocketDomain2str(saddr.addr.sa_family).c_str(), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port)); + INFO_LOG(Log::sceNet, "sceNetInetBind: Family = %s, Address = %s, Port = %d", inetSocketDomain2str(saddr.addr.sa_family).c_str(), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port)); // Update socket debug metadata inetSock->addr = ip2str(saddr.in.sin_addr); inetSock->port = ntohs(saddr.in.sin_port); @@ -655,7 +659,6 @@ static int sceNetInetConnect(int socket, u32 sockAddrPtr, int sockAddrLen) { } // Still using warn log here so it stands out in the log - WARN_LOG(Log::sceNet, "sceNetInetConnect(%i, %08x, %i) at %08x", socket, sockAddrPtr, sockAddrLen, currentMIPS->pc); SceNetInetSockaddr* dst = (SceNetInetSockaddr*)Memory::GetPointer(sockAddrPtr); SockAddrIN4 saddr{}; @@ -684,6 +687,11 @@ static int sceNetInetConnect(int socket, u32 sockAddrPtr, int sockAddrLen) { } changeBlockingMode(inetSock->sock, 1); + if (saddr.in.sin_port == 53) { + WARN_LOG(Log::G3D, "Game connected to DNS server %s (port 53), likely for doing its own DNS lookups!", ip2str(saddr.in.sin_addr, false).c_str()); + // We should sniff these messages... + } + return hleLogSuccessInfoI(Log::sceNet, retval, "Connect: Address = %s, Port = %d", ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port)); } diff --git a/Core/HLE/scePower.cpp b/Core/HLE/scePower.cpp index 7c324081ce..5e475b8792 100644 --- a/Core/HLE/scePower.cpp +++ b/Core/HLE/scePower.cpp @@ -330,7 +330,8 @@ static int sceKernelVolatileMemTryLock(int type, u32 paddr, u32 psize) { break; case SCE_KERNEL_ERROR_POWER_VMEM_IN_USE: - ERROR_LOG(Log::HLE, "sceKernelVolatileMemTryLock(%i, %08x, %08x) - already locked!", type, paddr, psize); + // This is OK, let's not ERROR_LOG. + DEBUG_LOG(Log::HLE, "sceKernelVolatileMemTryLock(%i, %08x, %08x) - already locked!", type, paddr, psize); break; default: diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index f00e1eb490..2dc2d59364 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -278,15 +278,17 @@ void GamePauseScreen::update() { finishNextFrame_ = false; } - if (g_netInited != lastNetInited_ || netInetInited != lastNetInetInited_ || lastAdhocServerConnected_ != g_adhocServerConnected) { + const bool networkConnected = IsNetworkConnected(); + if (g_netInited != lastNetInited_ || netInetInited != lastNetInetInited_ || lastAdhocServerConnected_ != g_adhocServerConnected || lastOnline_ != networkConnected) { INFO_LOG(Log::sceNet, "Network status changed, recreating views"); RecreateViews(); lastNetInetInited_ = netInetInited; lastNetInited_ = g_netInited; lastAdhocServerConnected_ = g_adhocServerConnected; + lastOnline_ = networkConnected; } - bool mustRunBehind = MustRunBehind(); + const bool mustRunBehind = MustRunBehind(); playButton_->SetVisibility(mustRunBehind ? UI::V_GONE : UI::V_VISIBLE); SetVRAppMode(VRAppMode::VR_MENU_MODE); @@ -394,6 +396,14 @@ void GamePauseScreen::CreateViews() { if (g_infraDNSConfig.state == InfraGameState::NotWorking) { leftColumnItems->Add(new NoticeView(NoticeLevel::WARN, nw->T("Some network functionality in this game is not working"), "")); + if (!g_infraDNSConfig.workingIDs.empty()) { + std::string str(nw->T("Other versions of this game that should work:")); + for (auto &id : g_infraDNSConfig.workingIDs) { + str.append("\n - "); + str += id; + } + leftColumnItems->Add(new TextView(str)); + } } else if (g_infraDNSConfig.state == InfraGameState::Unknown) { leftColumnItems->Add(new NoticeView(NoticeLevel::WARN, nw->T("Network functionality in this game is not guaranteed"), "")); } diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index 835f1f500a..2b753bf23b 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -64,6 +64,7 @@ private: DialogResult finishNextFrameResult_ = DR_CANCEL; UI::Button *playButton_ = nullptr; + bool lastOnline_ = false; bool lastNetInited_ = false; bool lastNetInetInited_ = false; bool lastAdhocServerConnected_ = false;