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

Allow two exec calls during a game #1020

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,10 @@ typedef struct {
float map_fog_density;
qbool map_fog_enabled;
float map_fog_sky;

// exec_count keeps track of how many /exec calls have been made during a
// game, the counter will be reset upon match start.
int exec_count;
} clientState_t;

#define SCORING_SYSTEM_DEFAULT 0
Expand Down
21 changes: 18 additions & 3 deletions src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,25 @@ void Cmd_Exec_f (void)
char *f, name[MAX_OSPATH];
char reset_bindphysical[128];
qbool server_command = false;
const int max_exec_calls = 2;

if (Rulesets_RestrictExec()) {
Com_Printf("The use of exec is not allowed during matches\n");
return;
if (Rulesets_RestrictExec())
{
if (cl.exec_count >= max_exec_calls)
{
Com_Printf("You have no remaining exec calls for this game\n");
return;
}

cl.exec_count++;
if (cl.exec_count < max_exec_calls)
{
Com_Printf("You have %d exec calls remaining\n", max_exec_calls - cl.exec_count);
}
else
{
Com_Printf("This was your last exec call for this game\n");
}
}

if (Cmd_Argc () != 2) {
Expand Down
1 change: 1 addition & 0 deletions src/match_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ static void MT_StartMatch(void)
cl.countdown = false;
cl.gametime = 0;
cl.gamestarttime = Sys_DoubleTime();
cl.exec_count = 0;

if (cls.state < ca_active) {
matchstate.matchtype = mt_empty;
Expand Down
Loading