Fix PK3 map folders in vres_GetMap
This commit is contained in:
parent
7d3987c51b
commit
1dec34c2e2
1 changed files with 25 additions and 1 deletions
26
src/w_wad.c
26
src/w_wad.c
|
|
@ -1016,6 +1016,19 @@ const char *W_CheckNameForNum(lumpnum_t lumpnum)
|
|||
return W_CheckNameForNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum));
|
||||
}
|
||||
|
||||
const char *W_CheckFullNameForNumPwad(UINT16 wad, UINT16 lump)
|
||||
{
|
||||
if (lump >= wadfiles[wad]->numlumps || !TestValidLump(wad, 0))
|
||||
return NULL;
|
||||
|
||||
return wadfiles[wad]->lumpinfo[lump].fullname;
|
||||
}
|
||||
|
||||
const char *W_CheckFullNameForNum(lumpnum_t lumpnum)
|
||||
{
|
||||
return W_CheckFullNameForNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum));
|
||||
}
|
||||
|
||||
//
|
||||
// wadid is a wad number
|
||||
// (Used for sprites loading)
|
||||
|
|
@ -2370,7 +2383,18 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
|||
{
|
||||
// Count number of lumps until the end of resource OR up until next "MAPXX" lump.
|
||||
lumpnum_t lumppos = lumpnum + 1;
|
||||
for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++)
|
||||
lumpnum_t lastlump = wadfiles[WADFILENUM(lumpnum)]->numlumps;
|
||||
// or the end of directory, for PK3 files
|
||||
if (wadfiles[WADFILENUM(lumpnum)]->type == RET_PK3)
|
||||
{
|
||||
const char *fullname = W_CheckFullNameForNum(lumpnum);
|
||||
const char *dirend = strrchr(fullname, '/');
|
||||
char *dirname = malloc(dirend - fullname + 2);
|
||||
strlcpy(dirname, fullname, dirend - fullname + 2);
|
||||
lastlump = W_CheckNumForFolderEndPK3(dirname, WADFILENUM(lumpnum), lumpnum);
|
||||
free(dirname);
|
||||
}
|
||||
for (i = LUMPNUM(lumppos); i < lastlump; i++, lumppos++, numlumps++)
|
||||
if (memcmp(W_CheckNameForNum(lumppos), "MAP", 3) == 0)
|
||||
break;
|
||||
numlumps++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue