mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-17 23:21:22 +00:00
I'm pushing this because I'm having issues. Changes so far:
-Folders aren't loaded as lumps anymore -Can now load an arbitrary number of TEXTURES lumps in PK3s. Name them textures.gfz, textures.thz, ..., for example.
This commit is contained in:
parent
19c46f3732
commit
16336dbe22
4 changed files with 52 additions and 30 deletions
34
src/r_data.c
34
src/r_data.c
|
@ -569,20 +569,23 @@ void R_LoadTextures(void)
|
|||
{
|
||||
if (wadfiles[w]->type == RET_PK3)
|
||||
{
|
||||
texstart = W_CheckNumForFullNamePK3("textures/", (UINT16)w, 0) + 1;
|
||||
texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0);
|
||||
texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart);
|
||||
texturesLumpPos = W_CheckNumForFullNamePK3("textures", (UINT16)w, 0);
|
||||
texturesLumpPos = W_CheckNumForFullNamePK3("TEXTURES", (UINT16)w, 0);
|
||||
while (texturesLumpPos != INT16_MAX)
|
||||
{
|
||||
CONS_Printf("AAA\n");
|
||||
numtextures += R_CountTexturesInTEXTURESLump((UINT16)w, (UINT16)texturesLumpPos);
|
||||
texturesLumpPos = W_CheckNumForFullNamePK3("TEXTURES", (UINT16)w, texturesLumpPos + 1);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (texturesLumpPos != INT16_MAX)
|
||||
{
|
||||
numtextures += R_CountTexturesInTEXTURESLump((UINT16)w, (UINT16)texturesLumpPos);
|
||||
if (texturesLumpPos != INT16_MAX)
|
||||
numtextures += R_CountTexturesInTEXTURESLump((UINT16)w, (UINT16)texturesLumpPos);
|
||||
}
|
||||
|
||||
// Add all the textures between TX_START and TX_END
|
||||
|
@ -597,7 +600,6 @@ void R_LoadTextures(void)
|
|||
I_Error("No textures detected in any WADs!\n");
|
||||
}
|
||||
}
|
||||
CONS_Printf("We got a number of %d textures.\n", numtextures);
|
||||
// Allocate memory and initialize to 0 for all the textures we are initialising.
|
||||
// There are actually 5 buffers allocated in one for convenience.
|
||||
textures = Z_Calloc((numtextures * sizeof(void *)) * 5, PU_STATIC, NULL);
|
||||
|
@ -621,20 +623,24 @@ void R_LoadTextures(void)
|
|||
// Get the lump numbers for the markers in the WAD, if they exist.
|
||||
if (wadfiles[w]->type == RET_PK3)
|
||||
{
|
||||
texstart = W_CheckNumForFullNamePK3("textures/", (UINT16)w, 0) + 1;
|
||||
texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0);
|
||||
texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart);
|
||||
texturesLumpPos = W_CheckNumForFullNamePK3("textures", (UINT16)w, 0);
|
||||
texturesLumpPos = W_CheckNumForFullNamePK3("TEXTURES", (UINT16)w, 0);
|
||||
while (texturesLumpPos != INT16_MAX)
|
||||
{
|
||||
R_ParseTEXTURESLump(w, texturesLumpPos, &i);
|
||||
texturesLumpPos = W_CheckNumForFullNamePK3("TEXTURES", (UINT16)w, texturesLumpPos + 1);
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (texturesLumpPos != INT16_MAX)
|
||||
R_ParseTEXTURESLump(w, texturesLumpPos, &i);
|
||||
}
|
||||
|
||||
if (texturesLumpPos != INT16_MAX)
|
||||
R_ParseTEXTURESLump(w, texturesLumpPos, &i);
|
||||
|
||||
if (texstart == INT16_MAX || texend == INT16_MAX)
|
||||
continue;
|
||||
|
||||
|
@ -1229,7 +1235,7 @@ lumpnum_t R_GetFlatNumForName(const char *name)
|
|||
}
|
||||
else if (wadfiles[i]->type == RET_PK3)
|
||||
{
|
||||
start = W_CheckNumForFullNamePK3("Flats/", i, 0);
|
||||
start = W_CheckNumForFolderStartPK3("Flats/", i, 0);
|
||||
if (start == INT16_MAX)
|
||||
continue;
|
||||
end = W_CheckNumForFolderEndPK3("Flats/", i, start);
|
||||
|
|
|
@ -415,15 +415,13 @@ void R_AddSpriteDefs(UINT16 wadnum)
|
|||
start = W_CheckNumForNamePwad("S_START", wadnum, 0);
|
||||
if (start == UINT16_MAX)
|
||||
start = W_CheckNumForNamePwad("SS_START", wadnum, 0); //deutex compatib.
|
||||
if (start == UINT16_MAX)
|
||||
start = 0; //let say S_START is lump 0
|
||||
else
|
||||
start++; // just after S_START
|
||||
}
|
||||
else if (wadfiles[wadnum]->type == RET_PK3)
|
||||
start = W_CheckNumForFullNamePK3("Sprites/", wadnum, 0);
|
||||
|
||||
if (start == UINT16_MAX)
|
||||
start = 0; //let say S_START is lump 0
|
||||
else
|
||||
start++; // just after S_START
|
||||
|
||||
start = W_CheckNumForFolderStartPK3("Sprites/", wadnum, 0);
|
||||
|
||||
// ignore skin wads (we don't want skin sprites interfering with vanilla sprites)
|
||||
if (start == 0 && W_CheckNumForNamePwad("S_SKIN", wadnum, 0) != UINT16_MAX)
|
||||
|
|
35
src/w_wad.c
35
src/w_wad.c
|
@ -175,18 +175,18 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
|
|||
static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum)
|
||||
{
|
||||
UINT16 posStart, posEnd;
|
||||
posStart = W_CheckNumForFullNamePK3("Lua/", wadnum, 0);
|
||||
posStart = W_CheckNumForFolderStartPK3("Lua/", wadnum, 0);
|
||||
if (posStart != INT16_MAX)
|
||||
{
|
||||
posEnd = W_CheckNumForFolderEndPK3("Lua/", wadnum, posStart);
|
||||
for (++posStart; posStart < posEnd; posStart++)
|
||||
for (posStart; posStart < posEnd; posStart++)
|
||||
LUA_LoadLump(wadnum, posStart);
|
||||
}
|
||||
posStart = W_CheckNumForFullNamePK3("SOCs/", wadnum, 0);
|
||||
posStart = W_CheckNumForFolderStartPK3("SOCs/", wadnum, 0);
|
||||
if (posStart != INT16_MAX)
|
||||
{
|
||||
posEnd = W_CheckNumForFolderEndPK3("SOCs/", wadnum, posStart);
|
||||
for(++posStart; posStart < posEnd; posStart++)
|
||||
for(posStart; posStart < posEnd; posStart++)
|
||||
DEH_LoadDehackedLumpPwad(wadnum, posStart);
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ UINT16 W_InitFile(const char *filename)
|
|||
size = ftell(handle);
|
||||
CONS_Debug(DBG_SETUP, "PK3 size is: %ld\n", size);
|
||||
|
||||
// We must look for the central directory through the file.
|
||||
// We must look for the central directory through the file. (Thanks to JTE for this algorithm.)
|
||||
// All of the central directory entry headers have a signature of 0x50 0x4b 0x01 0x02.
|
||||
// The first entry found means the beginning of the central directory.
|
||||
rewind(handle);
|
||||
|
@ -502,6 +502,11 @@ UINT16 W_InitFile(const char *filename)
|
|||
|
||||
eName = malloc(sizeof(char)*(eNameLen + 1));
|
||||
fgets(eName, eNameLen + 1, handle);
|
||||
|
||||
// Don't load lump if folder.
|
||||
if (*(eName + eNameLen - 1) == '/')
|
||||
continue;
|
||||
|
||||
if (numlumps == 0) // First lump? Let's allocate the first lumpinfo block.
|
||||
lumpinfo = Z_Malloc(sizeof(*lumpinfo), PU_STATIC, NULL);
|
||||
else // Otherwise, reallocate and increase by 1. Might not be optimal, though...
|
||||
|
@ -558,7 +563,6 @@ UINT16 W_InitFile(const char *filename)
|
|||
lumpinfo[numlumps].compression = CM_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
CONS_Printf("File %s, Shortname %s, data begins at: %ld\n", eName, lumpinfo[numlumps].name, lumpinfo[numlumps].position);
|
||||
CONS_Debug(DBG_SETUP, "File %s, data begins at: %ld\n", eName, lumpinfo[numlumps].position);
|
||||
fseek(handle, eXFieldLen + eCommentLen, SEEK_CUR); // We skip to where we expect the next central directory entry or end marker to be.
|
||||
numlumps++;
|
||||
|
@ -569,7 +573,7 @@ UINT16 W_InitFile(const char *filename)
|
|||
{
|
||||
CONS_Debug(DBG_SETUP, "Central directory end signature found at: %ld\n", ftell(handle));
|
||||
|
||||
// We will create a "virtual" marker lump at the very end of lumpinfo for convenience.
|
||||
/*// We will create a "virtual" marker lump at the very end of lumpinfo for convenience.
|
||||
// This marker will be used by the different lump-seeking (eg. textures, sprites, etc.) in PK3-specific cases in an auxiliary way.
|
||||
lumpinfo = (lumpinfo_t*) Z_Realloc(lumpinfo, (numlumps + 1)*sizeof(*lumpinfo), PU_STATIC, NULL);
|
||||
strcpy(lumpinfo[numlumps].name, "PK3_ENDM\0");
|
||||
|
@ -579,7 +583,7 @@ UINT16 W_InitFile(const char *filename)
|
|||
lumpinfo[numlumps].size = 0;
|
||||
lumpinfo[numlumps].disksize = 0;
|
||||
lumpinfo[numlumps].compression = CM_NONE;
|
||||
numlumps++;
|
||||
numlumps++;*/
|
||||
break;
|
||||
}
|
||||
// ... None of them? We're only expecting either a central directory signature entry or the central directory end signature.
|
||||
|
@ -858,6 +862,19 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump)
|
|||
return INT16_MAX;
|
||||
}
|
||||
|
||||
// Look for the first lump from a folder.
|
||||
UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlump)
|
||||
{
|
||||
INT32 i;
|
||||
lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump;
|
||||
for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++)
|
||||
{
|
||||
if (strnicmp(name, lump_p->name2, strlen(name)) == 0)
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
// In a PK3 type of resource file, it looks for the next lumpinfo entry that doesn't share the specified pathfile.
|
||||
// Useful for finding folder ends.
|
||||
// Returns the position of the lumpinfo entry.
|
||||
|
@ -947,7 +964,7 @@ lumpnum_t W_CheckNumForMap(const char *name)
|
|||
}
|
||||
else if (wadfiles[i]->type == RET_PK3)
|
||||
{
|
||||
lumpNum = W_CheckNumForFullNamePK3("maps/", i, 0);
|
||||
lumpNum = W_CheckNumForFolderStartPK3("maps/", i, 0);
|
||||
if (lumpNum != INT16_MAX)
|
||||
end = W_CheckNumForFolderEndPK3("maps/", i, lumpNum);
|
||||
else
|
||||
|
|
|
@ -117,6 +117,7 @@ const char *W_CheckNameForNum(lumpnum_t lumpnum);
|
|||
UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump); // checks only in one pwad
|
||||
|
||||
UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump);
|
||||
UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlump);
|
||||
UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump);
|
||||
|
||||
lumpnum_t W_CheckNumForMap(const char *name);
|
||||
|
|
Loading…
Reference in a new issue