Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

race: commands to change and vote countdown(vvd) #320

Merged
merged 3 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading