mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-16 17:11:03 +00:00
Allow reading player models from pak / pk2 / pk3 / zip files.
This fixes #119. As always I've chosen the least invasive way to solve this problem. Trying to open players/$model/trix.md2 is hack, but solves the problem without changes to filesystem.c and it's API.
This commit is contained in:
parent
fb7c79c93b
commit
9af1af55a5
1 changed files with 10 additions and 35 deletions
|
@ -3783,38 +3783,15 @@ extern char **FS_ListFiles(char *, int *, unsigned, unsigned);
|
|||
static qboolean
|
||||
PlayerConfig_ScanDirectories(void)
|
||||
{
|
||||
char findname[1024];
|
||||
char scratch[1024];
|
||||
int ndirs = 0, npms = 0;
|
||||
char **dirnames = NULL;
|
||||
char *path = NULL;
|
||||
int i;
|
||||
|
||||
s_numplayermodels = 0;
|
||||
|
||||
/* get a list of directories */
|
||||
do
|
||||
{
|
||||
path = FS_NextPath(path);
|
||||
|
||||
/* If FS_NextPath returns NULL we get a SEGV on the next line.
|
||||
On other platforms this propably works (path becomes
|
||||
the null string or something like that). */
|
||||
if (path == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Com_sprintf(findname, sizeof(findname), "%s/players/*.*", path);
|
||||
|
||||
if ((dirnames = FS_ListFiles(findname, &ndirs, SFF_SUBDIR, 0)) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (path);
|
||||
|
||||
if (!dirnames)
|
||||
if ((dirnames = FS_ListFiles2("players/*", &ndirs, SFF_SUBDIR, 0)) == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -3833,6 +3810,7 @@ PlayerConfig_ScanDirectories(void)
|
|||
char *a, *b, *c;
|
||||
char **pcxnames;
|
||||
char **skinnames;
|
||||
fileHandle_t f;
|
||||
int npcxfiles;
|
||||
int nskins = 0;
|
||||
|
||||
|
@ -3845,23 +3823,22 @@ PlayerConfig_ScanDirectories(void)
|
|||
strcpy(scratch, dirnames[i]);
|
||||
strcat(scratch, "/tris.md2");
|
||||
|
||||
if (!Sys_FindFirst(scratch, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM))
|
||||
if (FS_FOpenFile(scratch, &f, false) == 0)
|
||||
{
|
||||
free(dirnames[i]);
|
||||
dirnames[i] = 0;
|
||||
Sys_FindClose();
|
||||
continue;
|
||||
}
|
||||
|
||||
Sys_FindClose();
|
||||
else
|
||||
{
|
||||
FS_FCloseFile(f);
|
||||
}
|
||||
|
||||
/* verify the existence of at least one pcx skin */
|
||||
strcpy(scratch, dirnames[i]);
|
||||
strcat(scratch, "/*.pcx");
|
||||
pcxnames = FS_ListFiles(scratch, &npcxfiles,
|
||||
0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM);
|
||||
|
||||
if (!pcxnames)
|
||||
if ((pcxnames = FS_ListFiles2(scratch, &npcxfiles, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM)) == NULL)
|
||||
{
|
||||
free(dirnames[i]);
|
||||
dirnames[i] = 0;
|
||||
|
@ -3941,10 +3918,8 @@ PlayerConfig_ScanDirectories(void)
|
|||
c = b;
|
||||
}
|
||||
|
||||
Q_strlcpy(s_pmi[s_numplayermodels].displayname, c + 1,
|
||||
sizeof(s_pmi[s_numplayermodels].displayname));
|
||||
Q_strlcpy(s_pmi[s_numplayermodels].directory, c + 1,
|
||||
sizeof(s_pmi[s_numplayermodels].directory));
|
||||
Q_strlcpy(s_pmi[s_numplayermodels].displayname, c + 1, sizeof(s_pmi[s_numplayermodels].displayname));
|
||||
Q_strlcpy(s_pmi[s_numplayermodels].directory, c + 1, sizeof(s_pmi[s_numplayermodels].directory));
|
||||
|
||||
FreeFileList(pcxnames, npcxfiles);
|
||||
|
||||
|
|
Loading…
Reference in a new issue