From 54a628bdfdea51a6618e4fca1958d8027cc8fd55 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sat, 3 May 2025 17:30:31 +0200 Subject: [PATCH] Enable waypoints for patched maps --- src/k_kart.c | 5 +++++ src/p_inter.c | 14 ++------------ src/p_mobj.c | 37 +++++++++++++++++++++++++++++-------- src/p_spec.c | 2 +- src/p_spec.h | 1 + 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 528810383..f1381a410 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -11002,6 +11002,11 @@ boolean K_SlipdashActive(void) boolean K_UsingLegacyCheckpoints(void) { + if (patch_version && waypointcap) + { + // we're presumably adding waypoints to an existing map + return false; + } if (numbosswaypoints > 0) { // We are using Kart V1 waypoints! diff --git a/src/p_inter.c b/src/p_inter.c index 357e4d996..9cee82a17 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -941,8 +941,8 @@ void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost) (void)snaptopost; - // Player must have touched all previous starposts - if ((post->health - player->starpostnum > 1) && (!K_UsingLegacyCheckpoints())) + // Going backwards triggers sound + if (post->health >= ((numstarposts/2) + player->starpostnum)) { if (!player->checkskip) { @@ -952,17 +952,7 @@ void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost) player->grieftime += TICRATE; } - } - player->checkskip = 3; - return; - } - - // Going backwards triggers sound - if ((post->health >= ((numstarposts/2) + player->starpostnum)) && (K_UsingLegacyCheckpoints())) - { - if (!player->checkskip) - S_StartSound(toucher, sfx_s26d); player->checkskip = 3; return; diff --git a/src/p_mobj.c b/src/p_mobj.c index 9a9f99eca..3ce0d5975 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12860,15 +12860,22 @@ static boolean P_SetupParticleGen(mapthing_t *mthing, mobj_t *mobj) return true; } -static void P_SnapToFinishLine(mobj_t *mobj) +static void SpreadFinishLine(line_t *line, line_t *prev, boolean flip) { - line_t *finishline = P_FindNearestLine(mobj->x, mobj->y, - mobj->subsector->sector, 2001); // case 2001: Finish Line - if (finishline != NULL) + size_t i; + for (i = 0; i < numlines; i++) { - P_UnsetThingPosition(mobj); - P_ClosestPointOnLine(mobj->x, mobj->y, finishline, (vertex_t *)&mobj->x); - P_SetThingPosition(mobj); + line_t *line2 = &lines[i]; + if (line2 != line && line2 != prev && (line2->slopetype == ST_HORIZONTAL || line2->slopetype == ST_VERTICAL) && line2->slopetype == line->slopetype && + (line->v1 == line2->v1 || line->v2 == line2->v2 || line->v1 == line2->v2 || line->v2 == line2->v1)) + { + boolean flipped = line->v1 == line2->v1 || line->v2 == line2->v2; + line2->special = 2001; // Finish Line + line2->activation = SPAC_CROSS|SPAC_REPEATSPECIAL; + if (flipped != flip) + line2->args[0] |= TMCFF_FLIP; + SpreadFinishLine(line2, line, flipped != flip); + } } } @@ -13161,7 +13168,21 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean mobj->extravalue2 = 1; // args[2] of 1 means the waypoint is at the finish line mobj->reactiontime = 0; // Also don't respawn at finish lines - P_SnapToFinishLine(mobj); + line_t *finishline = P_FindNearestLine(mobj->x, mobj->y, + mobj->subsector->sector, -1); + if (finishline != NULL) + { + P_UnsetThingPosition(mobj); + P_ClosestPointOnLine(mobj->x, mobj->y, finishline, (vertex_t *)&mobj->x); + P_SetThingPosition(mobj); + + boolean flip = mthing->args[2] & TMWPF_FLIPFINISH; + finishline->special = 2001; // Finish Line + finishline->activation = SPAC_CROSS|SPAC_REPEATSPECIAL; + if (flip) + finishline->args[0] |= TMCFF_FLIP; + SpreadFinishLine(finishline, NULL, flip); + } } else { diff --git a/src/p_spec.c b/src/p_spec.c index a5a068028..8616dc5f2 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5356,7 +5356,7 @@ static void P_EvaluateSpecialFlags(player_t *player, sector_t *sector, sector_t P_ProcessZoomTube(player, sectag, true); if (sector->specialflags & SSF_FINISHLINE) { - if ((gametyperules & GTR_CIRCUIT) && (player->exiting == 0) && !(player->pflags & PF_HITFINISHLINE)) + if (K_UsingLegacyCheckpoints() && (gametyperules & GTR_CIRCUIT) && (player->exiting == 0) && !(player->pflags & PF_HITFINISHLINE)) { K_HandleLapIncrement(player); player->pflags |= PF_HITFINISHLINE; diff --git a/src/p_spec.h b/src/p_spec.h index 7bfab7f13..9983829f6 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -63,6 +63,7 @@ typedef enum TMWPF_SHORTCUT = 1<<1, TMWPF_NORESPAWN = 1<<2, TMWPF_FINISHLINE = 1<<3, + TMWPF_FLIPFINISH = 1<<4, } textmapwaypointflags_t; typedef enum