Skip to content

Commit

Permalink
[Cvar] New cvar sv_hidecmds
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrxd committed Mar 8, 2017
1 parent 1fec54a commit 4df4a3c
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 11 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# MinMod for UrbanTerror
**Four basic mods that must not miss on any urt server; infinite Stamina, no fall damage, colours names and infinite wall jumps**
**The mods that must not miss on any urt server; infinite Stamina, no fall damage, colours names, infinite wall jumps and hide cmds**

## Cvar/Usage
It contains all the original cvars and 4 more for control the mods added. All mods are enabled by default you can use the following commands for disable it (for enable just replace '0' with '1'):
It contains all the original cvars and 5 more for control the mods added. All mods are enabled by default you can use the following commands for disable it (for enable just replace '0' with '1'):

> set sv_infiniteStamina 0
Expand All @@ -11,6 +11,12 @@ It contains all the original cvars and 4 more for control the mods added. All mo
> set sv_nofallDamage 0
> set sv_colourNames 0
> set sv_hidecmds 0
*HideCmds have 3 modes -> 0: No mute nothing; 1: Mute all and who send can see msg; 2: Mute all and who send can't see msg.

The !pm command is allways muted.


## Installation
Expand Down
2 changes: 1 addition & 1 deletion code/qcommon/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,7 @@ void Com_Init( char *commandLine ) {
Cmd_AddCommand ("changeVectors", MSG_ReportChangeVectors_f );
Cmd_AddCommand ("writeconfig", Com_WriteConfig_f );

s = va("^5MinMod ^31.2V");
s = va("^5MinMod ^31.3V");
com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );

Sys_Init();
Expand Down
6 changes: 6 additions & 0 deletions code/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ extern cvar_t *sv_infiniteWallJumps;
extern cvar_t *sv_nofallDamage;

extern cvar_t *sv_colourNames;

extern cvar_t *sv_hideCmds;

#ifdef USE_AUTH
extern cvar_t *sv_authServerIP;
extern cvar_t *sv_auth_engine;
Expand All @@ -338,6 +341,9 @@ extern cvar_t *sv_auth_engine;
//
// sv_main.c
//
void QDECL SV_LogPrintf(const char *fmt, ...);


void SV_FinalMessage (char *message);
void QDECL SV_SendServerCommand( client_t *cl, const char *fmt, ...);

Expand Down
32 changes: 24 additions & 8 deletions code/server/sv_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

static void SV_CloseDownload( client_t *cl );




