Rearranged network's After PSPAction creation/registration so that newer one have higher value to prevent network's callbacks triggering the wrong after action after loading from old save state.

This commit is contained in:
ANR2ME 2020-08-02 08:49:58 +07:00
parent f927ca795c
commit 90ff382c59
3 changed files with 18 additions and 10 deletions

View File

@ -141,10 +141,6 @@ void __NetApctlInit() {
netApctlState = PSP_NET_APCTL_STATE_DISCONNECTED;
apctlHandlers.clear();
memset(&netApctlInfo, 0, sizeof(netApctlInfo));
// Init Apctl Callbacks
apctlThreadHackAddr = __CreateHLELoop(apctlThreadCode, "sceNetApctl", "__NetApctlCallbacks", "apctlThreadHack");
actionAfterApctlMipsCall = __KernelRegisterActionType(AfterApctlMipsCall::Create);
}
static void __ResetInitNetLib() {
@ -155,6 +151,18 @@ static void __ResetInitNetLib() {
memset(&parameter, 0, sizeof(parameter));
}
void __NetCallbackInit() {
// Init Network Callbacks
dummyThreadHackAddr = __CreateHLELoop(dummyThreadCode, "sceNetAdhoc", "__NetTriggerCallbacks", "dummythreadhack");
matchingThreadHackAddr = __CreateHLELoop(matchingThreadCode, "sceNetAdhocMatching", "__NetMatchingCallbacks", "matchingThreadHack");
apctlThreadHackAddr = __CreateHLELoop(apctlThreadCode, "sceNetApctl", "__NetApctlCallbacks", "apctlThreadHack");
// Newer one should be placed last to prevent callbacks going to the wrong after action after loading from old save state
actionAfterMatchingMipsCall = __KernelRegisterActionType(AfterMatchingMipsCall::Create);
actionAfterAdhocMipsCall = __KernelRegisterActionType(AfterAdhocMipsCall::Create);
actionAfterApctlMipsCall = __KernelRegisterActionType(AfterApctlMipsCall::Create);
}
void __NetInit() {
// Windows: Assuming WSAStartup already called beforehand
portOffset = g_Config.iPortOffset;
@ -172,6 +180,7 @@ void __NetInit() {
__ResetInitNetLib();
__NetApctlInit();
__NetCallbackInit();
}
void __NetApctlShutdown() {

View File

@ -199,12 +199,6 @@ void __NetAdhocInit() {
adhocctlHandlers.clear();
__AdhocServerInit();
// Init Adhoc Callbacks
dummyThreadHackAddr = __CreateHLELoop(dummyThreadCode, "sceNetAdhoc", "__NetTriggerCallbacks", "dummythreadhack");
matchingThreadHackAddr = __CreateHLELoop(matchingThreadCode, "sceNetAdhocMatching", "__NetMatchingCallbacks", "matchingThreadHack");
actionAfterMatchingMipsCall = __KernelRegisterActionType(AfterMatchingMipsCall::Create);
actionAfterAdhocMipsCall = __KernelRegisterActionType(AfterAdhocMipsCall::Create);
// Create built-in AdhocServer Thread
if (g_Config.bEnableWlan && g_Config.bEnableAdhocServer) {
adhocServerRunning = true;

View File

@ -55,6 +55,11 @@ extern int adhocEventDelayMS; // This will affect the duration of "Connecting...
extern std::recursive_mutex adhocEvtMtx;
extern int IsAdhocctlInCB;
extern u32 dummyThreadHackAddr;
extern u32_le dummyThreadCode[3];
extern u32 matchingThreadHackAddr;
extern u32_le matchingThreadCode[3];
int NetAdhocMatching_Term();
int NetAdhocctl_Term();
int NetAdhoc_Term();