From 20d9d48483a0b6d6234acb17552da259f879a9c3 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 18 May 2023 19:15:00 -0700 Subject: [PATCH] Destroy parties explicitly before building This removes a call to G_DestroyParty from CL_ClearPlayer. The problem with calling it from there is that the consoleplayer of a splitscreen is removed first, the local party is cleared. Then G_LeaveParty assert fails when the next splitscreen player is removed because the console's party was already cleared. --- src/d_clisrv.c | 3 ++- src/g_party.cpp | 7 ++++++- src/p_saveg.c | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6de772b50..e20c6d442 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2794,7 +2794,6 @@ void CL_ClearPlayer(INT32 playernum) splitscreen_invitations[playernum] = -1; playerconsole[playernum] = playernum; - G_DestroyParty(playernum); // Wipe the struct. memset(&players[playernum], 0, sizeof (player_t)); @@ -3876,6 +3875,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) { // Clear player before joining, lest some things get set incorrectly CL_ClearPlayer(newplayernum); + G_DestroyParty(newplayernum); playeringame[newplayernum] = true; G_AddPlayer(newplayernum); @@ -4018,6 +4018,7 @@ static void Got_AddBot(UINT8 **p, INT32 playernum) // Clear player before joining, lest some things get set incorrectly CL_ClearPlayer(newplayernum); + G_DestroyParty(newplayernum); playeringame[newplayernum] = true; G_AddPlayer(newplayernum); diff --git a/src/g_party.cpp b/src/g_party.cpp index 1c82a2d1d..2b72d49f0 100644 --- a/src/g_party.cpp +++ b/src/g_party.cpp @@ -186,6 +186,11 @@ public: // consoleplayer. Party& operator [](Party::Console console) { return pool_[console]; } + // Clears a single player's local party. This method + // accesses the playernum directly, instead of the + // consoleplayer. + void reset(playernum_t player) { pool_[player] = {}; } + protected: std::array pool_; } @@ -271,7 +276,7 @@ void G_ObliterateParties(void) void G_DestroyParty(UINT8 player) { - local_party[player] = {}; + local_party.reset(player); final_party[player] = {}; } diff --git a/src/p_saveg.c b/src/p_saveg.c index 70ccf1624..16073ac06 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -944,6 +944,7 @@ static void P_NetUnArchiveParties(savebuffer_t *save) if (!playeringame[i]) continue; + G_DestroyParty(i); G_BuildLocalSplitscreenParty(i); }