diff --git a/include/g_local.h b/include/g_local.h index bddd24b0..1b3ae894 100644 --- a/include/g_local.h +++ b/include/g_local.h @@ -974,6 +974,7 @@ typedef struct race_stats_score_s qbool isRACE(void); void apply_race_settings(void); void ToggleRace(void); +void RaceCountdownChange(float t); void StartDemoRecord(); qbool race_weapon_allowed(gedict_t *p); diff --git a/src/commands.c b/src/commands.c index fca233a2..7df3c715 100644 --- a/src/commands.c +++ b/src/commands.c @@ -607,6 +607,8 @@ const char CD_NODESC[] = "no desc"; #define CD_PAUSE "toggle pause" // { RACE #define CD_RACE "toggle race mode" +#define CD_R_COUNTDOWN_UP "+1 sec race cowntdown time" +#define CD_R_COUNTDOWN_DOWN "-1 sec race cowntdown time" #define CD_R_SSET "set race start checkpoint" #define CD_R_CSET "set race checkpoint" #define CD_R_ESET "set race end checkpoint" @@ -679,6 +681,8 @@ void redirect(); cmd_t cmds[] = { { "race", ToggleRace, 0, CF_PLAYER | CF_SPC_ADMIN, CD_RACE }, + { "race_countdown_up", DEF(RaceCountdownChange), 1, CF_PLAYER | CF_SPC_ADMIN, CD_R_COUNTDOWN_UP}, + { "race_countdown_down", DEF(RaceCountdownChange), -1, CF_PLAYER | CF_SPC_ADMIN, CD_R_COUNTDOWN_DOWN}, { "cm", SelectMap, 0, CF_BOTH | CF_MATCHLESS | CF_NOALIAS, CD_NODESC }, { "mapslist_dl", mapslist_dl, 0, CF_BOTH | CF_MATCHLESS | CF_PARAMS | CF_NOALIAS | CF_CONNECTION_FLOOD, CD_MAPSLIST_DL }, { "cmdslist_dl", cmdslist_dl, 0, CF_BOTH | CF_MATCHLESS | CF_PARAMS | CF_NOALIAS | CF_CONNECTION_FLOOD, CD_CMDSLIST_DL }, diff --git a/src/race.c b/src/race.c index 8d2d2df1..d1c12daa 100644 --- a/src/race.c +++ b/src/race.c @@ -271,6 +271,24 @@ void ToggleRace(void) apply_race_settings(); } +void RaceCountdownChange(float t) +{ + float rcd = cvar("k_race_countdown") + t; + + if (match_in_progress || !isRACE() || race_is_started()) + { + return; + } + + if ((rcd < 6) && (rcd > 0)) + { + cvar_fset("k_race_countdown", (int)rcd); + G_bprint(2, "%s %s %s\n", redtext("Race countdown length set to"), dig3(rcd), redtext("seconds")); + return; + } + G_sprint(self, 2, "%s still %s\n", redtext("race countdown"), dig3(rcd - t)); +} + // hard coded default settings for RACE static char race_settings[] = "sv_silentrecord 1\n" @@ -2039,7 +2057,7 @@ static void race_start(qbool cancelrecord, const char *fmt, ...) race.status = raceCD; // set countdown timer - race.cd_cnt = 3; + race.cd_cnt = cvar("k_race_countdown"); race.cd_next_think = g_globalvars.time; diff --git a/src/world.c b/src/world.c index 841d86a5..afb17908 100644 --- a/src/world.c +++ b/src/world.c @@ -896,6 +896,7 @@ void FirstFrame() // } // { race RegisterCvarEx("k_race", "0"); + RegisterCvarEx("k_race_countdown", "2"); RegisterCvarEx("k_race_custom_models", "0"); RegisterCvarEx("k_race_autorecord", "1"); RegisterCvarEx("k_race_times_per_port", "0");