summaryrefslogtreecommitdiff
path: root/source/ui_playermodels.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2009-05-29 21:32:02 +0000
committerAndrey Nazarov <skuller@skuller.net>2009-05-29 21:32:02 +0000
commit3ef036028a652f979a4197dd4a2ddd779e437597 (patch)
tree42c11d1e5396509e41d3776b80eaca3660a998db /source/ui_playermodels.c
parent454fc2e2eb975e359696850f07c071aa0736aac7 (diff)
Ran all source files through expand(1).
Diffstat (limited to 'source/ui_playermodels.c')
-rw-r--r--source/ui_playermodels.c324
1 files changed, 162 insertions, 162 deletions
diff --git a/source/ui_playermodels.c b/source/ui_playermodels.c
index 58a60a8..eb18d68 100644
--- a/source/ui_playermodels.c
+++ b/source/ui_playermodels.c
@@ -30,216 +30,216 @@ PLAYER MODELS
*/
static const char baseWeaponNames[][32] = {
- "w_bfg.md2",
- "w_blaster.md2",
- "w_chaingun.md2",
- "w_glauncher.md2",
- "w_hyperblaster.md2",
- "w_machinegun.md2",
- "w_railgun.md2",
- "w_rlauncher.md2",
- "w_shotgun.md2",
- "w_sshotgun.md2"
+ "w_bfg.md2",
+ "w_blaster.md2",
+ "w_chaingun.md2",
+ "w_glauncher.md2",
+ "w_hyperblaster.md2",
+ "w_machinegun.md2",
+ "w_railgun.md2",
+ "w_rlauncher.md2",
+ "w_shotgun.md2",
+ "w_sshotgun.md2"
};
static const int numBaseWeaponNames = sizeof( baseWeaponNames ) / sizeof( baseWeaponNames[0] );
static qboolean IconOfSkinExists( char *skin, char **pcxfiles, int npcxfiles ) {
- int i;
- char scratch[MAX_OSPATH];
+ int i;
+ char scratch[MAX_OSPATH];
- COM_StripExtension( skin, scratch, sizeof( scratch ) );
- Q_strlcat( scratch, "_i.pcx", sizeof( scratch ) );
+ COM_StripExtension( skin, scratch, sizeof( scratch ) );
+ Q_strlcat( scratch, "_i.pcx", sizeof( scratch ) );
- for( i = 0 ; i < npcxfiles ; i++ ) {
- if( strcmp( pcxfiles[i], scratch ) == 0 )
- return qtrue;
- }
+ for( i = 0 ; i < npcxfiles ; i++ ) {
+ if( strcmp( pcxfiles[i], scratch ) == 0 )
+ return qtrue;
+ }
- return qfalse;
+ return qfalse;
}
static int QDECL pmicmpfnc( const void *_a, const void *_b ) {
- const playerModelInfo_t *a = (const playerModelInfo_t *)_a;
- const playerModelInfo_t *b = (const playerModelInfo_t *)_b;
+ const playerModelInfo_t *a = (const playerModelInfo_t *)_a;
+ const playerModelInfo_t *b = (const playerModelInfo_t *)_b;
- /*
- ** sort by male, female, then alphabetical
- */
- if( strcmp( a->directory, "male" ) == 0 )
- return -1;
- else if( strcmp( b->directory, "male" ) == 0 )
- return 1;
+ /*
+ ** sort by male, female, then alphabetical
+ */
+ if( strcmp( a->directory, "male" ) == 0 )
+ return -1;
+ else if( strcmp( b->directory, "male" ) == 0 )
+ return 1;
- if( strcmp( a->directory, "female" ) == 0 )
- return -1;
- else if( strcmp( b->directory, "female" ) == 0 )
- return 1;
+ if( strcmp( a->directory, "female" ) == 0 )
+ return -1;
+ else if( strcmp( b->directory, "female" ) == 0 )
+ return 1;
- return strcmp( a->directory, b->directory );
+ return strcmp( a->directory, b->directory );
}
void PlayerModel_Load( void ) {
- char scratch[MAX_QPATH];
- int ndirs = 0;
- char *dirnames[MAX_PLAYERMODELS];
- int i, j;
- char **list;
- char *p;
- int numFiles;
- playerModelInfo_t *pmi;
+ char scratch[MAX_QPATH];
+ int ndirs = 0;
+ char *dirnames[MAX_PLAYERMODELS];
+ int i, j;
+ char **list;
+ char *p;
+ int numFiles;
+ playerModelInfo_t *pmi;
- uis.numPlayerModels = 0;
+ uis.numPlayerModels = 0;
- /*
- ** get a list of directories
- */
- if( !( list = ( char ** )FS_ListFiles( NULL, "players/*/*", FS_SEARCH_BYFILTER|FS_SEARCH_SAVEPATH, &numFiles ) ) ) {
- return;
- }
+ /*
+ ** get a list of directories
+ */
+ if( !( list = ( char ** )FS_ListFiles( NULL, "players/*/*", FS_SEARCH_BYFILTER|FS_SEARCH_SAVEPATH, &numFiles ) ) ) {
+ return;
+ }
- for( i = 0; i < numFiles; i++ ) {
- Q_strlcpy( scratch, list[i] + 8, sizeof( scratch ) );
- if( ( p = strchr( scratch, '/' ) ) ) {
- *p = 0;
- }
+ for( i = 0; i < numFiles; i++ ) {
+ Q_strlcpy( scratch, list[i] + 8, sizeof( scratch ) );
+ if( ( p = strchr( scratch, '/' ) ) ) {
+ *p = 0;
+ }
- for( j = 0; j < ndirs; j++ ) {
- if( !strcmp( dirnames[j], scratch ) ) {
- break;
- }
- }
+ for( j = 0; j < ndirs; j++ ) {
+ if( !strcmp( dirnames[j], scratch ) ) {
+ break;
+ }
+ }
- if( j != ndirs ) {
- continue;
- }
-
- dirnames[ndirs++] = UI_CopyString( scratch );
- if( ndirs == MAX_PLAYERMODELS ) {
- break;
- }
- }
+ if( j != ndirs ) {
+ continue;
+ }
+
+ dirnames[ndirs++] = UI_CopyString( scratch );
+ if( ndirs == MAX_PLAYERMODELS ) {
+ break;
+ }
+ }
- FS_FreeList( ( void ** )list );
+ FS_FreeList( ( void ** )list );
- if( !ndirs ) {
- return;
- }
+ if( !ndirs ) {
+ return;
+ }
- /*
- ** go through the subdirectories
- */
+ /*
+ ** go through the subdirectories
+ */
- for( i = 0; i < ndirs; i++ ) {
- int k, s;
- char **pcxnames;
- char **skinnames;
- int npcxfiles;
- int nskins = 0;
- int numWeapons;
- char **weaponNames;
+ for( i = 0; i < ndirs; i++ ) {
+ int k, s;
+ char **pcxnames;
+ char **skinnames;
+ int npcxfiles;
+ int nskins = 0;
+ int numWeapons;
+ char **weaponNames;
- // verify the existence of tris.md2
- Q_concat( scratch, sizeof( scratch ), "players/", dirnames[i], "/tris.md2", NULL );
- if( FS_LoadFile( scratch, NULL ) == INVALID_LENGTH ) {
- continue;
- }
+ // verify the existence of tris.md2
+ Q_concat( scratch, sizeof( scratch ), "players/", dirnames[i], "/tris.md2", NULL );
+ if( FS_LoadFile( scratch, NULL ) == INVALID_LENGTH ) {
+ continue;
+ }
- // verify the existence of at least one pcx skin
- Q_concat( scratch, sizeof( scratch ), "players/", dirnames[i], NULL );
- pcxnames = ( char ** )FS_ListFiles( scratch, ".pcx", 0, &npcxfiles );
- if( !pcxnames ) {
- continue;
- }
+ // verify the existence of at least one pcx skin
+ Q_concat( scratch, sizeof( scratch ), "players/", dirnames[i], NULL );
+ pcxnames = ( char ** )FS_ListFiles( scratch, ".pcx", 0, &npcxfiles );
+ if( !pcxnames ) {
+ continue;
+ }
- // count valid skins, which consist of a skin with a matching "_i" icon
- for( k = 0; k < npcxfiles; k++ ) {
- if( !strstr( pcxnames[k], "_i.pcx" ) ) {
- if( IconOfSkinExists( pcxnames[k], pcxnames, npcxfiles ) ) {
- nskins++;
- }
- }
- }
+ // count valid skins, which consist of a skin with a matching "_i" icon
+ for( k = 0; k < npcxfiles; k++ ) {
+ if( !strstr( pcxnames[k], "_i.pcx" ) ) {
+ if( IconOfSkinExists( pcxnames[k], pcxnames, npcxfiles ) ) {
+ nskins++;
+ }
+ }
+ }
- if( !nskins ) {
- FS_FreeList( ( void ** )pcxnames );
- continue;
- }
+ if( !nskins ) {
+ FS_FreeList( ( void ** )pcxnames );
+ continue;
+ }
- skinnames = UI_Malloc( sizeof( char * ) * ( nskins + 1 ) );
+ skinnames = UI_Malloc( sizeof( char * ) * ( nskins + 1 ) );
skinnames[nskins] = NULL;
- // copy the valid skins
- for( s = 0, k = 0; k < npcxfiles; k++ ) {
- if( !strstr( pcxnames[k], "_i.pcx" ) ) {
- if( IconOfSkinExists( pcxnames[k], pcxnames, npcxfiles ) ) {
- COM_StripExtension( pcxnames[k], scratch, sizeof( scratch ) );
- skinnames[s++] = UI_CopyString( scratch );
- }
- }
- }
+ // copy the valid skins
+ for( s = 0, k = 0; k < npcxfiles; k++ ) {
+ if( !strstr( pcxnames[k], "_i.pcx" ) ) {
+ if( IconOfSkinExists( pcxnames[k], pcxnames, npcxfiles ) ) {
+ COM_StripExtension( pcxnames[k], scratch, sizeof( scratch ) );
+ skinnames[s++] = UI_CopyString( scratch );
+ }
+ }
+ }
- FS_FreeList( ( void ** )pcxnames );
+ FS_FreeList( ( void ** )pcxnames );
- // load vweap models
- Q_concat( scratch, sizeof( scratch ), "players/", dirnames[i], "/w_*.md2", NULL );
- weaponNames = ( char ** )FS_ListFiles( NULL, scratch, FS_SEARCH_BYFILTER, &numWeapons );
+ // load vweap models
+ Q_concat( scratch, sizeof( scratch ), "players/", dirnames[i], "/w_*.md2", NULL );
+ weaponNames = ( char ** )FS_ListFiles( NULL, scratch, FS_SEARCH_BYFILTER, &numWeapons );
- pmi = &uis.pmi[uis.numPlayerModels++];
- pmi->numWeapons = 0;
+ pmi = &uis.pmi[uis.numPlayerModels++];
+ pmi->numWeapons = 0;
- if( weaponNames ) {
- pmi->weaponNames = UI_Malloc( sizeof( char * ) * numWeapons );
+ if( weaponNames ) {
+ pmi->weaponNames = UI_Malloc( sizeof( char * ) * numWeapons );
- for( j = 0; j < numWeapons ; j++ ) {
- for( k = 0; k < numBaseWeaponNames; k++ ) {
- if( !strcmp( weaponNames[j], baseWeaponNames[k] ) ) {
- pmi->weaponNames[pmi->numWeapons++] = UI_CopyString( weaponNames[j] );
- break;
- }
- }
- }
+ for( j = 0; j < numWeapons ; j++ ) {
+ for( k = 0; k < numBaseWeaponNames; k++ ) {
+ if( !strcmp( weaponNames[j], baseWeaponNames[k] ) ) {
+ pmi->weaponNames[pmi->numWeapons++] = UI_CopyString( weaponNames[j] );
+ break;
+ }
+ }
+ }
- FS_FreeList( ( void ** )weaponNames );
- }
+ FS_FreeList( ( void ** )weaponNames );
+ }
- // at this point we have a valid player model
- pmi->nskins = nskins;
- pmi->skindisplaynames = skinnames;
+ // at this point we have a valid player model
+ pmi->nskins = nskins;
+ pmi->skindisplaynames = skinnames;
- // make short name for the model
- strcpy( pmi->directory, dirnames[i] );
- }
+ // make short name for the model
+ strcpy( pmi->directory, dirnames[i] );
+ }
- for( i = 0; i < ndirs; i++ ) {
- Z_Free( dirnames[i] );
- }
+ for( i = 0; i < ndirs; i++ ) {
+ Z_Free( dirnames[i] );
+ }
- qsort( uis.pmi, uis.numPlayerModels, sizeof( uis.pmi[0] ), pmicmpfnc );
+ qsort( uis.pmi, uis.numPlayerModels, sizeof( uis.pmi[0] ), pmicmpfnc );
}
void PlayerModel_Free( void ) {
- playerModelInfo_t *pmi;
- int i, j;
+ playerModelInfo_t *pmi;
+ int i, j;
- for( i = 0, pmi = uis.pmi; i < uis.numPlayerModels; i++, pmi++ ) {
- if( pmi->skindisplaynames ) {
- for( j = 0; j < pmi->nskins; j++ ) {
- Z_Free( pmi->skindisplaynames[j] );
- }
- Z_Free( pmi->skindisplaynames );
- }
- if( pmi->weaponNames ) {
- for( j = 0; j < pmi->numWeapons; j++ ) {
- Z_Free( pmi->weaponNames[j] );
- }
- Z_Free( pmi->weaponNames );
- }
- memset( pmi, 0, sizeof( *pmi ) );
- }
+ for( i = 0, pmi = uis.pmi; i < uis.numPlayerModels; i++, pmi++ ) {
+ if( pmi->skindisplaynames ) {
+ for( j = 0; j < pmi->nskins; j++ ) {
+ Z_Free( pmi->skindisplaynames[j] );
+ }
+ Z_Free( pmi->skindisplaynames );
+ }
+ if( pmi->weaponNames ) {
+ for( j = 0; j < pmi->numWeapons; j++ ) {
+ Z_Free( pmi->weaponNames[j] );
+ }
+ Z_Free( pmi->weaponNames );
+ }
+ memset( pmi, 0, sizeof( *pmi ) );
+ }
- uis.numPlayerModels = 0;
+ uis.numPlayerModels = 0;
}
-
+