diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index d13d805528..f307275835 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -251,7 +251,7 @@ void __NetDoState(PointerWrap &p) { p.Do(apctlThreadID); } else { - actionAfterApctlMipsCall = 0; + actionAfterApctlMipsCall = -1; apctlThreadHackAddr = 0; apctlThreadID = 0; } @@ -442,6 +442,11 @@ void __NetApctlCallbacks() //if (*error == 0) *newState = netApctlState; + // Since 0 is a valid index to types_ we use -1 to detects if it was loaded from an old save state + if (actionAfterApctlMipsCall < 0) { + actionAfterApctlMipsCall = __KernelRegisterActionType(AfterApctlMipsCall::Create); + } + // Run mipscall. Should we skipped executing the mipscall if oldState == newState? for (std::map::iterator it = apctlHandlers.begin(); it != apctlHandlers.end(); ++it) { DEBUG_LOG(SCENET, "ApctlCallback [ID=%i][OldState=%d][NewState=%d][Event=%d][Error=%d][ArgsPtr=%08x]", it->first, *oldState, *newState, *event, *error, it->second.argument); diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index d0fb2ac203..5f04735661 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -131,7 +131,7 @@ void __NetAdhocDoState(PointerWrap &p) { p.Do(dummyThreadHackAddr); } else { - actionAfterMatchingMipsCall = 0; + actionAfterMatchingMipsCall = -1; dummyThreadHackAddr = 0; } if (s >= 3) { @@ -141,7 +141,7 @@ void __NetAdhocDoState(PointerWrap &p) { p.Do(matchingThreadHackAddr); } else { - actionAfterAdhocMipsCall = 0; + actionAfterAdhocMipsCall = -1; matchingThreadHackAddr = 0; } if (s >= 4) { @@ -3980,6 +3980,10 @@ void __NetTriggerCallbacks() //if (/*__KernelGetCurThread() == threadAdhocID &&*/ (!__IsInInterrupt() && __KernelIsDispatchEnabled() && !__KernelInCallback()) && IsAdhocctlInCallback() == 0) { + // Since 0 is a valid index to types_ we use -1 to detects if it was loaded from an old save state + if (actionAfterAdhocMipsCall < 0) { + actionAfterAdhocMipsCall = __KernelRegisterActionType(AfterAdhocMipsCall::Create); + } for (std::map::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); ++it) { DEBUG_LOG(SCENET, "AdhocctlCallback: [ID=%i][EVENT=%i]", it->first, flags); args[2] = it->second.argument; @@ -4014,6 +4018,9 @@ void __NetMatchingCallbacks() //(int matchingId) //if (/*__KernelGetCurThread() == context->matching_thid &&*/ (!__IsInInterrupt() && __KernelIsDispatchEnabled() && !__KernelInCallback()) /*&& !IsMatchingInCallback(context)*/) { + if (actionAfterMatchingMipsCall < 0) { + actionAfterMatchingMipsCall = __KernelRegisterActionType(AfterMatchingMipsCall::Create); + } DEBUG_LOG(SCENET, "AdhocMatchingCallback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr*)Memory::GetPointer(args[2])).c_str()); AfterMatchingMipsCall* after = (AfterMatchingMipsCall*)__KernelCreateAction(actionAfterMatchingMipsCall); after->SetData(args[0], args[1], args[2]);