From be5d651d1e38090cf5e8b17d43a9a92cbdbe17fd Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 2 Sep 2024 05:45:06 -0400 Subject: [PATCH] Don't tie restoring mobj/waypoint pointers on player struct to existence of player object https://git.do.srb2.org/KartKrew/RingRacers/-/commit/b573b6efbc9ad639f031e5299511185c5951e303 --- src/p_saveg.c | 78 ++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 8e214ce73..a292f2572 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3894,7 +3894,6 @@ static void P_NetUnArchiveThinkers(void) // remove all the current thinkers for (i = 0; i < NUM_THINKERLISTS; i++) { - currentthinker = thlist[i].next; for (currentthinker = thlist[i].next; currentthinker != &thlist[i]; currentthinker = next) { next = currentthinker->next; @@ -4238,7 +4237,7 @@ static void P_RelinkPointers(void) { thinker_t *currentthinker; mobj_t *mobj; - UINT32 temp; + UINT32 temp, i; // use info field (value = oldposition) to relink mobjs for (currentthinker = thlist[THINK_MOBJ].next; currentthinker != &thlist[THINK_MOBJ]; @@ -4305,59 +4304,62 @@ static void P_RelinkPointers(void) if (!P_SetTarget(&mobj->terrainOverlay, P_FindNewPosition(temp))) CONS_Debug(DBG_GAMELOGIC, "terrainOverlay not found on %d\n", mobj->type); } - if (mobj->player) + for (i = 0; i < MAXPLAYERS; i++) { - if ( mobj->player->skybox.viewpoint) + if (!playeringame[i]) + continue; + + if ( players[i].skybox.viewpoint) { - temp = (UINT32)(size_t)mobj->player->skybox.viewpoint; - mobj->player->skybox.viewpoint = NULL; - if (!P_SetTarget(&mobj->player->skybox.viewpoint, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "skybox.viewpoint not found on %d\n", mobj->type); + temp = (UINT32)(size_t)players[i].skybox.viewpoint; + players[i].skybox.viewpoint = NULL; + if (!P_SetTarget(&players[i].skybox.viewpoint, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "skybox.viewpoint not found on player %d\n", i); } - if ( mobj->player->skybox.centerpoint) + if ( players[i].skybox.centerpoint) { - temp = (UINT32)(size_t)mobj->player->skybox.centerpoint; - mobj->player->skybox.centerpoint = NULL; - if (!P_SetTarget(&mobj->player->skybox.centerpoint, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "skybox.centerpoint not found on %d\n", mobj->type); + temp = (UINT32)(size_t)players[i].skybox.centerpoint; + players[i].skybox.centerpoint = NULL; + if (!P_SetTarget(&players[i].skybox.centerpoint, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "skybox.centerpoint not found on plyer %d\n", i); } - if ( mobj->player->awayviewmobj) + if ( players[i].awayviewmobj) { - temp = (UINT32)(size_t)mobj->player->awayviewmobj; - mobj->player->awayviewmobj = NULL; - if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); + temp = (UINT32)(size_t)players[i].awayviewmobj; + players[i].awayviewmobj = NULL; + if (!P_SetTarget(&players[i].awayviewmobj, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on player %d\n", i); } - if (mobj->player->followmobj) + if (players[i].followmobj) { - temp = (UINT32)(size_t)mobj->player->followmobj; - mobj->player->followmobj = NULL; - if (!P_SetTarget(&mobj->player->followmobj, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "followmobj not found on %d\n", mobj->type); + temp = (UINT32)(size_t)players[i].followmobj; + players[i].followmobj = NULL; + if (!P_SetTarget(&players[i].followmobj, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "followmobj not found on player %d\n", i); } - if (mobj->player->follower) + if (players[i].follower) { - temp = (UINT32)(size_t)mobj->player->follower; - mobj->player->follower = NULL; - if (!P_SetTarget(&mobj->player->follower, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "follower not found on %d\n", mobj->type); + temp = (UINT32)(size_t)players[i].follower; + players[i].follower = NULL; + if (!P_SetTarget(&players[i].follower, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "follower not found on player %d\n", i); } - if (mobj->player->currentwaypoint) + if (players[i].currentwaypoint) { - temp = (UINT32)(size_t)mobj->player->currentwaypoint; - mobj->player->currentwaypoint = K_GetWaypointFromIndex(temp); - if (mobj->player->currentwaypoint == NULL) + temp = (UINT32)(size_t)players[i].currentwaypoint; + players[i].currentwaypoint = K_GetWaypointFromIndex(temp); + if (players[i].currentwaypoint == NULL) { - CONS_Debug(DBG_GAMELOGIC, "currentwaypoint not found on %d\n", mobj->type); + CONS_Debug(DBG_GAMELOGIC, "currentwaypoint not found on player %d\n", i); } } - if (mobj->player->nextwaypoint) + if (players[i].nextwaypoint) { - temp = (UINT32)(size_t)mobj->player->nextwaypoint; - mobj->player->nextwaypoint = K_GetWaypointFromIndex(temp); - if (mobj->player->nextwaypoint == NULL) + temp = (UINT32)(size_t)players[i].nextwaypoint; + players[i].nextwaypoint = K_GetWaypointFromIndex(temp); + if (players[i].nextwaypoint == NULL) { - CONS_Debug(DBG_GAMELOGIC, "nextwaypoint not found on %d\n", mobj->type); + CONS_Debug(DBG_GAMELOGIC, "nextwaypoint not found on player %d\n", i); } } }