From 20f8037351dffd30b296f28bbeaa536a26d3a740 Mon Sep 17 00:00:00 2001 From: Sryder Date: Sat, 29 Jun 2019 11:05:35 +0100 Subject: [PATCH] Respawn at waypoints once first crossing the finish line. --- src/g_game.c | 3 ++- src/k_kart.c | 36 ++++++++++++++++++++++++++++++++++-- src/p_inter.c | 6 ------ src/p_spec.c | 17 ----------------- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 297f4a198..b9099c5a8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3216,7 +3216,8 @@ void G_DoReborn(INT32 playernum) // respawn at the start mobj_t *oldmo = NULL; - if (player->starpostnum || ((mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE) && player->laps)) // SRB2kart + // Now only respawn at the start if you haven't crossed it at all + if (player->laps) // SRB2kart starpost = true; // first dissasociate the corpse diff --git a/src/k_kart.c b/src/k_kart.c index 1740aa862..01cc4b940 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5859,8 +5859,40 @@ static void K_UpdateDistanceFromFinishLine(player_t *const player) } else { - waypoint_t *finishline = K_GetFinishLineWaypoint(); - player->nextwaypoint = K_GetPlayerNextWaypoint(player); + waypoint_t *finishline = K_GetFinishLineWaypoint(); + waypoint_t *nextwaypoint = K_GetPlayerNextWaypoint(player); + + if ((nextwaypoint != player->nextwaypoint) && + (K_GetWaypointIsShortcut(nextwaypoint) == false) && (K_GetWaypointIsEnabled(nextwaypoint) == true)) + { + size_t i = 0U; + waypoint_t *aimwaypoint = NULL; + player->starpostx = nextwaypoint->mobj->x >> FRACBITS; + player->starposty = nextwaypoint->mobj->y >> FRACBITS; + player->starpostz = nextwaypoint->mobj->z >> FRACBITS; + + // player gravflip determines which way to respawn + player->kartstuff[k_starpostflip] = player->mo->flags2 & MF2_OBJECTFLIP; + + // starpostangle is to the first valid nextwaypoint for simplicity + // if we reach the last waypoint and it's still not valid, just use it anyway. Someone needs to fix + // their map! + for (i = 0U; i < nextwaypoint->numnextwaypoints; i++) + { + aimwaypoint = nextwaypoint->nextwaypoints[i]; + + if ((i == nextwaypoint->numnextwaypoints - 1U) + || ((K_GetWaypointIsShortcut(aimwaypoint) == false) + && (K_GetWaypointIsEnabled(aimwaypoint) == true))) + { + player->starpostangle = R_PointToAngle2( + nextwaypoint->mobj->x, nextwaypoint->mobj->y, aimwaypoint->mobj->x, aimwaypoint->mobj->y); + break; + } + } + } + + player->nextwaypoint = nextwaypoint; // nextwaypoint is now the waypoint that is in front of us if ((player->nextwaypoint != NULL) && (finishline != NULL)) diff --git a/src/p_inter.c b/src/p_inter.c index ceef7accb..63e091828 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1484,13 +1484,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Save the player's time and position. player->starposttime = player->realtime; //this makes race mode's timers work correctly whilst not affecting sp -x - //player->starposttime = leveltime; - player->starpostx = toucher->x>>FRACBITS; - player->starposty = toucher->y>>FRACBITS; - player->starpostz = special->z>>FRACBITS; - player->starpostangle = special->angle; player->starpostnum = special->health; - player->kartstuff[k_starpostflip] = special->spawnpoint->options & MTF_OBJECTFLIP; // store flipping //S_StartSound(toucher, special->info->painsound); return; diff --git a/src/p_spec.c b/src/p_spec.c index 8522fdf9b..b83a51cde 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2254,23 +2254,6 @@ static void K_HandleLapIncrement(player_t *player) player->starposttime = player->realtime; player->starpostnum = 0; - if (mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE) - { - // SRB2Kart 281118 - // Save the player's time and position. - player->starpostx = player->mo->x>>FRACBITS; - player->starposty = player->mo->y>>FRACBITS; - player->starpostz = player->mo->floorz>>FRACBITS; - player->kartstuff[k_starpostflip] = player->mo->flags2 & MF2_OBJECTFLIP; // store flipping - player->starpostangle = player->mo->angle; //R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); torn; a momentum-based guess is less likely to be wrong in general, but when it IS wrong, it fucks you over entirely... - } - else - { - // SRB2kart 200117 - // Reset starposts (checkpoints) info - player->starpostangle = player->starpostx = player->starposty = player->starpostz = player->kartstuff[k_starpostflip] = 0; - } - if (P_IsDisplayPlayer(player)) { if (player->laps == (UINT8)(cv_numlaps.value)) // final lap