char *SV_CleanName(char *name) {

static char cleaned[MAX_NAME_LENGTH];
Expand All @@ -53,8 +50,6 @@ char *SV_CleanName(char *name) {
return cleaned;
}



/*
=================
SV_GetChallenge
Expand Down Expand Up @@ -1357,14 +1352,13 @@ void SV_UserinfoChanged( client_t *cl ) {

}


/*
==================
SV_UpdateUserinfo_f
==================
*/
void SV_UpdateUserinfo_f( client_t *cl ) {
gclient_t *gl;
gclient_t *gl;
if ( (sv_floodProtect->integer) && (cl->state >= CS_ACTIVE) && (svs.time < cl->nextReliableUserTime) ) {
Q_strncpyz( cl->userinfobuffer, Cmd_Argv(1), sizeof(cl->userinfobuffer) );
SV_SendServerCommand(cl, "print \"^7Command ^1delayed^7 due to sv_floodprotect.\"");
Expand All @@ -1376,6 +1370,7 @@ void SV_UpdateUserinfo_f( client_t *cl ) {

Q_strncpyz( cl->userinfo, Cmd_Argv(1), sizeof(cl->userinfo) );


SV_UserinfoChanged( cl );
// call prog code to allow overrides
VM_Call( gvm, GAME_CLIENT_USERINFO_CHANGED, cl - svs.clients );
Expand Down Expand Up @@ -1415,9 +1410,11 @@ void SV_ExecuteClientCommand( client_t *cl, const char *s, qboolean clientOK ) {
int charCount;
int dollarCount;
int i;
char *arg;
char *arg, *p;
qboolean bProcessed = qfalse;
qboolean exploitDetected = qfalse;
playerState_t *ps;


Cmd_TokenizeString( s );

Expand All @@ -1434,11 +1431,30 @@ void SV_ExecuteClientCommand( client_t *cl, const char *s, qboolean clientOK ) {

// pass unknown strings to the game
if ((!u->name) && (sv.state == SS_GAME) && (cl->state == CS_ACTIVE)) {
ps = SV_GameClientNum(cl - svs.clients);

Cmd_Args_Sanitize();

argsFromOneMaxlen = -1;
if (Q_stricmp("say", Cmd_Argv(0)) == 0 || Q_stricmp("say_team", Cmd_Argv(0)) == 0) {
argsFromOneMaxlen = MAX_SAY_STRLEN;

p = Cmd_Argv(1);
while (*p == ' ') p++;
if (strncmp("!pm", (char *)p, 3) == 0)
{
SV_SendServerCommand(cl, "chat \"^9[pm] ^7%s: ^3%s\"", cl->colourName, Cmd_Args());
SV_LogPrintf("say: %i %s: %s\n", ps->clientNum, cl->name, CopyString(Cmd_Args()));
return;
}
if (((*p == '!') || (*p == '@') || (*p == '&') || (*p == '/')) && sv_hideCmds->integer)
{
if(sv_hideCmds->integer == 1)
SV_SendServerCommand(cl, "chat \"^9[pm] ^7%s: ^3%s\"", cl->colourName, Cmd_Args());
SV_LogPrintf("say: %i %s: %s\n", ps->clientNum, cl->name, CopyString(Cmd_Args()));
return;
}

}
else if (Q_stricmp("tell", Cmd_Argv(0)) == 0) {
// A command will look like "tell 12 hi" or "tell foo hi". The "12"
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 @@ -949,6 +949,7 @@ void SV_Init (void) {

sv_colourNames = Cvar_Get ("sv_colournames", "1", CVAR_ARCHIVE);

sv_hideCmds = Cvar_Get ("sv_hidecmds", "1", CVAR_ARCHIVE);
#ifdef USE_AUTH
sv_authServerIP = Cvar_Get("sv_authServerIP", "", CVAR_TEMP | CVAR_ROM);
sv_auth_engine = Cvar_Get("sv_auth_engine", "1", CVAR_ROM);
Expand Down
56 changes: 56 additions & 0 deletions code/server/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,68 @@ cvar_t *sv_infiniteWallJumps;
cvar_t *sv_nofallDamage;

cvar_t *sv_colourNames;

cvar_t *sv_hideCmds;
//@Barbatos
#ifdef USE_AUTH
cvar_t *sv_authServerIP;
cvar_t *sv_auth_engine;
#endif



/////////////////////////////////////////////////////////////////////
// SV_LogPrintf
/////////////////////////////////////////////////////////////////////
void QDECL SV_LogPrintf(const char *fmt, ...) {

va_list argptr;
fileHandle_t file;
fsMode_t mode;
char *logfile;
char buffer[MAX_STRING_CHARS];
int min, tens, sec;
int logsync;

// retrieve the logfile name
logfile = Cvar_VariableString("g_log");
if (!logfile[0]) {
return;
}

// retrieve the writing mode
logsync = Cvar_VariableIntegerValue("g_logSync");
mode = logsync ? FS_APPEND_SYNC : FS_APPEND;

// opening the log file
FS_FOpenFileByMode(logfile, &file, mode);
if (!file) {
return;
}

// get current level time
sec = sv.time / 1000;
min = sec / 60;
sec -= min * 60;
tens = sec / 10;
sec -= tens * 10;

// prepend current level time
Com_sprintf(buffer, sizeof(buffer), "%3i:%i%i ", min, tens, sec);

// get the arguments
va_start(argptr, fmt);
vsprintf(buffer + 7, fmt, argptr);
va_end(argptr);

// write in the log file
FS_Write(buffer, strlen(buffer), file);
FS_FCloseFile(file);
}




/*
=============================================================================
Expand Down

0 comments on commit 4df4a3c

Please sign in to comment.