From 7ee4cf67ea7f813d06495cc5460477cc7e1b103b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Nov 2026 17:03:12 +0100 Subject: [PATCH] Ad hoc: Keep the scan list while connected GetScanInfo returned nothing while in a group. On a PSP the list from the last scan stays after Create, Join and Disconnect, and only a scan attempted while connected empties it (pspautotests net/adhoc/pair/scaninfo, added here along with ptpflush). NBA 2K13's joiner looks for the group it just joined in the list and leaves when it isn't there. Co-Authored-By: Claude Opus 5.5 --- Core/HLE/sceNetAdhoc.cpp | 16 +++++++++------- pspautotests | 2 +- test.py | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index 146534a573..c51e08254d 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -2722,7 +2722,12 @@ int sceNetAdhocctlScan(MIPSState *mips) { // FIXME: When tested with JPCSP + official prx files it seems when adhocctl in a connected state (ie. joined to a group) attempting to create/connect/join/scan will return a success (without doing anything?) if ((adhocctlState == ADHOCCTL_STATE_CONNECTED) || (adhocctlState == ADHOCCTL_STATE_GAMEMODE)) { // Returns 0 and reports ALREADY_CONNECTED through the handlers, as on the PSP (pspautotests - // net/adhoc/adhocctl). Valhalla Knights 2 needs the event. + // net/adhoc/adhocctl). Valhalla Knights 2 needs the event. It empties the scan list + // (pspautotests net/adhoc/pair/scaninfo). + peerlock.lock(); + freeGroupsRecursive(networks); + networks = NULL; + peerlock.unlock(); notifyAdhocctlHandlers(ADHOCCTL_EVENT_ERROR, SCE_NET_ADHOCCTL_ERROR_ALREADY_CONNECTED); hleEatMicro(500); return hleLogDebug(Log::sceNet, 0); @@ -2792,13 +2797,10 @@ int sceNetAdhocctlGetScanInfo(MIPSState *mips, u32 sizeAddr, u32 bufAddr) { // Multithreading Lock peerlock.lock(); - // FIXME: When already connected to a group GetScanInfo will return size = 0 ? or may be only hides the group created by it's self? - if (adhocctlState == ADHOCCTL_STATE_CONNECTED || adhocctlState == ADHOCCTL_STATE_GAMEMODE) { - *buflen = 0; - DEBUG_LOG(Log::sceNet, "NetworkList [Available: 0] Already in a Group"); - } + // The list from the last scan stays after Create, Join and Disconnect (pspautotests + // net/adhoc/pair/scaninfo). NBA 2K13's joiner leaves when the joined group isn't in it. // Length Returner Mode - else if (buf == NULL) { + if (buf == NULL) { int availNetworks = countAvailableNetworks(excludeSelf); *buflen = availNetworks * sizeof(SceNetAdhocctlScanInfoEmu); DEBUG_LOG(Log::sceNet, "NetworkList [Available: %i]", availNetworks); diff --git a/pspautotests b/pspautotests index 54fa9eb4b4..c8bbc21edb 160000 --- a/pspautotests +++ b/pspautotests @@ -1 +1 @@ -Subproject commit 54fa9eb4b4fae3cae436564ed1c8c5e3b790dd63 +Subproject commit c8bbc21edbcd60c2b24090ad764ac351a5b43af1 diff --git a/test.py b/test.py index 2ed515005b..9f12f9f18b 100755 --- a/test.py +++ b/test.py @@ -596,6 +596,7 @@ tests_good = [ "net/adhoc/pair/matchingorder", "net/adhoc/pair/ptpmsg", "net/adhoc/pair/ptppoll", + "net/adhoc/pair/scaninfo", "net/adhoc/pair/vanish", ]