[iortcw] 47/152: MP: Add server cvar to force unique client names 1 = Empty client names only 2 = All names

Simon McVittie smcv at debian.org
Fri Sep 8 10:39:57 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.5a
in repository iortcw.

commit e62dc7dde3b31d5f5d1e1e45771d72c2ae02dcac
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Sat May 7 10:51:51 2016 -0400

    MP: Add server cvar to force unique client names
    1 = Empty client names only
    2 = All names
---
 MP/code/server/server.h    |  2 ++
 MP/code/server/sv_client.c | 18 +++++++++++++++++-
 MP/code/server/sv_init.c   |  2 ++
 MP/code/server/sv_main.c   |  3 +++
 4 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/MP/code/server/server.h b/MP/code/server/server.h
index 483b8fe..de2edf2 100644
--- a/MP/code/server/server.h
+++ b/MP/code/server/server.h
@@ -338,6 +338,8 @@ extern cvar_t  *sv_allowAnonymous;
 extern cvar_t  *sv_lanForceRate;
 extern cvar_t  *sv_onlyVisibleClients;
 
+extern cvar_t *sv_forceNameUniq;
+
 extern	cvar_t	*sv_banFile;
 
 extern	serverBan_t serverBans[SERVER_MAXBANS];
diff --git a/MP/code/server/sv_client.c b/MP/code/server/sv_client.c
index d74de7e..9f8b748 100644
--- a/MP/code/server/sv_client.c
+++ b/MP/code/server/sv_client.c
@@ -1467,11 +1467,27 @@ into a more C friendly form.
 void SV_UserinfoChanged( client_t *cl ) {
 	char    *val;
 	char	*ip;
+	char	*guid;
+	char	*name;
+	char	gname[MAX_QPATH];
 	int i;
 	int	len;
 
 	// name for C code
-	Q_strncpyz( cl->name, Info_ValueForKey( cl->userinfo, "name" ), sizeof( cl->name ) );
+	name = Info_ValueForKey( cl->userinfo, "name" );
+	guid = Info_ValueForKey( cl->userinfo, "cl_guid" );
+
+	if ( sv_forceNameUniq->integer == 1 ) {
+		if ( !Q_stricmp( name, "" ) || !Q_stricmp( name, "WolfPlayer" ) || !Q_stricmp( name, "UnnamedPlayer" ) ) {
+			Com_sprintf( gname, sizeof( gname ), "%s %s", name, guid + 24 );
+			Info_SetValueForKey( cl->userinfo, "name", gname );
+		}
+	} else if ( sv_forceNameUniq->integer == 2 ) {
+		Com_sprintf( gname, sizeof( gname ), "%s %s", name, guid + 24 );
+		Info_SetValueForKey( cl->userinfo, "name", gname );
+	}
+
+	Q_strncpyz( cl->name, name, sizeof( cl->name ) );
 
 	// rate command
 
diff --git a/MP/code/server/sv_init.c b/MP/code/server/sv_init.c
index 5bf5ef6..8ebea9a 100644
--- a/MP/code/server/sv_init.c
+++ b/MP/code/server/sv_init.c
@@ -930,6 +930,8 @@ void SV_Init( void ) {
 
 	sv_onlyVisibleClients = Cvar_Get( "sv_onlyVisibleClients", "0", 0 );       // DHM - Nerve
 
+	sv_forceNameUniq = Cvar_Get( "sv_forceNameUniq", "0", CVAR_ARCHIVE );
+
 	sv_showAverageBPS = Cvar_Get( "sv_showAverageBPS", "0", 0 );           // NERVE - SMF - net debugging
 
 	// NERVE - SMF - create user set cvars
diff --git a/MP/code/server/sv_main.c b/MP/code/server/sv_main.c
index 0181944..4538ac5 100644
--- a/MP/code/server/sv_main.c
+++ b/MP/code/server/sv_main.c
@@ -72,6 +72,9 @@ cvar_t  *sv_floodProtect;
 cvar_t  *sv_allowAnonymous;
 cvar_t  *sv_lanForceRate; // TTimo - dedicated 1 (LAN) server forces local client rates to 99999 (bug #491)
 cvar_t  *sv_onlyVisibleClients; // DHM - Nerve
+
+cvar_t  *sv_forceNameUniq;
+
 cvar_t  *sv_friendlyFire;       // NERVE - SMF
 cvar_t  *sv_maxlives;           // NERVE - SMF
 cvar_t  *sv_tourney;            // NERVE - SMF

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list