From d675b98330e92035bc14b9589d71f0dc7b009b76 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 17:38:15 +0200 Subject: [PATCH] Revert "Fix mobj reference management of player->mo" This reverts commit c5ec61baa5653029d5c01eeac3faca9ca1ff4538. --- src/g_game.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++-- src/p_mobj.c | 4 +-- src/p_user.c | 2 +- 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c1629af5a..ff459c59a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3072,6 +3072,12 @@ void G_DoReborn(INT32 playernum) player_t *player = &players[playernum]; boolean starpost = false; + /*if (modeattacking) // Not needed for SRB2Kart. + { + M_EndModeAttackRun(); + return; + }*/ + // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); @@ -3085,13 +3091,74 @@ void G_DoReborn(INT32 playernum) oldmo = player->mo; // Don't leave your carcass stuck 10-billion feet in the ground! P_RemoveMobj(player->mo); - P_SetTarget(&player->mo, NULL); } B_RespawnBot(playernum); if (oldmo) G_ChangePlayerReferences(oldmo, players[playernum].mo); } + /*else if (countdowntimeup || (!multiplayer && !modeattacking)) + { + // reload the level from scratch + if (countdowntimeup) + { + player->starpostangle = 0; + player->starposttime = 0; + player->starpostx = 0; + player->starposty = 0; + player->starpostz = 0; + player->starpostnum = 0; + } + if (!countdowntimeup && (mapheaderinfo[gamemap-1]->levelflags & LF_NORELOAD)) + { + INT32 i; + + player->playerstate = PST_REBORN; + + P_LoadThingsOnly(); + + // Do a wipe + wipegamestate = -1; + + if (player->starpostnum) // SRB2kart + starpost = true; + + for (i = 0; i <= splitscreen; i++) + { + if (camera[i].chase) + P_ResetCamera(&players[displayplayers[i]], &camera[i]); + } + + // clear cmd building stuff + memset(gamekeydown, 0, sizeof (gamekeydown)); + for (i = 0;i < JOYAXISSET; i++) + { + joyxmove[i] = joyymove[i] = 0; + joy2xmove[i] = joy2ymove[i] = 0; + joy3xmove[i] = joy3ymove[i] = 0; + joy4xmove[i] = joy4ymove[i] = 0; + } + mousex = mousey = 0; + mouse2x = mouse2y = 0; + + // clear hud messages remains (usually from game startup) + CON_ClearHUD(); + + // Starpost support + G_SpawnPlayer(playernum, starpost); + + if (botingame) + { // Bots respawn next to their master. + players[displayplayers[1]].playerstate = PST_REBORN; + G_SpawnPlayer(displayplayers[1], false); + } + } + else + { + LUAh_MapChange(gamemap); + G_DoLoadLevel(true); + } + }*/ else { // respawn at the start @@ -3108,7 +3175,6 @@ void G_DoReborn(INT32 playernum) oldmo = player->mo; // Don't leave your carcass stuck 10-billion feet in the ground! P_RemoveMobj(player->mo); - P_SetTarget(&player->mo, NULL); } G_SpawnPlayer(playernum, starpost); diff --git a/src/p_mobj.c b/src/p_mobj.c index 37af3777c..a0d80b413 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10597,9 +10597,7 @@ void P_SpawnPlayer(INT32 playernum) mobj = P_SpawnMobj(0, 0, 0, MT_PLAYER); I_Assert(mobj != NULL); - - mobj->player = p; - P_SetTarget(&p->mo, mobj); + (mobj->player = p)->mo = mobj; mobj->angle = 0; diff --git a/src/p_user.c b/src/p_user.c index 60661e4c2..118c1d06d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4025,7 +4025,7 @@ boolean P_SpectatorJoinGame(player_t *player) if (player->mo) { P_RemoveMobj(player->mo); - P_SetTarget(&player->mo, NULL); + player->mo = NULL; } player->spectator = false; player->pflags &= ~PF_WANTSTOJOIN;