summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/g_client.c23
-rw-r--r--src/game/g_local.h3
-rw-r--r--src/game/g_main.c2
3 files changed, 27 insertions, 1 deletions
diff --git a/src/game/g_client.c b/src/game/g_client.c
index b80451f3..fcbc8f3b 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -949,6 +949,7 @@ void ClientUserinfoChanged( int clientNum )
char buffer[ MAX_QPATH ];
char filename[ MAX_QPATH ];
char oldname[ MAX_STRING_CHARS ];
+ char newname[ MAX_STRING_CHARS ];
gclient_t *client;
char c1[ MAX_INFO_STRING ];
char c2[ MAX_INFO_STRING ];
@@ -981,7 +982,27 @@ void ClientUserinfoChanged( int clientNum )
// set name
Q_strncpyz( oldname, client->pers.netname, sizeof( oldname ) );
s = Info_ValueForKey( userinfo, "name" );
- ClientCleanName( s, client->pers.netname, sizeof( client->pers.netname ) );
+ ClientCleanName( s, newname, sizeof( newname ) );
+
+ if( strcmp( oldname, newname ) )
+ {
+ // If not connected or time since name change has passed threshold, allow the change
+ if( client->pers.connected != CON_CONNECTED ||
+ ( level.time - client->pers.nameChangeTime ) > ( g_minNameChangePeriod.integer * 1000 ) )
+ {
+ Q_strncpyz( client->pers.netname, newname, sizeof( client->pers.netname ) );
+ client->pers.nameChangeTime = level.time;
+ }
+ else
+ {
+ // Note this leaves the client in a strange state where it has changed its "name" cvar
+ // but the server has refused to honour the change. In this case the client's cvar does
+ // not match the actual client's name any longer. This isn't so bad since really the
+ // only case where the name would be changing so fast is when it was being abused, and
+ // we don't really care if that kind of player screws their client up.
+ // Nevertheless, maybe FIXME this later.
+ }
+ }
if( client->sess.sessionTeam == TEAM_SPECTATOR )
{
diff --git a/src/game/g_local.h b/src/game/g_local.h
index c897072d..85e26268 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -335,6 +335,8 @@ typedef struct
qboolean joinedATeam; // used to tell when a PTR code is valid
connectionRecord_t *connection;
+ int nameChangeTime;
+
vec3_t lastDeathLocation;
} clientPersistant_t;
@@ -1015,6 +1017,7 @@ extern vmCvar_t g_maxclients; // allow this many total, including spectato
extern vmCvar_t g_maxGameClients; // allow this many active
extern vmCvar_t g_restarted;
extern vmCvar_t g_minCommandPeriod;
+extern vmCvar_t g_minNameChangePeriod;
extern vmCvar_t g_timelimit;
extern vmCvar_t g_suddenDeathTime;
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 81675089..6eec109f 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -86,6 +86,7 @@ vmCvar_t pmove_msec;
vmCvar_t g_rankings;
vmCvar_t g_listEntity;
vmCvar_t g_minCommandPeriod;
+vmCvar_t g_minNameChangePeriod;
//TA
vmCvar_t g_humanBuildPoints;
@@ -178,6 +179,7 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_voteLimit, "g_voteLimit", "5", CVAR_ARCHIVE, 0, qfalse },
{ &g_listEntity, "g_listEntity", "0", 0, 0, qfalse },
{ &g_minCommandPeriod, "g_minCommandPeriod", "500", 0, 0, qfalse},
+ { &g_minNameChangePeriod, "g_minNameChangePeriod", "5", 0, 0, qfalse},
{ &g_smoothClients, "g_smoothClients", "1", 0, 0, qfalse},
{ &pmove_fixed, "pmove_fixed", "0", CVAR_SYSTEMINFO, 0, qfalse},