From d0d6f0f61b91811b7baf4e1eef7c1a5c8049ecea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 29 Oct 2026 16:49:07 +0100 Subject: [PATCH] sceNetAdhocMatching: A child lists its parent first after a keepalive - Fixes #22331 A child's GetMembers starts with itself, then switches to the parent first one keepalive interval after it was accepted (net/adhoc/pair/matchingorder, recorded on two PSPs). We kept it self first. Bomberman's client checks that the first member is the host before it marks itself ready, so its lobby stayed empty and the host's start failed with "failed to connect to the game". Co-Authored-By: Claude Opus 5.5 --- Core/HLE/proAdhoc.h | 4 ++++ Core/HLE/sceNetAdhocMatching.cpp | 14 +++++++++++--- pspautotests | 2 +- test.py | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Core/HLE/proAdhoc.h b/Core/HLE/proAdhoc.h index 28be1d4e66..617eb75f78 100644 --- a/Core/HLE/proAdhoc.h +++ b/Core/HLE/proAdhoc.h @@ -507,6 +507,10 @@ typedef struct SceNetAdhocMatchingContext { // Timeout u64_le timeout; + // Child: when GetMembers starts listing the parent first, one keepalive interval after being accepted + // (pspautotests net/adhoc/pair/matchingorder). 0 until accepted. + u64 parentFirstAt = 0; + // Helper Thread (fake PSP Thread) needed to execute callback //HLEHelperThread *matchingThread; int matching_thid; diff --git a/Core/HLE/sceNetAdhocMatching.cpp b/Core/HLE/sceNetAdhocMatching.cpp index 21d55ddb1a..00a8f46108 100644 --- a/Core/HLE/sceNetAdhocMatching.cpp +++ b/Core/HLE/sceNetAdhocMatching.cpp @@ -850,6 +850,7 @@ void actOnAcceptPacket(SceNetAdhocMatchingContext * context, SceNetEtherAddr * s // Add Self Peer to the following position (using peer->state = 0 to identify as Self) addMember(context, &context->mac); + context->parentFirstAt = CoreTiming::GetGlobalTimeUsScaled() + context->keepalive_int; } // Spawn Accept Event @@ -2422,8 +2423,11 @@ static int sceNetAdhocMatchingGetMembers(int matchingId, u32 sizeAddr, u32 buf) int filledpeers = 0; if (requestedpeers > 0) { - // The console itself comes first, also for a client (pspautotests net/adhoc/pair/matching) - { + // The console itself comes first, also for a child until a keepalive interval after it was + // accepted. Then the parent does, and the child is listed among the siblings + // (pspautotests net/adhoc/pair/matching, net/adhoc/pair/matchingorder). + bool parentFirst = context->mode == PSP_ADHOC_MATCHING_MODE_CHILD && context->parentFirstAt != 0 && CoreTiming::GetGlobalTimeUsScaled() >= context->parentFirstAt && findParent(context) != NULL; + if (!parentFirst) { // Add Local MAC buf2[filledpeers++].mac_addr = context->mac; @@ -2512,8 +2516,12 @@ static int sceNetAdhocMatchingGetMembers(int matchingId, u32 sizeAddr, u32 buf) buf2[filledpeers++].mac_addr = peer->mac; DEBUG_LOG(Log::sceNet, "MemberSibling [%s]", mac2str(&peer->mac).c_str()); - } + } else if (parentFirst && peer->state == 0) { + // Self Peer + buf2[filledpeers++].mac_addr = peer->mac; + DEBUG_LOG(Log::sceNet, "MemberSelf [%s]", mac2str(&peer->mac).c_str()); + } } } sortedPeers.clear(); diff --git a/pspautotests b/pspautotests index 7f918e6b2f..8d093e7e67 160000 --- a/pspautotests +++ b/pspautotests @@ -1 +1 @@ -Subproject commit 7f918e6b2f9e9d289b864c010fa1fdb796319fa3 +Subproject commit 8d093e7e67c65f5076913d0d09de2c34873b4679 diff --git a/test.py b/test.py index 6983b05cba..415c5c7e72 100755 --- a/test.py +++ b/test.py @@ -697,6 +697,7 @@ tests_next = [ "net/adhoc/pair/matching", "net/adhoc/pair/matching2", "net/adhoc/pair/matching3", + "net/adhoc/pair/matchingorder", "net/adhoc/pair/vanish", "sysmem/partition", # These two mbx tests only appeared to work because they papered over bugs