From f4f7c5b1eb3b6a97f826d01b46499f326a2f3757 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 24 Feb 2024 19:13:59 -0600 Subject: [PATCH 1/2] Add fault start mapthing 36 and prefer it for TA Fixes KartKrew/Kart#1063 --- src/doomstat.h | 1 + src/g_game.c | 21 +++++++++++++++++++-- src/p_mobj.c | 10 ++++++++++ src/p_setup.cpp | 4 ++++ src/p_setup.h | 2 +- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index b49404821..2515d9e1d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -871,6 +871,7 @@ extern tic_t gametic; extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF +extern mapthing_t *faultstart; // Kart Fault #define TUBEWAYPOINTSEQUENCESIZE 256 #define NUMTUBEWAYPOINTSEQUENCES 256 diff --git a/src/g_game.c b/src/g_game.c index 4cd1a7f8d..e779ffa1b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2821,6 +2821,18 @@ static inline mapthing_t *G_FindTeamStartOrFallback(INT32 playernum) return spawnpoint; } +static inline mapthing_t *G_FindTimeAttackStartOrFallback(INT32 playernum) +{ + mapthing_t *spawnpoint = NULL; + if (!(spawnpoint = faultstart) + && !(spawnpoint = G_FindRaceStart(playernum)) + && !(spawnpoint = G_FindBattleStart(playernum))) + { + spawnpoint = G_FindTeamStart(playernum); + } + return spawnpoint; +} + mapthing_t *G_FindMapStart(INT32 playernum) { extern consvar_t cv_battlespawn; @@ -2839,9 +2851,14 @@ mapthing_t *G_FindMapStart(INT32 playernum) else if (K_PodiumSequence() == true) spawnpoint = G_FindPodiumStart(playernum); - // -- Time Attack / Battle duels -- + // -- Time Attack -- + // Order: Fault->Race->DM->CTF + else if (K_TimeAttackRules() == true && modeattacking != ATTACKING_NONE) + spawnpoint = G_FindTimeAttackStartOrFallback(playernum); + + // -- Battle duels -- // Order: Race->DM->CTF - else if (K_TimeAttackRules() == true || ((gametyperules & GTR_BATTLESTARTS) && inDuel)) + else if (((gametyperules & GTR_BATTLESTARTS) && inDuel)) spawnpoint = G_FindRaceStartOrFallback(playernum); // -- CTF -- diff --git a/src/p_mobj.c b/src/p_mobj.c index 34fbb9b75..cbe31d5f7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12428,6 +12428,16 @@ static boolean P_SpawnNonMobjMapThing(mapthing_t *mthing) } return true; } + else if (mthing->type == 36) // Kart fault start + { + if (numfaultstarts < MAXPLAYERS) + { + faultstart = mthing; + mthing->type = 0; + numfaultstarts++; + } + return true; + } else if (mthing->type == 750 // Slope vertex point (formerly chaos spawn) || (mthing->type == FLOOR_SLOPE_THING || mthing->type == CEILING_SLOPE_THING) // Slope anchors || (mthing->type >= 600 && mthing->type <= 611) // Special placement patterns diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 9e9e46998..39a2ac020 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -187,11 +187,13 @@ UINT8 *rejectmatrix; // Maintain single and multi player starting spots. INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts; +INT32 numfaultstarts; mapthing_t *deathmatchstarts[MAX_DM_STARTS]; mapthing_t *playerstarts[MAXPLAYERS]; mapthing_t *bluectfstarts[MAXPLAYERS]; mapthing_t *redctfstarts[MAXPLAYERS]; +mapthing_t *faultstart; // Global state for PartialAddWadFile/MultiSetupWadFiles // Might be replacable with parameters, but non-trivial when the functions are called on separate tics @@ -7744,6 +7746,8 @@ static void P_ResetSpawnpoints(void) UINT8 i; numdmstarts = numredctfstarts = numbluectfstarts = 0; + numfaultstarts = 0; + faultstart = NULL; // reset the player starts for (i = 0; i < MAXPLAYERS; i++) diff --git a/src/p_setup.h b/src/p_setup.h index bcffd85b2..72bafc3b4 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -29,7 +29,7 @@ extern unsigned char mapmd5[16]; // Player spawn spots for deathmatch. #define MAX_DM_STARTS 64 extern mapthing_t *deathmatchstarts[MAX_DM_STARTS]; -extern INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts; +extern INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts, numfaultstarts; extern boolean levelloading; extern UINT8 levelfadecol; From ad7538922509240845c8d50189399ef16c628cfa Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 24 Feb 2024 21:05:49 -0600 Subject: [PATCH 2/2] Add respawn to fault start if available Fixes KartKrew/Kart#187 --- src/k_respawn.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/k_respawn.c b/src/k_respawn.c index 058052d8e..0c701c7da 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -128,6 +128,8 @@ void K_DoFault(player_t *player) --------------------------------------------------*/ void K_DoIngameRespawn(player_t *player) { + boolean faultstartfaulting = false; + if (!player->mo || P_MobjWasRemoved(player->mo)) { return; @@ -149,7 +151,24 @@ void K_DoIngameRespawn(player_t *player) { const waypoint_t *finish = K_GetFinishLineWaypoint(); - if (!(mapheaderinfo[gamemap-1]->levelflags & LF_SECTIONRACE) && finish != NULL) + if (numfaultstarts > 0 && faultstart) + { + subsector_t *subs; + if ((subs = R_PointInSubsectorOrNull(faultstart->x << FRACBITS, faultstart->y << FRACBITS)) != NULL) + { + faultstartfaulting = true; + player->respawn.wp = NULL; + player->respawn.flip = false; + player->respawn.pointx = faultstart->x << FRACBITS; + player->respawn.pointy = faultstart->y << FRACBITS; + player->respawn.pointz = + P_GetSectorFloorZAt(subs->sector, faultstart->x << FRACBITS, faultstart->y << FRACBITS) + + (faultstart->z << FRACBITS) + + K_RespawnOffset(player, player->respawn.flip); + player->respawn.pointangle = FixedAngle(faultstart->angle << FRACBITS); + } + } + else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_SECTIONRACE) && finish != NULL) player->respawn.wp = finish->prevwaypoints[0]; K_DoFault(player); } @@ -198,6 +217,10 @@ void K_DoIngameRespawn(player_t *player) K_RespawnAtWaypoint(player, player->respawn.wp); } } + else if (faultstartfaulting) + { + ; // Do nothing, position was already set + } else if ((gametyperules & GTR_CHECKPOINTS) && player->checkpointId && (checkpoint = Obj_FindCheckpoint(player->checkpointId))