mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-29 23:32:03 +00:00
fixed the player name look-up behavior of kick, banUser, dumpuser
This commit is contained in:
parent
998ad98511
commit
8abb87e783
2 changed files with 47 additions and 24 deletions
|
@ -1,6 +1,9 @@
|
||||||
|
|
||||||
DD Mmm 17 - 1.49
|
DD Mmm 17 - 1.49
|
||||||
|
|
||||||
|
fix: improved the player name look-up behavior for these commands: kick, banUser, dumpuser
|
||||||
|
if 2 players had the same name, it would just pick the first one (lowest client number)
|
||||||
|
|
||||||
fix: multi-view mouse input sensitivity is now the same as in the UI for CPMA 1.50
|
fix: multi-view mouse input sensitivity is now the same as in the UI for CPMA 1.50
|
||||||
|
|
||||||
chg: replaced monitor gamma by a post-process gamma shader and removed r_ignorehwgamma
|
chg: replaced monitor gamma by a post-process gamma shader and removed r_ignorehwgamma
|
||||||
|
|
|
@ -37,10 +37,6 @@ These commands can only be entered from stdin or by a remote operator datagram
|
||||||
|
|
||||||
static client_t* SV_GetPlayerByHandle()
|
static client_t* SV_GetPlayerByHandle()
|
||||||
{
|
{
|
||||||
client_t *cl;
|
|
||||||
int i;
|
|
||||||
char cleanName[64];
|
|
||||||
|
|
||||||
// make sure server is running
|
// make sure server is running
|
||||||
if ( !com_sv_running->integer ) {
|
if ( !com_sv_running->integer ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -51,42 +47,66 @@ static client_t* SV_GetPlayerByHandle()
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* s = Cmd_Argv(1);
|
const char* const s = Cmd_Argv( 1 );
|
||||||
|
|
||||||
// Check whether this is a numeric player handle
|
// check whether this is a numeric player handle
|
||||||
for(i = 0; s[i] >= '0' && s[i] <= '9'; i++);
|
int i;
|
||||||
|
for ( i = 0; s[i] >= '0' && s[i] <= '9'; i++ );
|
||||||
if(!s[i])
|
|
||||||
{
|
if ( !s[i] ) {
|
||||||
int plid = atoi(s);
|
int plid = atoi(s);
|
||||||
|
|
||||||
// Check for numeric playerid match
|
// Check for numeric playerid match
|
||||||
if(plid >= 0 && plid < sv_maxclients->integer)
|
if ( plid >= 0 && plid < sv_maxclients->integer ) {
|
||||||
{
|
client_t* const cl = &svs.clients[plid];
|
||||||
cl = &svs.clients[plid];
|
|
||||||
|
|
||||||
if(cl->state)
|
if ( cl->state )
|
||||||
return cl;
|
return cl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char s2[64];
|
||||||
|
char n2[64];
|
||||||
|
Q_strncpyz( s2, s, sizeof(s2) );
|
||||||
|
Q_CleanStr( s2 );
|
||||||
|
|
||||||
|
int caseSensMatchCount = 0;
|
||||||
|
int caseInsMatchCount = 0;
|
||||||
|
int caseSensMatchIndex = -1;
|
||||||
|
int caseInsMatchIndex = -1;
|
||||||
|
client_t* cl = svs.clients;
|
||||||
|
|
||||||
// check for a name match
|
// check for a name match
|
||||||
for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) {
|
for ( i = 0; i < sv_maxclients->integer; i++, cl++ ) {
|
||||||
if ( !cl->state ) {
|
if ( !cl->state )
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if ( !Q_stricmp( cl->name, s ) ) {
|
Q_strncpyz( n2, cl->name, sizeof(n2) );
|
||||||
return cl;
|
Q_CleanStr( n2 );
|
||||||
|
|
||||||
|
if ( !strcmp( n2, s2 ) ) {
|
||||||
|
caseSensMatchIndex = i;
|
||||||
|
caseSensMatchCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_strncpyz( cleanName, cl->name, sizeof(cleanName) );
|
if ( !Q_stricmp( n2, s2 ) ) {
|
||||||
Q_CleanStr( cleanName );
|
caseInsMatchIndex = i;
|
||||||
if ( !Q_stricmp( cleanName, s ) ) {
|
caseInsMatchCount++;
|
||||||
return cl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Com_Printf( "Player %s is not on the server\n", s );
|
if (caseSensMatchCount == 1)
|
||||||
|
return svs.clients + caseSensMatchIndex;
|
||||||
|
|
||||||
|
if (caseInsMatchCount == 1)
|
||||||
|
return svs.clients + caseInsMatchIndex;
|
||||||
|
|
||||||
|
if (caseSensMatchCount > 1 || caseInsMatchCount > 1) {
|
||||||
|
Com_Printf( "More than 1 player with the name %s\n", s2 );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Com_Printf( "Player %s is not on the server\n", s2 );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue