From da3c040922dc0611eb9c3ea3b3189bea4c9bc486 Mon Sep 17 00:00:00 2001 From: Logan McNaughton Date: Thu, 29 Oct 2020 07:30:06 -0700 Subject: [PATCH] update core --- mupen64plus-core/src/api/frontend.c | 4 ++++ mupen64plus-core/src/main/main.c | 3 --- mupen64plus-core/src/main/netplay.c | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mupen64plus-core/src/api/frontend.c b/mupen64plus-core/src/api/frontend.c index ce00482..d4e03e3 100644 --- a/mupen64plus-core/src/api/frontend.c +++ b/mupen64plus-core/src/api/frontend.c @@ -359,6 +359,8 @@ EXPORT m64p_error CALL CoreAddCheat(const char *CheatName, m64p_cheat_code *Code { if (!l_CoreInit) return M64ERR_NOT_INIT; + if (netplay_is_init()) + return M64ERR_INVALID_STATE; if (CheatName == NULL || CodeList == NULL) return M64ERR_INPUT_ASSERT; if (strlen(CheatName) < 1 || NumCodes < 1) @@ -374,6 +376,8 @@ EXPORT m64p_error CALL CoreCheatEnabled(const char *CheatName, int Enabled) { if (!l_CoreInit) return M64ERR_NOT_INIT; + if (netplay_is_init()) + return M64ERR_INVALID_STATE; if (CheatName == NULL) return M64ERR_INPUT_ASSERT; diff --git a/mupen64plus-core/src/main/main.c b/mupen64plus-core/src/main/main.c index 5bf3dbd..dc4388c 100644 --- a/mupen64plus-core/src/main/main.c +++ b/mupen64plus-core/src/main/main.c @@ -890,9 +890,6 @@ static void apply_speed_limiter(void) /* TODO: make a GameShark module and move that there */ static void gs_apply_cheats(struct cheat_ctx* ctx) { - if (netplay_is_init()) - return; - struct r4300_core* r4300 = &g_dev.r4300; if (g_gs_vi_counter < 60) diff --git a/mupen64plus-core/src/main/netplay.c b/mupen64plus-core/src/main/netplay.c index 6b3bc2d..33b91eb 100644 --- a/mupen64plus-core/src/main/netplay.c +++ b/mupen64plus-core/src/main/netplay.c @@ -137,6 +137,18 @@ m64p_error netplay_stop() return M64ERR_INVALID_STATE; else { + for (int i = 0; i < 4; ++i) + { + struct netplay_event* current = l_cin_compats[i].event_first; + struct netplay_event* next; + while (current != NULL) + { + next = current->next; + free(current); + current = next; + } + } + char output_data[5]; output_data[0] = TCP_DISCONNECT_NOTICE; SDLNet_Write32(l_reg_id, &output_data[1]);