Fix mobj reference management of player->mo

Thanks to toaster
This commit is contained in:
James R 2023-03-20 19:42:07 -07:00
parent cd7d4f23c7
commit d0719ef5ba
3 changed files with 6 additions and 2 deletions

View file

@ -3139,8 +3139,10 @@ void G_DoReborn(INT32 playernum)
if (player->mo)
{
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);

View file

@ -11769,7 +11769,9 @@ void P_SpawnPlayer(INT32 playernum)
p->flashing = K_GetKartFlashing(p); // Babysitting deterrent
mobj = P_SpawnMobj(0, 0, 0, MT_PLAYER);
(mobj->player = p)->mo = mobj;
mobj->player = p;
P_SetTarget(&p->mo, mobj);
mobj->angle = mobj->old_angle = 0;

View file

@ -3643,7 +3643,7 @@ boolean P_SpectatorJoinGame(player_t *player)
if (player->mo)
{
P_RemoveMobj(player->mo);
player->mo = NULL;
P_SetTarget(&player->mo, NULL);
}
player->spectator = false;
player->pflags &= ~PF_WANTSTOJOIN;