Skip to content

Commit

Permalink
Merge pull request #320 from julienbelmon/race-countdown-cmds
Browse files Browse the repository at this point in the history
race: commands to change and vote countdown(vvd)
  • Loading branch information
tcsabina authored Nov 19, 2023
2 parents 3a9b9a9 + e5d2c01 commit 3d00eff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 },
Expand Down
20 changes: 19 additions & 1 deletion src/race.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 3d00eff

Please sign in to comment.