diff --git a/src/g_game.c b/src/g_game.c index c2f31a035..59ed90232 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3161,8 +3161,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); diff --git a/src/p_mobj.c b/src/p_mobj.c index 0e5e9fb02..3fe31a7ef 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10476,6 +10476,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // Set shadowscale here, before spawn hook so that Lua can change it P_DefaultMobjShadowScale(mobj); + if (!(mobj->flags & MF_NOTHINK)) + P_AddThinker(THINK_MOBJ, &mobj->thinker); + // DANGER! This can cause P_SpawnMobj to return NULL! // Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks! if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjSpawn))) @@ -10938,9 +10941,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) } } - if (!(mobj->flags & MF_NOTHINK)) - P_AddThinker(THINK_MOBJ, &mobj->thinker); - if (mobj->skin) // correct inadequecies above. { mobj->sprite2 = P_GetSkinSprite2(mobj->skin, (mobj->frame & FF_FRAMEMASK), NULL); @@ -11781,7 +11781,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; diff --git a/src/p_user.c b/src/p_user.c index 7e7e3ef85..98e5b92c2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -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;