summaryrefslogtreecommitdiff
path: root/src/game/g_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/g_client.c')
-rw-r--r--src/game/g_client.c144
1 files changed, 91 insertions, 53 deletions
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 3d274ee..abdfa8e 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -910,7 +910,7 @@ team_t TeamCount( int ignoreClientNum, int team )
ClientCleanName
============
*/
-static void ClientCleanName( const char *in, char *out, int outSize, qboolean special )
+static void ClientCleanName( const char *in, char *out, int outSize )
{
int len, colorlessLen;
char ch;
@@ -957,8 +957,8 @@ static void ClientCleanName( const char *in, char *out, int outSize, qboolean sp
break;
}
- // don't allow black in a name, unless if special
- if( ColorIndex( *in ) == 0 && !special )
+ // don't allow black in a name, period
+ if( ColorIndex( *in ) == 0 )
*out++ = COLOR_WHITE;
else
*out++ = *in;
@@ -1154,11 +1154,7 @@ void ClientUserinfoChanged( int clientNum, qboolean forceName )
// set name
Q_strncpyz( oldname, client->pers.netname, sizeof( oldname ) );
s = Info_ValueForKey( userinfo, "name" );
-
- if ( !G_admin_permission( ent, ADMF_SPECIALNAME ) )
- ClientCleanName( s, newname, sizeof( newname ), qfalse );
- else
- ClientCleanName( s, newname, sizeof( newname ), qtrue );
+ ClientCleanName( s, newname, sizeof( newname ) );
if( strcmp( oldname, newname ) )
{
@@ -1166,10 +1162,7 @@ void ClientUserinfoChanged( int clientNum, qboolean forceName )
showRenameMsg = qfalse;
// in case we need to revert and there's no oldname
- if ( !G_admin_permission( ent, ADMF_SPECIALNAME ) )
- ClientCleanName( va( "%s", client->pers.netname ), oldname, sizeof( oldname ), qfalse );
- else
- ClientCleanName( va( "%s", client->pers.netname ), oldname, sizeof( oldname ), qtrue );
+ ClientCleanName( va( "%s", client->pers.netname ), oldname, sizeof( oldname ) );
if( g_newbieNumbering.integer )
{
@@ -1198,8 +1191,7 @@ void ClientUserinfoChanged( int clientNum, qboolean forceName )
revertName = qtrue;
}
else if( g_maxNameChanges.integer > 0
- && client->pers.nameChanges >= g_maxNameChanges.integer
- && !G_admin_permission( ent, ADMF_SPECIAL ) )
+ && client->pers.nameChanges >= g_maxNameChanges.integer )
{
trap_SendServerCommand( ent - g_entities, va(
"print \"Maximum name changes reached (g_maxNameChanges = %d)\n\"",
@@ -1248,7 +1240,8 @@ void ClientUserinfoChanged( int clientNum, qboolean forceName )
//dont show if players invisible
if( client->sess.invisible != qtrue )
trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE
- " renamed to %s^7\n\"", oldname, client->pers.netname ) );
+ " renamed to %s^7\n\"", oldname, client->pers.netname ) );
+
if( g_decolourLogfiles.integer)
{
char decoloured[ MAX_STRING_CHARS ] = "";
@@ -1367,17 +1360,18 @@ void ClientUserinfoChanged( int clientNum, qboolean forceName )
if ( client->sess.invisible != qtrue )
{
Com_sprintf( userinfo, sizeof( userinfo ),
- "n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\c1\\%s\\c2\\%s\\"
- "hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\"
- "tl\\%d\\ig\\%16s",
- client->pers.netname, team, model, model, c1, c2,
- client->pers.maxHealth, client->sess.wins, client->sess.losses, teamTask,
- teamLeader, BG_ClientListString( &client->sess.ignoreList ) );
+ "n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\c1\\%s\\c2\\%s\\"
+ "hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\"
+ "tl\\%d\\ig\\%16s",
+ client->pers.netname, team, model, model, c1, c2,
+ client->pers.maxHealth, client->sess.wins, client->sess.losses, teamTask,
+ teamLeader, BG_ClientListString( &client->sess.ignoreList ) );
trap_SetConfigstring( CS_PLAYERS + clientNum, userinfo );
} else {
trap_SetConfigstring( CS_PLAYERS + clientNum, "" );
}
+
/*G_LogPrintf( "ClientUserinfoChanged: %i %s\n", clientNum, userinfo );*/
}
@@ -1426,6 +1420,7 @@ char *ClientConnect( int clientNum, qboolean firstTime )
return va( "%s", reason );
}
+
// IP filtering
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=500
// recommanding PB based IP / GUID banning, the builtin system is pretty limited
@@ -1443,13 +1438,38 @@ char *ClientConnect( int clientNum, qboolean firstTime )
if( G_FilterPacket( value ) )
return "You are banned from this server.";
- if( ip[ 0 ] == 0 ||strlen( ip ) < 7 )
+ if( strlen( ip ) < 7 )
{
G_AdminsPrintf( "Connect from client with invalid IP: '%s' NAME: '%s^7'\n",
- ip, Info_ValueForKey( userinfo, "name" ) );
+ ip, Info_ValueForKey( userinfo, "name" ) );
return "Invalid client data";
}
+ // limit max clients per IP
+ if( g_maxGhosts.integer > 1 )
+ {
+ gclient_t *other;
+ int count = 0;
+
+ for( i = 0 ; i < level.maxclients; i++ )
+ {
+ other = &level.clients[ i ];
+ if( other &&
+ ( other->pers.connected == CON_CONNECTED || other->pers.connected == CON_CONNECTING ) &&
+ strcmp( ip, other->pers.ip ) == 0 )
+ {
+ count++;
+ }
+ }
+
+ if( count + 1 > g_maxGhosts.integer )
+ {
+ G_AdminsPrintf( "Connect from client exceeds %d maximum connections per IP: '%s' NAME: '%s^7'\n",
+ g_maxGhosts.integer, ip, Info_ValueForKey( userinfo, "name" ) );
+ return "Maximum simultaneous clients exceeded";
+ }
+ }
+
// check for a password
value = Info_ValueForKey( userinfo, "password" );
@@ -1464,7 +1484,7 @@ char *ClientConnect( int clientNum, qboolean firstTime )
memset( client, 0, sizeof(*client) );
// add guid to session so we don't have to keep parsing userinfo everywhere
- if( !guid[ 0 ] )
+ if( !guid[0] )
{
Q_strncpyz( client->pers.guid, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
sizeof( client->pers.guid ) );
@@ -1473,23 +1493,9 @@ char *ClientConnect( int clientNum, qboolean firstTime )
{
Q_strncpyz( client->pers.guid, guid, sizeof( client->pers.guid ) );
}
-
Q_strncpyz( client->pers.ip, ip, sizeof( client->pers.ip ) );
client->pers.adminLevel = G_admin_level( ent );
- // do autoghost now so that there won't be any name conflicts later on
- if ( g_autoGhost.integer && client->pers.guid[ 0 ] != 'X' )
- {
- for ( i = 0; i < MAX_CLIENTS; i++ )
- {
- if ( i != ent - g_entities && g_entities[i].client && g_entities[i].client->pers.connected != CON_DISCONNECTED && !Q_stricmp( g_entities[i].client->pers.guid, client->pers.guid ) )
- {
- trap_SendServerCommand( i, "disconnect \"You may not be connected to this server multiple times\"" );
- trap_DropClient( i, "disconnected" );
- }
- }
- }
-
client->pers.connected = CON_CONNECTING;
// read or initialize the session data
@@ -1545,7 +1551,6 @@ char *ClientConnect( int clientNum, qboolean firstTime )
CalculateRanks( );
G_admin_namelog_update( client, qfalse );
}
-
// if this is after !restart keepteams or !restart switchteams, apply said selection
if ( client->sess.restartTeam != PTE_NONE ) {
@@ -1602,35 +1607,58 @@ void ClientBegin( int clientNum )
// locate ent at a spawn point
ClientSpawn( ent, NULL, NULL, NULL );
-
+
// Ignore invisible players for this section:
if ( client->sess.invisible != qtrue )
{
trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname ) );
- // auto mute flag
- if( G_admin_permission( ent, ADMF_NO_CHAT ) )
- client->pers.muted = qtrue;
-
// name can change between ClientConnect() and ClientBegin()
G_admin_namelog_update( client, qfalse );
-
+
+ // rejoin any saved chat channels
+ G_admin_chat_sync( ent );
+
// request the clients PTR code
trap_SendServerCommand( ent - g_entities, "ptrcrequest" );
}
+
+ // auto mute flag
+ if( G_admin_permission( ent, ADMF_NO_CHAT ) )
+ client->pers.muted = qtrue;
+
+ if( g_karma.integer )
+ {
+ if( g_karma.integer > 1 &&
+ client->pers.adminLevel == 0 &&
+ client->pers.guid[0] != 'X' )
+ {
+ if( !(g_newbieNumbering.integer && g_newbieNamePrefix.string[ 0 ] &&
+ Q_stricmpn ( client->pers.netname, g_newbieNamePrefix.string,
+ strlen(g_newbieNamePrefix.string ) ) == 0 ) )
+ {
+ trap_SendConsoleCommand( EXEC_APPEND, va( "!l1 %d", clientNum ) );
+ trap_SendServerCommand( client->ps.clientNum,
+ "print \"^5The karma feature automatically !registers all players.\n\"" );
+ }
+ }
+ else if( client->pers.adminLevel > 0 &&
+ level.time - level.startTime > 60000 )
+ {
+ trap_SendServerCommand( client->ps.clientNum,
+ va( "print \"^5Welcome back, your karma is %d\n\"", client->pers.karma / 1000 ) );
+ }
+ }
+
G_LogPrintf( "ClientBegin: %i\n", clientNum );
if( g_clientUpgradeNotice.integer )
{
if( !Q_stricmp( ent->client->pers.guid, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) )
{
- trap_SendServerCommand( client->ps.clientNum, va( "print \"^3Your client is out of date. Updating your client will allow you to "
- "become an admin on servers and download maps much more quickly. Please replace your client executable with a newer client. \n\"" ) );
-
- trap_SendServerCommand( client->ps.clientNum, va("print \"^3Some available clients: \n"
- "^2TremFusion^7- ^3http://www.tremfusion.net/download/^7\n"
- "^2FSM-Trem^7 - ^3http://code.google.com/p/fsm-trem/^7\n"
- "^2MGClient^7 - ^3http://releases.mercenariesguild.net/client/^7\n\"" ) );
+ trap_SendServerCommand( client->ps.clientNum, va( "print \"^1Your client is out of date. Updating your client will allow you to "
+ "become an admin on servers and download maps much more quickly. Please replace your client executable with the one "
+ "at ^2http://trem.tjw.org/backport/^1 and reconnect. \n\"" ) );
}
}
@@ -1847,6 +1875,15 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
client->jetpackfuel = mod_jetpackFuel.value;
}
+ //free credits
+ if( g_freeCredits.integer && ent != spawn )
+ {
+ if( client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
+ client->ps.persistant[ PERS_CREDIT ] = ALIEN_MAX_KILLS;
+ else if( client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
+ client->ps.persistant[ PERS_CREDIT ] = HUMAN_MAX_CREDITS;
+ }
+
G_SetOrigin( ent, spawn_origin );
VectorCopy( spawn_origin, client->ps.origin );
@@ -1999,7 +2036,8 @@ void ClientDisconnect( int clientNum )
Q_strncpyz( ptr->name, ent->client->pers.netname, MAX_NETNAME );
}
}
-
+
+ //update namelog only if they are not invisible
if ( ent->client->sess.invisible != qtrue )
G_admin_namelog_update( ent->client, qtrue );
G_LeaveTeam( ent );