sceNetAdhocMatching: Start returns 0, not the matching thread's ID

The fake matching thread was started through sceKernelStartThread,
which switched threads inside the call, and the game got the new
thread's ID back. On a PSP, Start returns 0 (pspautotests
net/adhoc/matching). Create and start it like adhocctl's thread instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 authored and Henrik Rydgård committed 2026-10-29 22:39:05 +01:00
1 parent ae906cb292
commit ce81c07a69
1 file changed
+5 -2
+5 -2
View File
@@ -1925,10 +1925,13 @@ int NetAdhocMatching_Start(int matchingId, int evthPri, int evthPartitionId, int
// Create & Start the Fake PSP Thread ("matching_ev%d" and "matching_io%d")
netAdhocMatchingValidateLoopMemory();
std::string thrname = std::string("MatchingThr") + std::to_string(matchingId);
matchingThreads[item->matching_thid] = hleCall(ThreadManForUser, int, sceKernelCreateThread, thrname.c_str(), matchingThreadHackAddr, evthPri, evthStack, 0, 0);
// Created and started without rescheduling, like adhocctl's thread: starting it through
// sceKernelStartThread switched threads inside this call, and the game got the thread's ID back
// instead of 0 (pspautotests net/adhoc/matching).
matchingThreads[item->matching_thid] = __KernelCreateThread(thrname.c_str(), __KernelGetCurThreadModuleId(), matchingThreadHackAddr, evthPri, evthStack, PSP_THREAD_ATTR_USER, 0, true);
//item->matchingThread = new HLEHelperThread(thrname.c_str(), "sceNetAdhocMatching", "__NetMatchingCallbacks", inthPri, inthStack);
if (matchingThreads[item->matching_thid] > 0) {
hleCall(ThreadManForUser, int, sceKernelStartThread, matchingThreads[item->matching_thid], 0, 0); //sceKernelStartThread(context->event_thid, sizeof(context), &context);
__KernelStartThread(matchingThreads[item->matching_thid], 0, 0);
//item->matchingThread->Start(matchingId, 0);
}