From bd12658355098b78cc270a5e15d6f7d4ced98f88 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 25 Jul 2018 21:33:03 +0100 Subject: [PATCH] Added the ability to toggle the f-zero style elimination of last place specifically. Type `karteliminatelast off` to turn it off, and `karteliminatelast on` to... you know the rest. --- src/d_netcmd.c | 10 ++++++++++ src/d_netcmd.h | 2 ++ src/k_kart.c | 1 + src/p_inter.c | 37 ++++++++++++++++++++----------------- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e959f406..e0a31408 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -114,6 +114,7 @@ static void KartFrantic_OnChange(void); static void KartSpeed_OnChange(void); static void KartMirror_OnChange(void); static void KartComeback_OnChange(void); +static void KartEliminateLast_OnChange(void); #ifdef NETGAME_DEVMODE static void Fishcake_OnChange(void); @@ -366,6 +367,9 @@ consvar_t cv_kartmirror = {"kartmirror", "Off", CV_NETVAR|CV_CHEAT|CV_CALL|CV_NO static CV_PossibleValue_t kartspeedometer_cons_t[] = {{0, "Off"}, {1, "Kilometers"}, {2, "Miles"}, {3, "Fracunits"}, {0, NULL}}; consvar_t cv_kartspeedometer = {"kartdisplayspeed", "Off", CV_SAVE, kartspeedometer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // use tics in display +// this might be a debug or it might be an undocumented regular feature +consvar_t cv_karteliminatelast = {"karteliminatelast", "Yes", CV_NETVAR|CV_CHEAT|CV_CALL, CV_OnOff, KartEliminateLast_OnChange, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t kartdebugitem_cons_t[] = {{-1, "MIN"}, {NUMKARTITEMS-1, "MAX"}, {0, NULL}}; consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; @@ -5260,3 +5264,9 @@ static void KartComeback_OnChange(void) } } } + +static void KartEliminateLast_OnChange(void) +{ + if (G_RaceGametype() && cv_karteliminatelast.value) + P_CheckRacers(); +} diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 0805a41f..009563af 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -127,6 +127,8 @@ extern consvar_t cv_kartcomeback; extern consvar_t cv_kartmirror; extern consvar_t cv_kartspeedometer; +extern consvar_t cv_karteliminatelast; + extern consvar_t cv_votetime; extern consvar_t cv_kartdebugitem, cv_kartdebugamount, cv_kartdebugcheckpoint, cv_kartdebugshrink; diff --git a/src/k_kart.c b/src/k_kart.c index d2ded697..3b982756 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -403,6 +403,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartcomeback); CV_RegisterVar(&cv_kartmirror); CV_RegisterVar(&cv_kartspeedometer); + CV_RegisterVar(&cv_karteliminatelast); CV_RegisterVar(&cv_votetime); CV_RegisterVar(&cv_kartdebugitem); diff --git a/src/p_inter.c b/src/p_inter.c index a0cecbb3..765c73f9 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2068,29 +2068,32 @@ boolean P_CheckRacers(void) return true; } - for (j = 0; j < MAXPLAYERS; j++) + if (cv_karteliminatelast.value) { - if (!playeringame[j] || players[j].spectator) - continue; - numplayersingame++; - } - - if (numplayersingame > 1) // if there's more than one player in-game, this is safe to do - { - // check if we just got unlucky and there was only one guy who was a problem - for (j = i+1; j < MAXPLAYERS; j++) + for (j = 0; j < MAXPLAYERS; j++) { - if (!playeringame[j] || players[j].spectator || players[j].exiting || !players[j].lives) + if (!playeringame[j] || players[j].spectator) continue; - - break; + numplayersingame++; } - if (j == MAXPLAYERS) // finish anyways, force a time over + if (numplayersingame > 1) // if there's more than one player in-game, this is safe to do { - P_DoTimeOver(&players[i]); - countdown = countdown2 = 0; - return true; + // check if we just got unlucky and there was only one guy who was a problem + for (j = i+1; j < MAXPLAYERS; j++) + { + if (!playeringame[j] || players[j].spectator || players[j].exiting || !players[j].lives) + continue; + + break; + } + + if (j == MAXPLAYERS) // finish anyways, force a time over + { + P_DoTimeOver(&players[i]); + countdown = countdown2 = 0; + return true; + } } }