diff --git a/src/doomstat.h b/src/doomstat.h index 2df6caeb5..038944ef1 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -686,6 +686,7 @@ extern tic_t indirectitemcooldown; extern tic_t hyubgone; extern tic_t mapreset; extern boolean thwompsactive; +extern UINT8 lastLowestLap; extern SINT8 spbplace; extern boolean rainbowstartavailable; diff --git a/src/g_game.c b/src/g_game.c index 018d443ba..b62e7a6ce 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -315,6 +315,7 @@ tic_t indirectitemcooldown; // Cooldown before any more Shrink, SPB, or any othe tic_t hyubgone; // Cooldown before hyudoro is allowed to be rerolled tic_t mapreset; // Map reset delay when enough players have joined an empty game boolean thwompsactive; // Thwomps activate on lap 2 +UINT8 lastLowestLap; // Last lowest lap, for activating race lap executors SINT8 spbplace; // SPB exists, give the person behind better items boolean rainbowstartavailable; // Boolean, keeps track of if the rainbow start was gotten diff --git a/src/lua_script.c b/src/lua_script.c index 291a1936c..abf427e75 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -357,6 +357,9 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word,"thwompsactive")) { lua_pushboolean(L, thwompsactive); return 1; + } else if (fastcmp(word,"lastLowestLap")) { + lua_pushinteger(L, lastLowestLap); + return 1; } else if (fastcmp(word,"spbplace")) { lua_pushinteger(L, spbplace); return 1; diff --git a/src/p_saveg.c b/src/p_saveg.c index 650f77ef1..79b99e98f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -4162,6 +4162,7 @@ static void P_NetArchiveMisc(void) WRITEINT16(save_p, nospectategrief[i]); WRITEUINT8(save_p, thwompsactive); + WRITEUINT8(save_p, lastLowestLap); WRITESINT8(save_p, spbplace); WRITEUINT8(save_p, rainbowstartavailable); @@ -4295,6 +4296,7 @@ static inline boolean P_NetUnArchiveMisc(void) nospectategrief[i] = READINT16(save_p); thwompsactive = (boolean)READUINT8(save_p); + lastLowestLap = READUINT8(save_p); spbplace = READSINT8(save_p); rainbowstartavailable = (boolean)READUINT8(save_p); diff --git a/src/p_setup.c b/src/p_setup.c index 15e6767a5..13c0170a8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4098,6 +4098,7 @@ boolean P_LoadLevel(boolean fromnetsave) nospectategrief[i] = -1; thwompsactive = false; + lastLowestLap = 0; spbplace = -1; // clear special respawning que diff --git a/src/p_spec.c b/src/p_spec.c index 1fcba7585..06de8118e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1836,7 +1836,6 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller || specialtype == 336 // Dye - Once || specialtype == 399 // Level Load || specialtype == 328 // SRB2Kart Encore Load - || specialtype == 2002 // SRB2Kart Race Lap ) triggerline->special = 0; // Clear it out @@ -1999,6 +1998,7 @@ static void K_HandleLapIncrement(player_t *player) { size_t i = 0; UINT8 nump = 0; + UINT8 lowestLap; for (i = 0; i < MAXPLAYERS; i++) { @@ -2082,6 +2082,8 @@ static void K_HandleLapIncrement(player_t *player) thwompsactive = true; // Lap 2 effects + lowestLap = P_FindLowestLap(); + for (i = 0; i < numlines; i++) { if (lines[i].special == 2002) // Race lap trigger @@ -2094,7 +2096,13 @@ static void K_HandleLapIncrement(player_t *player) } else { - lap = P_FindLowestLap(); + lap = lowestLap; + + if (lap <= lastLowestLap) + { + // Need to be able to search for E4 linedefs + continue; + } } if (lines[i].flags & ML_NOCLIMB) // Need higher than or equal to @@ -2116,6 +2124,8 @@ static void K_HandleLapIncrement(player_t *player) P_RunTriggerLinedef(&lines[i], player->mo, NULL); } } + + lastLowestLap = lowestLap; } else if (player->starpostnum) { diff --git a/src/p_user.c b/src/p_user.c index e705c0d8a..0df4aa756 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -409,7 +409,7 @@ UINT8 P_FindLowestLap(void) INT32 i; UINT8 lowest = UINT8_MAX; - if (gametyperules & GTR_CIRCUIT) + if (!(gametyperules & GTR_CIRCUIT)) return 0; for (i = 0; i < MAXPLAYERS; i++) @@ -417,10 +417,10 @@ UINT8 P_FindLowestLap(void) if (!playeringame[i] || players[i].spectator) continue; - if (lowest == 255) - lowest = players[i].laps; - else if (players[i].laps < lowest) + if (lowest == UINT8_MAX || players[i].laps < lowest) + { lowest = players[i].laps; + } } CONS_Debug(DBG_GAMELOGIC, "Lowest laps found: %d\n", lowest);