diff --git a/src/k_kart.c b/src/k_kart.c index 81a2bd4bc..63a2a6673 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7891,7 +7891,23 @@ static boolean K_SetPlayerNextWaypoint(player_t *player) continue; } - bestwaypoint = waypoint->prevwaypoints[i]; + if ((waypoint->nextwaypoints != NULL) && (waypoint->numnextwaypoints > 0U)) + { + for (size_t j = 0U; j < waypoint->numnextwaypoints; j++) + { + if (!K_GetWaypointIsEnabled(waypoint->nextwaypoints[j])) + { + continue; + } + + if (waypoint->nextwaypoints[j] == waypoint)\ + { + continue; + } + + bestwaypoint = waypoint->nextwaypoints[j]; + } + } nextbestdelta = angledelta; nextbestmomdelta = momdelta; @@ -8207,12 +8223,14 @@ static void K_UpdatePlayerWaypoints(player_t *const player) } else { + mobj_t *currentwaypoint = player->currentwaypoint->mobj; mobj_t *safewaypoint = player->nextwaypoint->mobj; + angle_t respawnangle = R_PointToAngle2(currentwaypoint->x, currentwaypoint->y, safewaypoint->x, safewaypoint->y); player->starposttime = player->realtime; player->starpostz = safewaypoint->spawnpoint->z >> FRACBITS; player->starpostflip = (safewaypoint->flags2 & MF2_OBJECTFLIP); - player->starpostangle = safewaypoint->spawnpoint ? FixedAngle(safewaypoint->spawnpoint->angle * FRACUNIT) : player->mo->angle; + player->starpostangle = respawnangle; // Then do x and y player->starpostx = safewaypoint->x >> FRACBITS; diff --git a/src/p_mobj.c b/src/p_mobj.c index ef02fc917..cc2ad1b8d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6322,6 +6322,28 @@ static boolean P_MobjDeadThink(mobj_t *mobj) { case MT_PLAYER: /// \todo Have the player's dead body completely finish its animation even if they've already respawned. + + if (mobj->player) + { + // Set players next respawn point to the next waypoint + // If they die while still in respawn state for extra safety. + if (mobj->player->nextwaypoint && mobj->player->respawn > 0) + { + mobj_t *currentwaypoint = mobj->player->currentwaypoint->mobj; + mobj_t *safewaypoint = mobj->player->nextwaypoint->mobj; + angle_t respawnangle = R_PointToAngle2(currentwaypoint->x, currentwaypoint->y, safewaypoint->x, safewaypoint->y); + + mobj->player->starposttime = mobj->player->realtime; + mobj->player->starpostz = safewaypoint->spawnpoint->z >> FRACBITS; + mobj->player->starpostflip = (safewaypoint->flags2 & MF2_OBJECTFLIP); + mobj->player->starpostangle = respawnangle; + + // Then do x and y + mobj->player->starpostx = safewaypoint->x >> FRACBITS; + mobj->player->starposty = safewaypoint->y >> FRACBITS; + } + } + if (!mobj->fuse) { // Go away. /// \todo Actually go ahead and remove mobj completely, and fix any bugs and crashes doing this creates. Chasecam should stop moving, and F12 should never return to it.