diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_misc.c | 39 | ||||
-rw-r--r-- | src/game/bg_public.h | 2 | ||||
-rw-r--r-- | src/game/g_main.c | 2 |
3 files changed, 35 insertions, 8 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 244ee482..270ae89b 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -3861,18 +3861,19 @@ weapon_t BG_PrimaryWeapon( int stats[ ] ) BG_LoadEmoticons ============ */ -int BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ] ) +int BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ], int widths[ ] ) { int numFiles; - char fileList[ MAX_EMOTICONS * ( MAX_EMOTICON_NAME_LEN + 5 ) ] = {""}; + char fileList[ MAX_EMOTICONS * ( MAX_EMOTICON_NAME_LEN + 9 ) ] = {""}; int i; char *filePtr; int fileLen; - char emoticon[ MAX_EMOTICON_NAME_LEN + 5 ] = {""}; + char emoticon[ MAX_EMOTICON_NAME_LEN + 9 ] = {""}; int loaded = 0; int count; + int width = 0; - numFiles = trap_FS_GetFileList( "emoticons", ".tga", fileList, + numFiles = trap_FS_GetFileList( "emoticons", "x1.tga", fileList, sizeof( fileList ) ); if( numFiles < 1 ) @@ -3890,12 +3891,18 @@ int BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ] ) } fileLen = strlen( filePtr ); - if( fileLen > MAX_EMOTICON_NAME_LEN + 5 ) + if( fileLen > MAX_EMOTICON_NAME_LEN + 8 ) { 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", + filePtr ); + continue; + } if( !trap_FS_FOpenFile( va( "emoticons/%s", filePtr ), NULL, FS_READ ) ) { Com_Printf( S_COLOR_YELLOW "WARNING: BG_LoadEmoticons(): detected " @@ -3903,10 +3910,30 @@ int BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ] ) filePtr ); break; } + Q_strncpyz( emoticon, filePtr, sizeof( emoticon ) ); - emoticon[ fileLen - 4 ] = '\0'; + + if( emoticon[ fileLen - 8 ] != '_' ) + { + Com_Printf( S_COLOR_YELLOW "WARNING: skipping \"%s\", filename invalid", + filePtr ); + continue; + } + + width = atoi( va( "%c", emoticon[ fileLen - 7 ] ) ); + + if( width < 1 || width > 9 ) + { + Com_Printf( S_COLOR_YELLOW "WARNING: skipping \"%s\", invalid width", + filePtr ); + continue; + } + + emoticon[ fileLen - 8 ] = '\0'; Q_strncpyz( names[ count ], emoticon, sizeof( names[ count ] ) ); + if( widths ) + widths[ count ] = width; count++; loaded = count; } diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 2a6f1874..4547bb80 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -1298,4 +1298,4 @@ 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 BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ], int widths[ ] ); diff --git a/src/game/g_main.c b/src/game/g_main.c index e3db3c23..42f07eda 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -607,7 +607,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 ); + level.emoticonCount = BG_LoadEmoticons( level.emoticons, NULL ); trap_SetConfigstring( CS_INTERMISSION, "0" ); |