diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_misc.c | 62 | ||||
-rw-r--r-- | src/game/bg_public.h | 2 | ||||
-rw-r--r-- | src/game/g_client.c | 12 | ||||
-rw-r--r-- | src/game/g_cmds.c | 43 | ||||
-rw-r--r-- | src/game/g_local.h | 4 | ||||
-rw-r--r-- | src/game/g_main.c | 2 | ||||
-rw-r--r-- | src/game/g_team.c | 23 | ||||
-rw-r--r-- | src/game/g_utils.c | 25 |
8 files changed, 52 insertions, 121 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 0859a7af..0c23befc 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -3875,17 +3875,14 @@ weapon_t BG_PrimaryWeapon( int stats[ ] ) BG_LoadEmoticons ============ */ -int BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ], int widths[ ] ) +int BG_LoadEmoticons( emoticon_t *emoticons, int num ) { int numFiles; char fileList[ MAX_EMOTICONS * ( MAX_EMOTICON_NAME_LEN + 9 ) ] = {""}; int i; char *filePtr; int fileLen; - char emoticon[ MAX_EMOTICON_NAME_LEN + 9 ] = {""}; - int loaded = 0; int count; - int width = 0; numFiles = trap_FS_GetFileList( "emoticons", "x1.tga", fileList, sizeof( fileList ) ); @@ -3896,65 +3893,38 @@ int BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ], int widths[ ] ) filePtr = fileList; fileLen = 0; count = 0; - for( i = 0; i < numFiles; i++, filePtr += fileLen + 1 ) + for( i = 0; i < numFiles && count < num; i++, filePtr += fileLen + 1 ) { - if( count >= MAX_EMOTICONS ) - { - count++; - continue; - } - fileLen = strlen( filePtr ); - if( fileLen > MAX_EMOTICON_NAME_LEN + 8 ) + if( fileLen < 9 || filePtr[ fileLen - 8 ] != '_' || + filePtr[ fileLen - 7 ] < '1' || filePtr[ fileLen - 7 ] > '9' ) { - Com_Printf( S_COLOR_YELLOW "WARNING: MAX_EMOTICON_NAME_LEN is %d. " - "skipping \"%s\", filename too long", MAX_EMOTICON_NAME_LEN, filePtr ); - continue; - } - if( fileLen < 9 ) - { - Com_Printf( S_COLOR_YELLOW "WARNING: skipping \"%s\", filename too short", + Com_Printf( S_COLOR_YELLOW "skipping invalidly named emoticon \"%s\"\n", filePtr ); continue; } - if( !trap_FS_FOpenFile( va( "emoticons/%s", filePtr ), NULL, FS_READ ) ) + if( fileLen - 8 > MAX_EMOTICON_NAME_LEN ) { - Com_Printf( S_COLOR_YELLOW "WARNING: BG_LoadEmoticons(): detected " - " an unreadable .tga file name \"emoticons/%s\" in emoticon detection", - filePtr ); - break; - } - - Q_strncpyz( emoticon, filePtr, sizeof( emoticon ) ); - - if( emoticon[ fileLen - 8 ] != '_' ) - { - Com_Printf( S_COLOR_YELLOW "WARNING: skipping \"%s\", filename invalid", - filePtr ); + Com_Printf( S_COLOR_YELLOW "emoticon file name \"%s\" too long (>%d)\n", + filePtr, MAX_EMOTICON_NAME_LEN + 8 ); continue; } - - width = emoticon[ fileLen - 7 ] - '0'; - - if( width < 1 || width > 9 ) + if( !trap_FS_FOpenFile( va( "emoticons/%s", filePtr ), NULL, FS_READ ) ) { - Com_Printf( S_COLOR_YELLOW "WARNING: skipping \"%s\", invalid width", - filePtr ); + Com_Printf( S_COLOR_YELLOW "could not open \"emoticons/%s\"\n", filePtr ); continue; } - emoticon[ fileLen - 8 ] = '\0'; - - Q_strncpyz( names[ count ], emoticon, sizeof( names[ count ] ) ); - if( widths ) - widths[ count ] = width; + Q_strncpyz( emoticons[ count ].name, filePtr, fileLen - 8 + 1 ); +#ifndef GAME + emoticons[ count ].width = filePtr[ fileLen - 7 ] - '0'; +#endif count++; - loaded = count; } Com_Printf( "Loaded %d of %d emoticons (MAX_EMOTICONS is %d)\n", - loaded, count, MAX_EMOTICONS ); - return loaded; + count, numFiles, MAX_EMOTICONS ); + return count; } /* diff --git a/src/game/bg_public.h b/src/game/bg_public.h index c9c752e0..6fd949ff 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -1302,7 +1302,7 @@ voiceTrack_t *BG_VoiceTrackFind( voiceTrack_t *head, team_t team, class_t class, weapon_t weapon, int enthusiasm, int *trackNum ); -int BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ], int widths[ ] ); +int BG_LoadEmoticons( emoticon_t *emoticons, int num ); char *BG_TeamName( team_t team ); diff --git a/src/game/g_client.c b/src/game/g_client.c index f3426d42..b6f1ab61 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -785,7 +785,7 @@ static qboolean G_IsEmoticon( const char *s, qboolean *escaped ) { for( j = 0; j < level.emoticonCount; j++ ) { - if( !Q_stricmp( emoticon, level.emoticons[ j ] ) ) + if( !Q_stricmp( emoticon, level.emoticons[ j ].name ) ) { *escaped = escape; return qtrue; @@ -1014,16 +1014,16 @@ void ClientUserinfoChanged( int clientNum ) if( strcmp( oldname, newname ) ) { if( client->pers.nameChangeTime && - ( level.time - client->pers.nameChangeTime ) - <= ( g_minNameChangePeriod.value * 1000 ) ) + level.time - client->pers.nameChangeTime <= + g_minNameChangePeriod.value * 1000 ) { trap_SendServerCommand( ent - g_entities, va( "print \"Name change spam protection (g_minNameChangePeriod = %d)\n\"", g_minNameChangePeriod.integer ) ); revertName = qtrue; } - else if( g_maxNameChanges.integer > 0 - && client->pers.nameChanges >= g_maxNameChanges.integer ) + else if( g_maxNameChanges.integer > 0 && + client->pers.nameChanges >= g_maxNameChanges.integer ) { trap_SendServerCommand( ent - g_entities, va( "print \"Maximum name changes reached (g_maxNameChanges = %d)\n\"", @@ -1154,7 +1154,7 @@ void ClientUserinfoChanged( int clientNum ) client->pers.teamInfo = qtrue; else client->pers.teamInfo = qfalse; - + s = Info_ValueForKey( userinfo, "cg_unlagged" ); if( !s[0] || atoi( s ) != 0 ) client->pers.useUnlagged = qtrue; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 4c3067ed..d6774950 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -32,29 +32,10 @@ Remove color codes and non-alphanumeric characters from a string */ void G_SanitiseString( char *in, char *out, int len ) { - qboolean skip = qtrue; - int spaces = 0; - len--; while( *in && len > 0 ) { - // strip leading white space - if( *in == ' ' ) - { - if( skip ) - { - in++; - continue; - } - spaces++; - } - else - { - spaces = 0; - skip = qfalse; - } - if( Q_IsColorString( in ) ) { in += 2; // skip color code @@ -68,7 +49,6 @@ void G_SanitiseString( char *in, char *out, int len ) } in++; } - out -= spaces; *out = 0; } @@ -551,10 +531,6 @@ void Cmd_Team_f( gentity_t *ent ) int aliens = level.numAlienClients; int humans = level.numHumanClients; - // stop team join spam - if( level.time - ent->client->pers.teamChangeTime < 1000 ) - return; - if( oldteam == TEAM_ALIENS ) aliens--; else if( oldteam == TEAM_HUMANS ) @@ -571,8 +547,8 @@ void Cmd_Team_f( gentity_t *ent ) if( !s[ 0 ] ) { - trap_SendServerCommand( ent-g_entities, va( "print \"team: %i\n\"", - oldteam ) ); + trap_SendServerCommand( ent-g_entities, va( "print \"team: %s\n\"", + BG_TeamName( oldteam ) ) ); return; } @@ -782,19 +758,6 @@ static void Cmd_SayArea_f( gentity_t *ent ) vec3_t mins, maxs; char *msg; - if( ent->client->pers.teamSelection == TEAM_NONE ) - { - G_TriggerMenu( ent - g_entities, MN_CMD_TEAM ); - return; - } - - if( ent->client->ps.stats[ STAT_HEALTH ] <= 0 || - ent->client->sess.spectatorState != SPECTATOR_NOT ) - { - G_TriggerMenu( ent - g_entities, MN_CMD_LIVING ); - return; - } - if( trap_Argc( ) < 2 ) { ADMP( "usage: say_area [message]\n" ); @@ -3213,7 +3176,7 @@ void Cmd_PrivateMessage_f( gentity_t *ent ) return; } - if( !Q_stricmp( cmd, "mt" ) || !Q_stricmp( cmd, "/mt" ) ) + if( !Q_stricmp( cmd, "mt" ) ) teamonly = qtrue; trap_Argv( 1, name, sizeof( name ) ); diff --git a/src/game/g_local.h b/src/game/g_local.h index b317bba9..83e0c557 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -631,7 +631,7 @@ typedef struct voice_t *voices; - char emoticons[ MAX_EMOTICONS ][ MAX_EMOTICON_NAME_LEN ]; + emoticon_t emoticons[ MAX_EMOTICONS ]; int emoticonCount; } level_locals_t; @@ -784,7 +784,6 @@ int G_ParticleSystemIndex( char *name ); int G_ShaderIndex( char *name ); int G_ModelIndex( char *name ); int G_SoundIndex( char *name ); -void G_TeamCommand( team_t team, char *cmd ); void G_KillBox (gentity_t *ent); gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match); gentity_t *G_PickTarget (char *targetname); @@ -992,6 +991,7 @@ void G_RunClient( gentity_t *ent ); // g_team.c // team_t G_TeamFromString( char *str ); +void G_TeamCommand( team_t team, char *cmd ); qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 ); void G_LeaveTeam( gentity_t *self ); void G_ChangeTeam( gentity_t *ent, team_t newTeam ); diff --git a/src/game/g_main.c b/src/game/g_main.c index 0e1df90e..0a2a37bd 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -582,7 +582,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) trap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ), &level.clients[ 0 ].ps, sizeof( level.clients[ 0 ] ) ); - level.emoticonCount = BG_LoadEmoticons( level.emoticons, NULL ); + level.emoticonCount = BG_LoadEmoticons( level.emoticons, MAX_EMOTICONS ); trap_SetConfigstring( CS_INTERMISSION, "0" ); diff --git a/src/game/g_team.c b/src/game/g_team.c index 3f95f533..dec34e9a 100644 --- a/src/game/g_team.c +++ b/src/game/g_team.c @@ -63,6 +63,29 @@ team_t G_TeamFromString( char *str ) } /* +================ +G_TeamCommand + +Broadcasts a command to only a specific team +================ +*/ +void G_TeamCommand( team_t team, char *cmd ) +{ + int i; + + for( i = 0 ; i < level.maxclients ; i++ ) + { + if( level.clients[ i ].pers.connected == CON_CONNECTED ) + { + if( level.clients[ i ].pers.teamSelection == team || + ( level.clients[ i ].pers.teamSelection == TEAM_NONE && + G_admin_permission( &g_entities[ i ], ADMF_SPEC_ALLCHAT ) ) ) + trap_SendServerCommand( i, cmd ); + } + } +} + +/* ============== OnSameTeam ============== diff --git a/src/game/g_utils.c b/src/game/g_utils.c index 00ec630a..9de86337 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -144,31 +144,6 @@ int G_SoundIndex( char *name ) //===================================================================== - -/* -================ -G_TeamCommand - -Broadcasts a command to only a specific team -================ -*/ -void G_TeamCommand( team_t team, char *cmd ) -{ - int i; - - for( i = 0 ; i < level.maxclients ; i++ ) - { - if( level.clients[ i ].pers.connected == CON_CONNECTED ) - { - if( level.clients[ i ].pers.teamSelection == team || - ( level.clients[ i ].pers.teamSelection == TEAM_NONE && - G_admin_permission( &g_entities[ i ], ADMF_SPEC_ALLCHAT ) ) ) - trap_SendServerCommand( i, cmd ); - } - } -} - - /* ============= G_Find |