@@ -856,7 +856,7 @@ Forces a client's skin (for teamplay)
856856ClientCheckName
857857============
858858*/
859- static void ClientCleanName ( int clientNum , const char * in , char * out , int outSize ) {
859+ static void ClientCleanName ( int clientNum , const char * in , char * out , int outSize , qboolean dupecheck ) {
860860 int len , colorlessLen ;
861861 char ch ;
862862 char * p ;
@@ -870,7 +870,7 @@ static void ClientCleanName( int clientNum, const char *in, char *out, int outSi
870870 len = 0 ;
871871 colorlessLen = 0 ;
872872 p = out ;
873- * p = 0 ;
873+ * p = '\0' ;
874874 spaces = 0 ;
875875
876876 while ( 1 ) {
@@ -880,7 +880,7 @@ static void ClientCleanName( int clientNum, const char *in, char *out, int outSi
880880 }
881881
882882 // don't allow leading spaces
883- if ( ! * p && ch == ' ' ) {
883+ if ( * p == '\0' && ch == ' ' ) {
884884 continue ;
885885 }
886886
@@ -927,49 +927,51 @@ static void ClientCleanName( int clientNum, const char *in, char *out, int outSi
927927 colorlessLen ++ ;
928928 len ++ ;
929929 }
930- * out = 0 ;
930+ * out = '\0' ;
931931
932932 // don't allow empty names
933933 if ( * p == 0 || colorlessLen == 0 ) {
934934 Q_strncpyz ( p , "ETF_Player" , outSize );
935935 }
936936
937- // djbob: stop colliding nicks
938- // Perhaps add a list of nicks which will be forcefully changed
939- Q_strncpyz ( buffer , p , outSize );
940- Q_CleanStr ( buffer );
937+ if ( dupecheck ) {
938+ // djbob: stop colliding nicks
939+ // Perhaps add a list of nicks which will be forcefully changed
940+ Q_strncpyz ( buffer , p , outSize );
941+ Q_CleanStr ( buffer );
941942
942- a = 0 ;
943- for ( i = 0 ; i < MAX_CLIENTS ; i ++ ) {
944- char buf [128 ], buf_2 [128 ];
943+ a = 0 ;
944+ for ( i = 0 ; i < MAX_CLIENTS ; i ++ ) {
945+ char buf [128 ], buf_2 [128 ];
945946
946- if (!g_entities [i ].inuse || g_entities [i ].s .number == clientNum || (g_entities [i ].client -> pers .connected < CON_CONNECTING )) {
947- continue ;
948- }
947+ if (!g_entities [i ].inuse || g_entities [i ].s .number == clientNum || (g_entities [i ].client -> pers .connected < CON_CONNECTING )) {
948+ continue ;
949+ }
949950
950- if (a ) {
951- Com_sprintf (buf , outSize , "%d_%s" , a , buffer );
952- } else {
953- Q_strncpyz ( buf , buffer , outSize );
954- }
951+ if (a ) {
952+ Com_sprintf (buf , outSize , "%d_%s" , a , buffer );
953+ } else {
954+ Q_strncpyz ( buf , buffer , outSize );
955+ }
955956
956- Q_strncpyz ( buf_2 , g_entities [i ].client -> pers .netname , outSize );
957- Q_CleanStr ( buf_2 );
957+ Q_strncpyz ( buf_2 , g_entities [i ].client -> pers .netname , outSize );
958+ Q_CleanStr ( buf_2 );
958959
959960
960- if (!Q_stricmp (buf_2 , buf )) {
961- a ++ ;
962- i = -1 ;
961+ if (!Q_stricmp (buf_2 , buf )) {
962+ a ++ ;
963+ i = -1 ;
964+ }
963965 }
964- }
965966
966- if (a ) {
967- //Keeger -- seems somehow Com_sprintf borks when using the destination as an argument
968- //cause the original way produced "1_1_1_1_" garbage.
969- Q_strncpyz ( buffer , p , outSize ); //re-make buffer to colorized string
970- Com_sprintf (p , outSize , "%d_%s" , a , buffer ); //replace the p arg with buffer and bug goes away...
967+ if (a ) {
968+ //Keeger -- seems somehow Com_sprintf borks when using the destination as an argument
969+ //cause the original way produced "1_1_1_1_" garbage.
970+ Q_strncpyz ( buffer , p , outSize ); //re-make buffer to colorized string
971+ Com_sprintf (p , outSize , "%d_%s" , a , buffer ); //replace the p arg with buffer and bug goes away...
972+ }
973+ // djbob
971974 }
972- // djbob
973975}
974976
975977
@@ -984,7 +986,7 @@ The game can override any of the settings and call trap_SetUserinfo
984986if desired.
985987============
986988*/
987- qboolean ClientUserinfoChanged ( int clientNum , const char * reason ) {
989+ qboolean ClientUserinfoChanged ( int clientNum , const char * reason , qboolean dupecheck ) {
988990 gentity_t * ent ;
989991 const char * s ;
990992 char oldname [MAX_NETNAME ];
@@ -1077,7 +1079,7 @@ qboolean ClientUserinfoChanged( int clientNum, const char *reason ) {
10771079 // set name.
10781080 Q_strncpyz ( oldname , client -> pers .netname , sizeof ( oldname ) );
10791081 s = Info_ValueForKey (userinfo , "name" );
1080- ClientCleanName ( clientNum , s , client -> pers .netname , sizeof (client -> pers .netname ) );
1082+ ClientCleanName ( clientNum , s , client -> pers .netname , sizeof (client -> pers .netname ), dupecheck );
10811083
10821084 //if ( client->sess.sessionTeam == Q3F_TEAM_SPECTATOR ) {
10831085 if ( Q3F_IsSpectator (ent -> client )) { // RR2DO2
@@ -1337,7 +1339,7 @@ const char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot )
13371339
13381340 client -> ps .clientNum = clientNum ;
13391341
1340- if ( !ClientUserinfoChanged ( clientNum , "connect" ) ) {
1342+ if ( !ClientUserinfoChanged ( clientNum , "connect" , qfalse ) ) {
13411343 return ban_reason ;
13421344 }
13431345
@@ -1382,7 +1384,7 @@ const char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot )
13821384 client -> pers .connected = CON_CONNECTING ;
13831385 client -> pers .connectTime = level .time ;
13841386
1385- ClientUserinfoChanged ( clientNum , "connect" );
1387+ ClientUserinfoChanged ( clientNum , "connect" , qtrue );
13861388
13871389 // don't do the "xxx connected" messages if they were caried over from previous level
13881390 if ( firstTime ) {
@@ -1587,7 +1589,7 @@ qboolean ClientSpawn(gentity_t *ent) {
15871589 if ( client -> sess .sessionClass == Q3F_CLASS_MAX )
15881590 client -> ps .persistant [PERS_CURRCLASS ] = G_Q3F_SelectRandomClass ( client -> sess .sessionTeam , ent );
15891591 else client -> ps .persistant [PERS_CURRCLASS ] = client -> sess .sessionClass ;
1590- ClientUserinfoChanged ( client - level .clients , "spawn with new class" );
1592+ ClientUserinfoChanged ( client - level .clients , "spawn with new class" , qtrue );
15911593 }
15921594 }
15931595 else beginclass = qfalse ;
0 commit comments