Be more verbose and less errory about corrupt gfx.wad files.
This commit is contained in:
parent
933155ce88
commit
36b2046f57
|
@ -419,7 +419,7 @@ void Draw_LoadPics (void)
|
||||||
|
|
||||||
data = (byte *) W_GetLumpName ("conchars", &info);
|
data = (byte *) W_GetLumpName ("conchars", &info);
|
||||||
if (!data || info->size < 128*128) Sys_Error ("Draw_LoadPics: couldn't load conchars");
|
if (!data || info->size < 128*128) Sys_Error ("Draw_LoadPics: couldn't load conchars");
|
||||||
if (info->size != 128*128) Con_Warning("Invalid size for gfx.wad conchars lump - attempting to ignore for compat.\n");
|
if (info->size != 128*128) Con_Warning("Invalid size for gfx.wad conchars lump (%u, expected %u) - attempting to ignore for compat.\n", info->size, 128*128);
|
||||||
else if (info->type != TYP_MIPTEX) Con_DWarning("Invalid type for gfx.wad conchars lump - attempting to ignore for compat.\n"); //not really a miptex, but certainly NOT a qpic.
|
else if (info->type != TYP_MIPTEX) Con_DWarning("Invalid type for gfx.wad conchars lump - attempting to ignore for compat.\n"); //not really a miptex, but certainly NOT a qpic.
|
||||||
offset = (src_offset_t)data - (src_offset_t)wad_base;
|
offset = (src_offset_t)data - (src_offset_t)wad_base;
|
||||||
char_texture = TexMgr_LoadImage (NULL, WADFILENAME":conchars", 128, 128, SRC_INDEXED, data,
|
char_texture = TexMgr_LoadImage (NULL, WADFILENAME":conchars", 128, 128, SRC_INDEXED, data,
|
||||||
|
|
33
Quake/wad.c
33
Quake/wad.c
|
@ -89,20 +89,41 @@ void W_LoadWadFile (void) //johnfitz -- filename is now hard-coded for honesty
|
||||||
|
|
||||||
if (header->identification[0] != 'W' || header->identification[1] != 'A'
|
if (header->identification[0] != 'W' || header->identification[1] != 'A'
|
||||||
|| header->identification[2] != 'D' || header->identification[3] != '2')
|
|| header->identification[2] != 'D' || header->identification[3] != '2')
|
||||||
Sys_Error ("Wad file %s doesn't have WAD2 id\n",filename);
|
{
|
||||||
|
Con_Printf ("Wad file %s doesn't have WAD2 id\n",filename);
|
||||||
wad_numlumps = LittleLong(header->numlumps);
|
wad_numlumps = 0;
|
||||||
infotableofs = LittleLong(header->infotableofs);
|
infotableofs = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wad_numlumps = LittleLong(header->numlumps);
|
||||||
|
infotableofs = LittleLong(header->infotableofs);
|
||||||
|
}
|
||||||
wad_lumps = (lumpinfo_t *)(wad_base + infotableofs);
|
wad_lumps = (lumpinfo_t *)(wad_base + infotableofs);
|
||||||
if (infotableofs < 0 || infotableofs+wad_numlumps*sizeof(lumpinfo_t)>com_filesize)
|
if (infotableofs < 0 || infotableofs+wad_numlumps*sizeof(lumpinfo_t)>com_filesize)
|
||||||
Sys_Error ("Wad file %s header extends beyond end of file\n",filename);
|
{
|
||||||
|
Con_Printf ("Wad file %s header extends beyond end of file\n",filename);
|
||||||
|
wad_numlumps = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0, lump_p = wad_lumps ; i<wad_numlumps ; i++,lump_p++)
|
for (i=0, lump_p = wad_lumps ; i<wad_numlumps ; i++,lump_p++)
|
||||||
{
|
{
|
||||||
lump_p->filepos = LittleLong(lump_p->filepos);
|
lump_p->filepos = LittleLong(lump_p->filepos);
|
||||||
lump_p->size = LittleLong(lump_p->size);
|
lump_p->size = LittleLong(lump_p->size);
|
||||||
if (lump_p->filepos < 0 || lump_p->size < 0 || lump_p->filepos + lump_p->size > com_filesize)
|
if (lump_p->filepos < 0 || lump_p->size < 0 || lump_p->filepos + lump_p->size > com_filesize)
|
||||||
Sys_Error ("Wad file %s lump \"%16s\" extends beyond end of file\n",filename, lump_p->name);
|
{
|
||||||
|
if (lump_p->filepos > com_filesize || lump_p->size < 0)
|
||||||
|
{
|
||||||
|
Con_Printf ("Wad file %s lump \"%.16s\" begins %u bytes beyond end of wad\n",filename, lump_p->name, lump_p->filepos - com_filesize);
|
||||||
|
lump_p->filepos = 0;
|
||||||
|
lump_p->size = q_max(0, lump_p->size-lump_p->filepos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Con_Printf ("Wad file %s lump \"%.16s\" extends %u bytes beyond end of wad (lump size: %u)\n",filename, lump_p->name, (lump_p->filepos + lump_p->size) - com_filesize, lump_p->size);
|
||||||
|
lump_p->size = q_max(0, lump_p->size-lump_p->filepos);
|
||||||
|
}
|
||||||
|
}
|
||||||
W_CleanupName (lump_p->name, lump_p->name); // CAUTION: in-place editing!!! The endian fixups too.
|
W_CleanupName (lump_p->name, lump_p->name); // CAUTION: in-place editing!!! The endian fixups too.
|
||||||
if (lump_p->type == TYP_QPIC)
|
if (lump_p->type == TYP_QPIC)
|
||||||
SwapPic ( (qpic_t *)(wad_base + lump_p->filepos));
|
SwapPic ( (qpic_t *)(wad_base + lump_p->filepos));
|
||||||
|
|
Loading…
Reference in New Issue