MCPcopy Create free account
hub / github.com/JACoders/OpenJK / UI_BuildPlayerModel_List

Function UI_BuildPlayerModel_List

code/ui/ui_main.cpp:2445–2616  ·  view source on GitHub ↗

================= PlayerModel_BuildList ================= */

Source from the content-addressed store, hash-verified

2443=================
2444*/
2445static void UI_BuildPlayerModel_List( qboolean inGameLoad )
2446{
2447 static const size_t DIR_LIST_SIZE = 16384;
2448
2449 int numdirs;
2450 size_t dirListSize = DIR_LIST_SIZE;
2451 char stackDirList[8192];
2452 char *dirlist;
2453 char* dirptr;
2454 int dirlen;
2455 int i;
2456 const int building = Cvar_VariableIntegerValue("com_buildscript");
2457
2458 dirlist = (char *)malloc(DIR_LIST_SIZE);
2459 if ( !dirlist )
2460 {
2461 Com_Printf(S_COLOR_YELLOW "WARNING: Failed to allocate %u bytes of memory for player model "
2462 "directory list. Using stack allocated buffer of %u bytes instead.",
2463 DIR_LIST_SIZE, sizeof(stackDirList));
2464
2465 dirlist = stackDirList;
2466 dirListSize = sizeof(stackDirList);
2467 }
2468
2469 uiInfo.playerSpeciesCount = 0;
2470 uiInfo.playerSpeciesIndex = 0;
2471 uiInfo.playerSpeciesMax = 8;
2472 uiInfo.playerSpecies = (playerSpeciesInfo_t *)malloc(uiInfo.playerSpeciesMax * sizeof(playerSpeciesInfo_t));
2473
2474 // iterate directory of all player models
2475 numdirs = ui.FS_GetFileList("models/players", "/", dirlist, dirListSize );
2476 dirptr = dirlist;
2477 for (i=0; i<numdirs; i++,dirptr+=dirlen+1)
2478 {
2479 char* fileptr;
2480 int filelen;
2481 int f = 0;
2482 char fpath[MAX_QPATH];
2483
2484 dirlen = strlen(dirptr);
2485
2486 if (dirlen)
2487 {
2488 if (dirptr[dirlen-1]=='/')
2489 dirptr[dirlen-1]='\0';
2490 }
2491 else
2492 {
2493 continue;
2494 }
2495
2496 if (!strcmp(dirptr,".") || !strcmp(dirptr,".."))
2497 continue;
2498
2499 Com_sprintf(fpath, sizeof(fpath), "models/players/%s/PlayerChoice.txt", dirptr);
2500 filelen = ui.FS_FOpenFile(fpath, &f, FS_READ);
2501
2502 if (f)

Callers 1

_UI_InitFunction · 0.70

Calls 10

Q_strncpyzFunction · 0.85
IsImageFileFunction · 0.85
Q_stricmpnFunction · 0.85
UI_ParseColorDataFunction · 0.70
UI_FreeSpeciesFunction · 0.70
Com_PrintfFunction · 0.50
Com_sprintfFunction · 0.50
vaFunction · 0.50
COM_StripExtensionFunction · 0.50

Tested by

no test coverage detected