From 0d4f42cf809dccc9327a331a5029815b68b47ccb Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 3 Mar 2024 03:03:23 -0800 Subject: [PATCH 1/2] Add debuglapcheat command, disables lap cheat prevention and prints a console message --- src/cvars.cpp | 1 + src/k_kart.c | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/cvars.cpp b/src/cvars.cpp index 809216600..1aa0d9a0b 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -804,6 +804,7 @@ consvar_t cv_capsuletest = OnlineCheat("capsuletest", "Off").values(capsuletest_ consvar_t cv_debugcheese = OnlineCheat("debugcheese", "Off").on_off().description("Disable checks that prevent farming item boxes"); consvar_t cv_debugencorevote = OnlineCheat("debugencorevote", "Off").on_off().description("Force encore choice to appear on vote screen"); +consvar_t cv_debuglapcheat = OnlineCheat("debuglapcheat", "Off").on_off().description("Permit far waypoint jumps and disable lap cheat prevention"); consvar_t cv_forcebots = OnlineCheat("forcebots", "No").yes_no().description("Force bots to appear, even in wrong game modes"); void ForceSkin_OnChange(void); diff --git a/src/k_kart.c b/src/k_kart.c index a4ef754e0..f9e3a17ea 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9935,18 +9935,27 @@ static void K_UpdatePlayerWaypoints(player_t *const player) UINT32 delta = u32_delta(player->distancetofinish, player->distancetofinishprev); if (player->respawn.state == RESPAWNST_NONE && delta > distance_threshold && old_currentwaypoint != NULL) { - CONS_Debug(DBG_GAMELOGIC, "Player %s: waypoint ID %d too far away (%u > %u)\n", - sizeu1(player - players), K_GetWaypointID(player->nextwaypoint), delta, distance_threshold); + extern consvar_t cv_debuglapcheat; +#define debug_args "Player %s: waypoint ID %d too far away (%u > %u)\n", \ + sizeu1(player - players), K_GetWaypointID(player->nextwaypoint), delta, distance_threshold + if (cv_debuglapcheat.value) + CONS_Printf(debug_args); + else + CONS_Debug(DBG_GAMELOGIC, debug_args); +#undef debug_args - // Distance jump is too great, keep the old waypoints and old distance. - player->currentwaypoint = old_currentwaypoint; - player->nextwaypoint = old_nextwaypoint; - player->distancetofinish = player->distancetofinishprev; - - // Start the auto respawn timer when the distance jumps. - if (!player->bigwaypointgap) + if (!cv_debuglapcheat.value) { - player->bigwaypointgap = 35; + // Distance jump is too great, keep the old waypoints and old distance. + player->currentwaypoint = old_currentwaypoint; + player->nextwaypoint = old_nextwaypoint; + player->distancetofinish = player->distancetofinishprev; + + // Start the auto respawn timer when the distance jumps. + if (!player->bigwaypointgap) + { + player->bigwaypointgap = 35; + } } } else From 9f982a574ed1063fd378641461d360d2be808227 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 3 Mar 2024 03:04:24 -0800 Subject: [PATCH 2/2] Add LapsPerSection property to map headers, fixes finish line distance in hybrid section-circuit maps - It is possible to have a circuit map separated into sections, where there are multiple "laps" before making a full loop - Normally the lap count is used to multiply the finish line distance, but it fails for these maps - The LapsPerSection property fixes the calculation by specifying how many laps make up a full loop - Default = 1 lap (most maps) --- src/deh_soc.c | 2 ++ src/doomstat.h | 1 + src/k_kart.c | 5 +++-- src/lua_maplib.c | 2 ++ src/p_setup.cpp | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/deh_soc.c b/src/deh_soc.c index 88755ead8..8817ad40b 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1299,6 +1299,8 @@ void readlevelheader(MYFILE *f, char * name) mapheaderinfo[num]->encorepal = (UINT16)i; else if (fastcmp(word, "NUMLAPS")) mapheaderinfo[num]->numlaps = (UINT8)i; + else if (fastcmp(word, "LAPSPERSECTION")) + mapheaderinfo[num]->lapspersection = max((UINT8)i, 1u); else if (fastcmp(word, "SKYBOXSCALE")) mapheaderinfo[num]->skybox_scalex = mapheaderinfo[num]->skybox_scaley = mapheaderinfo[num]->skybox_scalez = (INT16)i; else if (fastcmp(word, "SKYBOXSCALEX")) diff --git a/src/doomstat.h b/src/doomstat.h index 53ac819d9..c74dda7ac 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -509,6 +509,7 @@ struct mapheader_t UINT16 levelflags; ///< LF_flags: merged booleans into one UINT16 for space, see below UINT32 typeoflevel; ///< Combination of typeoflevel flags. UINT8 numlaps; ///< Number of laps in circuit mode, unless overridden. + UINT8 lapspersection; ///< Number of laps per section in hybrid section-circuit maps. fixed_t gravity; ///< Map-wide gravity. char relevantskin[SKINNAMESIZE+1]; ///< Skin to use for tutorial (if not provided, uses Eggman.) diff --git a/src/k_kart.c b/src/k_kart.c index f9e3a17ea..66865c8b4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9891,9 +9891,10 @@ static void K_UpdateDistanceFromFinishLine(player_t *const player) // correct we need to add to it the length of the entire circuit multiplied by the number of laps // left after this one. This will give us the total distance to the finish line, and allow item // distance calculation to work easily - if ((mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE) == 0U) + const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; + if ((mapheader->levelflags & LF_SECTIONRACE) == 0U) { - const UINT8 numfulllapsleft = ((UINT8)numlaps - player->laps); + const UINT8 numfulllapsleft = ((UINT8)numlaps - player->laps) / mapheader->lapspersection; player->distancetofinish += numfulllapsleft * K_GetCircuitLength(); } } diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 7ec807c87..9117858d1 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -2535,6 +2535,8 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->palette); else if (fastcmp(field,"numlaps")) lua_pushinteger(L, header->numlaps); + else if (fastcmp(field,"lapspersection")) + lua_pushinteger(L, header->lapspersection); else if (fastcmp(field,"levelselect")) lua_pushinteger(L, header->levelselect); else if (fastcmp(field,"levelflags")) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 27dd80043..f73355636 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -458,6 +458,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 num) mapheaderinfo[num]->palette = UINT16_MAX; mapheaderinfo[num]->encorepal = UINT16_MAX; mapheaderinfo[num]->numlaps = NUMLAPS_DEFAULT; + mapheaderinfo[num]->lapspersection = 1; mapheaderinfo[num]->levelselect = 0; mapheaderinfo[num]->levelflags = 0; mapheaderinfo[num]->menuflags = 0;