mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-29 12:40:58 +00:00
Little progress made. The code from everywhere still looks for the basic WAD structure of the lumps.
-Removed a redundant boolean related to texture loading in P_AddWadFile. -Started working on handling PK3s differently, except that I'm not sure about what I'm doing. I don't know what to do from now on for today, so I'll leave it here for now.
This commit is contained in:
parent
376d2a2da3
commit
448ceefe84
3 changed files with 70 additions and 38 deletions
|
@ -3027,8 +3027,8 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
|
|||
UINT16 numlumps, wadnum;
|
||||
INT16 firstmapreplaced = 0, num;
|
||||
char *name;
|
||||
char *fullName;
|
||||
lumpinfo_t *lumpinfo;
|
||||
boolean texturechange = false;
|
||||
boolean replacedcurrentmap = false;
|
||||
|
||||
if ((numlumps = W_LoadWadFile(wadfilename)) == INT16_MAX)
|
||||
|
@ -3036,49 +3036,72 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
|
|||
CONS_Printf(M_GetText("Errors occured while loading %s; not added.\n"), wadfilename);
|
||||
return false;
|
||||
}
|
||||
else wadnum = (UINT16)(numwadfiles-1);
|
||||
else
|
||||
wadnum = (UINT16)(numwadfiles-1);
|
||||
|
||||
lumpinfo = wadfiles[wadnum]->lumpinfo;
|
||||
|
||||
//
|
||||
// search for sound replacements
|
||||
//
|
||||
lumpinfo = wadfiles[wadnum]->lumpinfo;
|
||||
for (i = 0; i < numlumps; i++, lumpinfo++)
|
||||
switch(wadfiles[wadnum]->type)
|
||||
{
|
||||
name = lumpinfo->name;
|
||||
if (name[0] == 'D')
|
||||
case RET_PK3:
|
||||
for (i = 0; i < numlumps; i++, lumpinfo++)
|
||||
{
|
||||
if (name[1] == 'S') for (j = 1; j < NUMSFX; j++)
|
||||
name = lumpinfo->name;
|
||||
fullName = lumpinfo->name2;
|
||||
if (!strnicmp(fullName, "sounds", 6))
|
||||
{
|
||||
if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6))
|
||||
// We found a sound. Let's check whether it's replacing an existing sound or it's a brand new one.
|
||||
for (j = 1; j < NUMSFX; j++)
|
||||
{
|
||||
// the sound will be reloaded when needed,
|
||||
// since sfx->data will be NULL
|
||||
CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name);
|
||||
if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name, 6))
|
||||
{
|
||||
// the sound will be reloaded when needed,
|
||||
// since sfx->data will be NULL
|
||||
CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name);
|
||||
|
||||
I_FreeSfx(&S_sfx[j]);
|
||||
I_FreeSfx(&S_sfx[j]);
|
||||
|
||||
sreplaces++;
|
||||
sreplaces++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (name[1] == '_')
|
||||
}
|
||||
break;
|
||||
default:
|
||||
for (i = 0; i < numlumps; i++, lumpinfo++)
|
||||
{
|
||||
name = lumpinfo->name;
|
||||
if (name[0] == 'D')
|
||||
{
|
||||
if (name[1] == 'S') for (j = 1; j < NUMSFX; j++)
|
||||
{
|
||||
if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6))
|
||||
{
|
||||
// the sound will be reloaded when needed,
|
||||
// since sfx->data will be NULL
|
||||
CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name);
|
||||
|
||||
I_FreeSfx(&S_sfx[j]);
|
||||
|
||||
sreplaces++;
|
||||
}
|
||||
}
|
||||
else if (name[1] == '_')
|
||||
{
|
||||
CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name);
|
||||
mreplaces++;
|
||||
}
|
||||
}
|
||||
else if (name[0] == 'O' && name[1] == '_')
|
||||
{
|
||||
CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name);
|
||||
mreplaces++;
|
||||
digmreplaces++;
|
||||
}
|
||||
}
|
||||
else if (name[0] == 'O' && name[1] == '_')
|
||||
{
|
||||
CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name);
|
||||
digmreplaces++;
|
||||
}
|
||||
#if 0
|
||||
//
|
||||
// search for texturechange replacements
|
||||
//
|
||||
else if (!memcmp(name, "TEXTURE1", 8) || !memcmp(name, "TEXTURE2", 8)
|
||||
|| !memcmp(name, "PNAMES", 6))
|
||||
#endif
|
||||
texturechange = true;
|
||||
break;
|
||||
}
|
||||
if (!devparm && sreplaces)
|
||||
CONS_Printf(M_GetText("%s sounds replaced\n"), sizeu1(sreplaces));
|
||||
|
@ -3095,10 +3118,7 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
|
|||
// Reload it all anyway, just in case they
|
||||
// added some textures but didn't insert a
|
||||
// TEXTURE1/PNAMES/etc. list.
|
||||
if (texturechange) // initialized in the sound check
|
||||
R_LoadTextures(); // numtexture changes
|
||||
else
|
||||
R_FlushTextureCache(); // just reload it from file
|
||||
R_LoadTextures(); // numtexture changes
|
||||
|
||||
// Reload ANIMATED / ANIMDEFS
|
||||
P_InitPicAnims();
|
||||
|
|
22
src/w_wad.c
22
src/w_wad.c
|
@ -293,6 +293,7 @@ UINT16 W_LoadWadFile(const char *filename)
|
|||
FILE *handle;
|
||||
lumpinfo_t *lumpinfo;
|
||||
wadfile_t *wadfile;
|
||||
enum restype type;
|
||||
UINT32 numlumps;
|
||||
size_t i;
|
||||
INT32 compressed = 0;
|
||||
|
@ -342,7 +343,7 @@ UINT16 W_LoadWadFile(const char *filename)
|
|||
// This code emulates a wadfile with one lump name "OBJCTCFG"
|
||||
// at position 0 and size of the whole file.
|
||||
// This allows soc files to be like all wads, copied by network and loaded at the console.
|
||||
//wadfile->restype = RET_WAD;
|
||||
type = RET_WAD;
|
||||
|
||||
numlumps = 1;
|
||||
lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL);
|
||||
|
@ -363,7 +364,7 @@ UINT16 W_LoadWadFile(const char *filename)
|
|||
// This code emulates a wadfile with one lump name "LUA_INIT"
|
||||
// at position 0 and size of the whole file.
|
||||
// This allows soc files to be like all wads, copied by network and loaded at the console.
|
||||
//wadfile->restype = RET_WAD;
|
||||
type = RET_WAD;
|
||||
|
||||
numlumps = 1;
|
||||
lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL);
|
||||
|
@ -387,7 +388,7 @@ UINT16 W_LoadWadFile(const char *filename)
|
|||
|
||||
numlumps = 0;
|
||||
|
||||
//wadfile->restype = RET_PK3;
|
||||
type = RET_PK3;
|
||||
CONS_Alert(CONS_NOTICE, "PK3 file detected.\n");
|
||||
|
||||
// Obtain the file's size.
|
||||
|
@ -454,6 +455,7 @@ UINT16 W_LoadWadFile(const char *filename)
|
|||
}
|
||||
else // If not, then it is a normal file. Let's arrange its lumpinfo structure then!
|
||||
{
|
||||
int namePos = eNameLen - 1;
|
||||
CONS_Printf("File %s at %ld:\n", eName, handlePos);
|
||||
|
||||
if (numlumps == 0) // First lump? Let's allocate the first lumpinfo block.
|
||||
|
@ -464,7 +466,16 @@ UINT16 W_LoadWadFile(const char *filename)
|
|||
lumpinfo[numlumps].position = eLocalHeaderOffset + 30 + eNameLen + eXFieldLen;
|
||||
lumpinfo[numlumps].disksize = eCompSize;
|
||||
|
||||
strncpy(lumpinfo[numlumps].name, eName + eNameLen - 8, 8);
|
||||
// We will trim the file's full name so that only the filename is left.
|
||||
while(namePos--)
|
||||
{
|
||||
if(eName[namePos] == '/')
|
||||
{
|
||||
namePos++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
strncpy(lumpinfo[numlumps].name, eName + namePos, 8);
|
||||
lumpinfo[numlumps].name[8] = '\0';
|
||||
|
||||
lumpinfo[numlumps].name2 = Z_Malloc((eNameLen+1)*sizeof(char), PU_STATIC, NULL);
|
||||
|
@ -509,7 +520,7 @@ UINT16 W_LoadWadFile(const char *filename)
|
|||
// assume wad file
|
||||
else
|
||||
{
|
||||
//wadfile->restype = RET_WAD;
|
||||
type = RET_WAD;
|
||||
|
||||
wadinfo_t header;
|
||||
lumpinfo_t *lump_p;
|
||||
|
@ -621,6 +632,7 @@ UINT16 W_LoadWadFile(const char *filename)
|
|||
//
|
||||
wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL);
|
||||
wadfile->filename = Z_StrDup(filename);
|
||||
wadfile->type = type;
|
||||
wadfile->handle = handle;
|
||||
wadfile->numlumps = (UINT16)numlumps;
|
||||
wadfile->lumpinfo = lumpinfo;
|
||||
|
|
|
@ -69,7 +69,7 @@ enum restype {RET_WAD, RET_PK3};
|
|||
typedef struct wadfile_s
|
||||
{
|
||||
char *filename;
|
||||
enum restype restype;
|
||||
enum restype type;
|
||||
lumpinfo_t *lumpinfo;
|
||||
lumpcache_t *lumpcache;
|
||||
#ifdef HWRENDER
|
||||
|
|
Loading…
Reference in a new issue