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:
Nevur 2017-04-30 20:05:26 +02:00
parent 376d2a2da3
commit 448ceefe84
3 changed files with 70 additions and 38 deletions

View File

@ -3027,8 +3027,8 @@ boolean P_AddWadFile(const char *wadfilename, char **firstmapname)
UINT16 numlumps, wadnum; UINT16 numlumps, wadnum;
INT16 firstmapreplaced = 0, num; INT16 firstmapreplaced = 0, num;
char *name; char *name;
char *fullName;
lumpinfo_t *lumpinfo; lumpinfo_t *lumpinfo;
boolean texturechange = false;
boolean replacedcurrentmap = false; boolean replacedcurrentmap = false;
if ((numlumps = W_LoadWadFile(wadfilename)) == INT16_MAX) 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); CONS_Printf(M_GetText("Errors occured while loading %s; not added.\n"), wadfilename);
return false; return false;
} }
else wadnum = (UINT16)(numwadfiles-1); else
wadnum = (UINT16)(numwadfiles-1);
lumpinfo = wadfiles[wadnum]->lumpinfo;
// //
// search for sound replacements // search for sound replacements
// //
lumpinfo = wadfiles[wadnum]->lumpinfo; switch(wadfiles[wadnum]->type)
for (i = 0; i < numlumps; i++, lumpinfo++)
{ {
name = lumpinfo->name; case RET_PK3:
if (name[0] == 'D') 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, if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name, 6))
// since sfx->data will be NULL {
CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name); // 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); CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name);
mreplaces++; digmreplaces++;
} }
} }
else if (name[0] == 'O' && name[1] == '_') break;
{
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;
} }
if (!devparm && sreplaces) if (!devparm && sreplaces)
CONS_Printf(M_GetText("%s sounds replaced\n"), sizeu1(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 // Reload it all anyway, just in case they
// added some textures but didn't insert a // added some textures but didn't insert a
// TEXTURE1/PNAMES/etc. list. // TEXTURE1/PNAMES/etc. list.
if (texturechange) // initialized in the sound check R_LoadTextures(); // numtexture changes
R_LoadTextures(); // numtexture changes
else
R_FlushTextureCache(); // just reload it from file
// Reload ANIMATED / ANIMDEFS // Reload ANIMATED / ANIMDEFS
P_InitPicAnims(); P_InitPicAnims();

View File

@ -293,6 +293,7 @@ UINT16 W_LoadWadFile(const char *filename)
FILE *handle; FILE *handle;
lumpinfo_t *lumpinfo; lumpinfo_t *lumpinfo;
wadfile_t *wadfile; wadfile_t *wadfile;
enum restype type;
UINT32 numlumps; UINT32 numlumps;
size_t i; size_t i;
INT32 compressed = 0; INT32 compressed = 0;
@ -342,7 +343,7 @@ UINT16 W_LoadWadFile(const char *filename)
// This code emulates a wadfile with one lump name "OBJCTCFG" // This code emulates a wadfile with one lump name "OBJCTCFG"
// at position 0 and size of the whole file. // 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. // 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; numlumps = 1;
lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); 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" // This code emulates a wadfile with one lump name "LUA_INIT"
// at position 0 and size of the whole file. // 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. // 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; numlumps = 1;
lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL);
@ -387,7 +388,7 @@ UINT16 W_LoadWadFile(const char *filename)
numlumps = 0; numlumps = 0;
//wadfile->restype = RET_PK3; type = RET_PK3;
CONS_Alert(CONS_NOTICE, "PK3 file detected.\n"); CONS_Alert(CONS_NOTICE, "PK3 file detected.\n");
// Obtain the file's size. // 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! 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); CONS_Printf("File %s at %ld:\n", eName, handlePos);
if (numlumps == 0) // First lump? Let's allocate the first lumpinfo block. 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].position = eLocalHeaderOffset + 30 + eNameLen + eXFieldLen;
lumpinfo[numlumps].disksize = eCompSize; 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].name[8] = '\0';
lumpinfo[numlumps].name2 = Z_Malloc((eNameLen+1)*sizeof(char), PU_STATIC, NULL); 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 // assume wad file
else else
{ {
//wadfile->restype = RET_WAD; type = RET_WAD;
wadinfo_t header; wadinfo_t header;
lumpinfo_t *lump_p; lumpinfo_t *lump_p;
@ -621,6 +632,7 @@ UINT16 W_LoadWadFile(const char *filename)
// //
wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL); wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL);
wadfile->filename = Z_StrDup(filename); wadfile->filename = Z_StrDup(filename);
wadfile->type = type;
wadfile->handle = handle; wadfile->handle = handle;
wadfile->numlumps = (UINT16)numlumps; wadfile->numlumps = (UINT16)numlumps;
wadfile->lumpinfo = lumpinfo; wadfile->lumpinfo = lumpinfo;

View File

@ -69,7 +69,7 @@ enum restype {RET_WAD, RET_PK3};
typedef struct wadfile_s typedef struct wadfile_s
{ {
char *filename; char *filename;
enum restype restype; enum restype type;
lumpinfo_t *lumpinfo; lumpinfo_t *lumpinfo;
lumpcache_t *lumpcache; lumpcache_t *lumpcache;
#ifdef HWRENDER #ifdef HWRENDER