Skip to content

Commit

Permalink
Added sv_substitute
Browse files Browse the repository at this point in the history
Allow server admins to disable the use of /sub command in matchmode (1, Default = substitutes enabled, 0 = disabled).

Co-Authored-By: Taras Mykhailovych <6552671+tarquas@users.noreply.github.com>
  • Loading branch information
BidyBiddle and tarquas committed Dec 22, 2021
1 parent c988f76 commit 713df41
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion code/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ extern cvar_t *sv_demofolder; // define the server-side demo folder name
extern cvar_t *sv_autoRecordDemo; // automatically create a server demo of every player that connects
extern cvar_t *sv_sayprefix;
extern cvar_t *sv_tellprefix;
extern cvar_t *sv_teamSwitch; // allow players to switch teams (0, Default = players must wait 5 seconds to switch, 1 = no restriction)
extern cvar_t *sv_teamSwitch; // allow players to switch teams (0, Default = players must wait 5 seconds, 1 = no restriction)
extern cvar_t *sv_substitute; // allow players to use /sub in matchmode (1, Default = substitutes enabled, 0 = disabled)

#ifdef USE_VOIP
extern cvar_t *sv_voip;
Expand Down
25 changes: 14 additions & 11 deletions code/server/sv_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ static void SV_SendClientGameState( client_t *client ) {
msg_t msg;
byte msgBuffer[MAX_MSGLEN];

Com_DPrintf ("SV_SendClientGameState() for %s\n", client->name);
Com_DPrintf( "SV_SendClientGameState() for %s\n", client->name );
Com_DPrintf( "Going from CS_CONNECTED to CS_PRIMED for %s\n", client->name );
client->state = CS_PRIMED;
client->pureAuthentic = 0;
Expand Down Expand Up @@ -1226,13 +1226,16 @@ void SV_ExecuteClientCommand( client_t *cl, const char *s, qboolean clientOK ) {
int dollarCount;
int i;
char *arg;
qboolean bProcessed = qfalse;
qboolean exploitDetected = qfalse;
qboolean bProcessed = qfalse;
qboolean exploitDetected = qfalse;



Cmd_TokenizeString( s );

// ignore /sub commands if sv_substitute is set to 0
if (!sv_substitute->integer && !strcasecmp(Cmd_Argv(0), "sub")) return;

// see if it is a server level command
for (u=ucmds ; u->name ; u++) {
if (!strcmp (Cmd_Argv(0), u->name) ) {
Expand All @@ -1250,19 +1253,19 @@ void SV_ExecuteClientCommand( client_t *cl, const char *s, qboolean clientOK ) {
argsFromOneMaxlen = -1;

// Fix for the annoying "must wait 5 seconds before switching teams" limitation
if (Q_stricmp("team", Cmd_Argv(0)) == 0) {
if (Q_stricmp("team", Cmd_Argv(0)) == 0) {
int cid;
cid = cl - svs.clients;
cid = cl - svs.clients;
if (sv_teamSwitch->integer) {
Cmd_ExecuteString(va("forceteam %d %s", cid, Cmd_Argv(1)));
return;
Cmd_ExecuteString(va("forceteam %d %s", cid, Cmd_Argv(1)));
return;
}
if (Cvar_VariableIntegerValue("g_matchmode") == 1){
// always allow team switching whilst matchmode is 1
Cmd_ExecuteString(va("forceteam %d %s", cid, Cmd_Argv(1)));
return;
Cmd_ExecuteString(va("forceteam %d %s", cid, Cmd_Argv(1)));
return;
}
}
}
if (Q_stricmp("say", Cmd_Argv(0)) == 0 ||
Q_stricmp("say_team", Cmd_Argv(0)) == 0) {
argsFromOneMaxlen = MAX_SAY_STRLEN;
Expand Down Expand Up @@ -1533,7 +1536,7 @@ static qboolean SV_ShouldIgnoreVoipSender(const client_t *cl)
return qtrue; // VoIP disabled on this server.
else if (!cl->hasVoip) // client doesn't have VoIP support?!
return qtrue;
// !!! FIXME: implement player blacklist.

return qfalse; // don't ignore.
Expand Down
1 change: 1 addition & 0 deletions code/server/sv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ void SV_Init (void)
sv_sayprefix = Cvar_Get ("sv_sayprefix", "console: ", CVAR_ARCHIVE );
sv_tellprefix = Cvar_Get ("sv_tellprefix", "console_tell: ", CVAR_ARCHIVE );
sv_teamSwitch = Cvar_Get("sv_teamSwitch", "0", CVAR_ARCHIVE );
sv_substitute = Cvar_Get ("sv_substitute", "1", CVAR_ARCHIVE );
sv_extraPaks = Cvar_Get ("sv_extraPaks", "", CVAR_ARCHIVE | CVAR_LATCH);
sv_extraPure = Cvar_Get ("sv_extraPure", "0", CVAR_ARCHIVE | CVAR_LATCH);

Expand Down
1 change: 1 addition & 0 deletions code/server/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ cvar_t *sv_autoRecordDemo; // automatically create a server demo of every pla
cvar_t *sv_tellprefix;
cvar_t *sv_sayprefix;
cvar_t *sv_teamSwitch; // allow players to switch teams (0, Default = players must wait 5 seconds to switch, 1 = no restriction)
cvar_t *sv_substitute; // allow players to use /sub in matchmode (1, Default = substitutes enabled, 0 = disabled)

#ifdef USE_VOIP
cvar_t *sv_voip;
Expand Down

0 comments on commit 713df41

Please sign in to comment.