- Fixed: glbsp nodes in a wad file inside a pk3 would not be loaded.

- Fixed: Typo from r4270.

SVN r4273 (trunk)
This commit is contained in:
Braden Obrzut 2013-05-20 20:39:34 +00:00
parent 8af465189a
commit 1d4fbc05a5
3 changed files with 18 additions and 27 deletions

View file

@ -794,17 +794,20 @@ static int FindGLNodesInWAD(int labellump)
// FindGLNodesInWAD // FindGLNodesInWAD
// //
// Looks for GL nodes in the same WAD as the level itself // Looks for GL nodes in the same WAD as the level itself
// When this function returns the file pointer points to // Function returns the lump number within the file. Returns -1 if the input
// the directory entry of the GL_VERTS lump // resource file is NULL.
// //
//=========================================================================== //===========================================================================
static int FindGLNodesInFile(FileReader * f, const char * label) static int FindGLNodesInFile(FResourceFile * f, const char * label)
{ {
// No file open? Probably shouldn't happen but assume no GL nodes
if(!f)
return -1;
FString glheader; FString glheader;
bool mustcheck=false; bool mustcheck=false;
DWORD id, dirofs, numentries; DWORD numentries = f->LumpCount();
DWORD offset, size;
char lumpname[9]; char lumpname[9];
glheader.Format("GL_%.8s", label); glheader.Format("GL_%.8s", label);
@ -814,25 +817,17 @@ static int FindGLNodesInFile(FileReader * f, const char * label)
mustcheck=true; mustcheck=true;
} }
f->Seek(0, SEEK_SET); if (numentries > 4)
(*f) >> id >> numentries >> dirofs;
if ((id == IWAD_ID || id == PWAD_ID) && numentries > 4)
{ {
f->Seek(dirofs, SEEK_SET);
for(DWORD i=0;i<numentries-4;i++) for(DWORD i=0;i<numentries-4;i++)
{ {
(*f) >> offset >> size; if (!strnicmp(f->GetLump(i)->Name, glheader, 8))
f->Read(lumpname, 8);
if (!strnicmp(lumpname, glheader, 8))
{ {
if (mustcheck) if (mustcheck)
{ {
char check[16]={0}; char check[16]={0};
int filepos = f->Tell(); FileReader *fr = f->GetLump(i)->GetReader();
f->Seek(offset, SEEK_SET); fr->Read(check, 16);
f->Read(check, 16);
f->Seek(filepos, SEEK_SET);
if (MatchHeader(label, check)) return i; if (MatchHeader(label, check)) return i;
} }
else return i; else return i;
@ -902,8 +897,7 @@ bool P_LoadGLNodes(MapData * map)
int li; int li;
int lumpfile = Wads.GetLumpFile(map->lumpnum); int lumpfile = Wads.GetLumpFile(map->lumpnum);
bool mapinwad = map->InWad; bool mapinwad = map->InWad;
FileReader * fr = map->file; FResourceFile * f_gwa = map->resource;
FResourceFile * f_gwa = NULL;
const char * name = Wads.GetWadFullName(lumpfile); const char * name = Wads.GetWadFullName(lumpfile);
@ -933,15 +927,13 @@ bool P_LoadGLNodes(MapData * map)
f_gwa = FResourceFile::OpenResourceFile(path, NULL, true); f_gwa = FResourceFile::OpenResourceFile(path, NULL, true);
if (f_gwa==NULL) return false; if (f_gwa==NULL) return false;
fr = f_gwa->GetReader();
strncpy(map->MapLumps[0].Name, Wads.GetLumpFullName(map->lumpnum), 8); strncpy(map->MapLumps[0].Name, Wads.GetLumpFullName(map->lumpnum), 8);
} }
} }
} }
bool result = false; bool result = false;
li = FindGLNodesInFile(fr, map->MapLumps[0].Name); li = FindGLNodesInFile(f_gwa, map->MapLumps[0].Name);
if (li!=-1) if (li!=-1)
{ {
static const char check[][9]={"GL_VERT","GL_SEGS","GL_SSECT","GL_NODES"}; static const char check[][9]={"GL_VERT","GL_SEGS","GL_SSECT","GL_NODES"};
@ -959,11 +951,8 @@ bool P_LoadGLNodes(MapData * map)
if (result) result = DoLoadGLNodes(gwalumps); if (result) result = DoLoadGLNodes(gwalumps);
} }
if (f_gwa) if (f_gwa != map->resource)
{
delete fr;
delete f_gwa; delete f_gwa;
}
for(unsigned int i = 0;i < 4;++i) for(unsigned int i = 0;i < 4;++i)
delete gwalumps[i]; delete gwalumps[i];
return result; return result;

View file

@ -305,6 +305,7 @@ MapData *P_OpenMapData(const char * mapname)
// This case can only happen if the lump is inside a real WAD file. // This case can only happen if the lump is inside a real WAD file.
// As such any special handling for other types of lumps is skipped. // As such any special handling for other types of lumps is skipped.
map->MapLumps[0].Reader = map->file = Wads.ReopenLumpNum(lump_name); map->MapLumps[0].Reader = map->file = Wads.ReopenLumpNum(lump_name);
strncpy(map->MapLumps[0].Name, Wads.GetLumpFullName(lump_name), 8);
map->Encrypted = Wads.IsEncryptedFile(lump_name); map->Encrypted = Wads.IsEncryptedFile(lump_name);
map->InWad = true; map->InWad = true;
@ -412,6 +413,7 @@ MapData *P_OpenMapData(const char * mapname)
int index=0; int index=0;
map->MapLumps[0].Reader = map->resource->GetLump(0)->NewReader(); map->MapLumps[0].Reader = map->resource->GetLump(0)->NewReader();
strncpy(map->MapLumps[0].Name, map->resource->GetLump(0)->Name, 8);
for(DWORD i = 1; i < map->resource->LumpCount(); i++) for(DWORD i = 1; i < map->resource->LumpCount(); i++)
{ {

View file

@ -806,7 +806,7 @@ OB_MPMINIMISSILELAUNCHER = "%o gulped down %k's missile.";
OB_MPSTRIFEGRENADE = "%o was inverted by %k's H-E grenade."; OB_MPSTRIFEGRENADE = "%o was inverted by %k's H-E grenade.";
OB_MPPHOSPHOROUSGRENADE = "%o took a flame bath in %k's phosphorous pyre."; OB_MPPHOSPHOROUSGRENADE = "%o took a flame bath in %k's phosphorous pyre.";
OB_MPFLAMETHROWER = "%o was barbecued by %k."; OB_MPFLAMETHROWER = "%o was barbecued by %k.";
OP_MPMAULER1 = "%o was zapped by %k."; OB_MPMAULER1 = "%o was zapped by %k.";
OB_MPMAULER = "%o was viciously vaporized by %k."; OB_MPMAULER = "%o was viciously vaporized by %k.";
OB_MPSIGIL = "%o bowed down to the sheer power of %k's Sigil."; OB_MPSIGIL = "%o bowed down to the sheer power of %k's Sigil.";