Don't crash if the palette entry is not first.

Instead, swap the palette entry and the first entry (only in memory).
This commit is contained in:
Bill Currie 2010-10-09 21:57:18 +09:00
parent 0082b93283
commit 29d544d766
1 changed files with 14 additions and 2 deletions

View File

@ -215,8 +215,20 @@ TEX_InitFromWad (const char *path)
lumpinfo = wad->lumps; lumpinfo = wad->lumps;
if (strcmp (lumpinfo->name, "PALETTE")) if (strcmp (lumpinfo->name, "PALETTE")) {
Sys_Error ("TEX_InitFromWad: %s doesn't have palette as 0", path); lumpinfo_t tlump;
Sys_Printf ("TEX_InitFromWad: %s doesn't have palette as 0", path);
lumpinfo = wad_find_lump (wad, "PALETTE");
if (!lumpinfo)
Sys_Printf ("TEX_InitFromWad: %s doesn't have a palette", path);
// move the palette lump to the first entry
tlump = *lumpinfo;
*lumpinfo = wad->lumps[0];
wad->lumps[0] = tlump;
lumpinfo = wad->lumps;
}
TEX_InitPalette (wad, lumpinfo); TEX_InitPalette (wad, lumpinfo);