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 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-30 10:15:14 +01:00
1 parent 0d686c1a95
commit d0d6f0f61b
4 files changed
+17 -4

No files matched your search

+4
View File
@@ -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;
+11 -3
View File
@@ -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();
+1
View File
@@ -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