mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-27 03:30:50 +00:00
Merge branch 'pk3-folders-are-not-textures-backport' into 'next'
Pk3 folders are not textures! See merge request STJr/SRB2!502
This commit is contained in:
commit
f7357a02ae
3 changed files with 60 additions and 20 deletions
63
src/r_data.c
63
src/r_data.c
|
@ -404,16 +404,7 @@ void R_LoadTextures(void)
|
||||||
// but the alternative is to spend a ton of time checking and re-checking all previous entries just to skip any potentially patched textures.
|
// but the alternative is to spend a ton of time checking and re-checking all previous entries just to skip any potentially patched textures.
|
||||||
for (w = 0, numtextures = 0; w < numwadfiles; w++)
|
for (w = 0, numtextures = 0; w < numwadfiles; w++)
|
||||||
{
|
{
|
||||||
if (wadfiles[w]->type == RET_PK3)
|
// Count the textures from TEXTURES lumps
|
||||||
{
|
|
||||||
texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0);
|
|
||||||
texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0) + 1;
|
|
||||||
texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0);
|
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0);
|
||||||
while (texturesLumpPos != INT16_MAX)
|
while (texturesLumpPos != INT16_MAX)
|
||||||
|
@ -422,19 +413,43 @@ void R_LoadTextures(void)
|
||||||
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, texturesLumpPos + 1);
|
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, texturesLumpPos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all the textures between TX_START and TX_END
|
// Count single-patch textures
|
||||||
if (texstart != INT16_MAX && texend != INT16_MAX)
|
|
||||||
|
if (wadfiles[w]->type == RET_PK3)
|
||||||
|
{
|
||||||
|
texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0);
|
||||||
|
texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0);
|
||||||
|
texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (texstart == INT16_MAX || texend == INT16_MAX)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
texstart++; // Do not count the first marker
|
||||||
|
|
||||||
|
// PK3s have subfolders, so we can't just make a simple sum
|
||||||
|
if (wadfiles[w]->type == RET_PK3)
|
||||||
|
{
|
||||||
|
for (j = texstart; j < texend; j++)
|
||||||
|
{
|
||||||
|
if (!W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it
|
||||||
|
numtextures++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Add all the textures between TX_START and TX_END
|
||||||
{
|
{
|
||||||
numtextures += (UINT32)(texend - texstart);
|
numtextures += (UINT32)(texend - texstart);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no textures found by this point, bomb out
|
|
||||||
if (!numtextures && w == (numwadfiles - 1))
|
|
||||||
{
|
|
||||||
I_Error("No textures detected in any WADs!\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no textures found by this point, bomb out
|
||||||
|
if (!numtextures)
|
||||||
|
I_Error("No textures detected in any WADs!\n");
|
||||||
|
|
||||||
// Allocate memory and initialize to 0 for all the textures we are initialising.
|
// Allocate memory and initialize to 0 for all the textures we are initialising.
|
||||||
// There are actually 5 buffers allocated in one for convenience.
|
// There are actually 5 buffers allocated in one for convenience.
|
||||||
textures = Z_Calloc((numtextures * sizeof(void *)) * 5, PU_STATIC, NULL);
|
textures = Z_Calloc((numtextures * sizeof(void *)) * 5, PU_STATIC, NULL);
|
||||||
|
@ -469,7 +484,7 @@ void R_LoadTextures(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0) + 1;
|
texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0);
|
||||||
texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0);
|
texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0);
|
||||||
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0);
|
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0);
|
||||||
if (texturesLumpPos != INT16_MAX)
|
if (texturesLumpPos != INT16_MAX)
|
||||||
|
@ -479,9 +494,16 @@ void R_LoadTextures(void)
|
||||||
if (texstart == INT16_MAX || texend == INT16_MAX)
|
if (texstart == INT16_MAX || texend == INT16_MAX)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
texstart++; // Do not count the first marker
|
||||||
|
|
||||||
// Work through each lump between the markers in the WAD.
|
// Work through each lump between the markers in the WAD.
|
||||||
for (j = 0; j < (texend - texstart); i++, j++)
|
for (j = 0; j < (texend - texstart); j++)
|
||||||
{
|
{
|
||||||
|
if (wadfiles[w]->type == RET_PK3)
|
||||||
|
{
|
||||||
|
if (W_IsLumpFolder((UINT16)w, texstart + j)) // Check if lump is a folder
|
||||||
|
continue; // If it is then SKIP IT
|
||||||
|
}
|
||||||
patchlump = W_CacheLumpNumPwad((UINT16)w, texstart + j, PU_CACHE);
|
patchlump = W_CacheLumpNumPwad((UINT16)w, texstart + j, PU_CACHE);
|
||||||
|
|
||||||
// Then, check the lump directly to see if it's a texture SOC,
|
// Then, check the lump directly to see if it's a texture SOC,
|
||||||
|
@ -520,6 +542,7 @@ void R_LoadTextures(void)
|
||||||
texturewidthmask[i] = k - 1;
|
texturewidthmask[i] = k - 1;
|
||||||
textureheight[i] = texture->height << FRACBITS;
|
textureheight[i] = texture->height << FRACBITS;
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
src/w_wad.c
16
src/w_wad.c
|
@ -1153,6 +1153,22 @@ boolean W_IsLumpWad(lumpnum_t lumpnum)
|
||||||
return false; // WADs should never be inside non-PK3s as far as SRB2 is concerned
|
return false; // WADs should never be inside non-PK3s as far as SRB2 is concerned
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// W_IsLumpFolder
|
||||||
|
// Is the lump a folder? (in a PK3 obviously)
|
||||||
|
//
|
||||||
|
boolean W_IsLumpFolder(UINT16 wad, UINT16 lump)
|
||||||
|
{
|
||||||
|
if (wadfiles[wad]->type == RET_PK3)
|
||||||
|
{
|
||||||
|
const char *name = wadfiles[wad]->lumpinfo[lump].name2;
|
||||||
|
|
||||||
|
return (name[strlen(name)-1] == '/'); // folders end in '/'
|
||||||
|
}
|
||||||
|
|
||||||
|
return false; // non-PK3s don't have folders
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
/* report a zlib or i/o error */
|
/* report a zlib or i/o error */
|
||||||
void zerr(int ret)
|
void zerr(int ret)
|
||||||
|
|
|
@ -154,6 +154,7 @@ size_t W_LumpLengthPwad(UINT16 wad, UINT16 lump);
|
||||||
size_t W_LumpLength(lumpnum_t lumpnum);
|
size_t W_LumpLength(lumpnum_t lumpnum);
|
||||||
|
|
||||||
boolean W_IsLumpWad(lumpnum_t lumpnum); // for loading maps from WADs in PK3s
|
boolean W_IsLumpWad(lumpnum_t lumpnum); // for loading maps from WADs in PK3s
|
||||||
|
boolean W_IsLumpFolder(UINT16 wad, UINT16 lump); // for detecting folder "lumps"
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
void zerr(int ret); // zlib error checking
|
void zerr(int ret); // zlib error checking
|
||||||
|
|
Loading…
Reference in a new issue