From 946a06b264fdc750f7ae8f2462a9c8d74bd8c9bd Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 9 Oct 2010 21:57:18 +0900 Subject: [PATCH] Don't crash if the palette entry is not first. Instead, swap the palette entry and the first entry (only in memory). --- tools/Forge/Bundles/MapEdit/TexturePalette.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/Forge/Bundles/MapEdit/TexturePalette.m b/tools/Forge/Bundles/MapEdit/TexturePalette.m index 55f8604c4..35d57f87e 100644 --- a/tools/Forge/Bundles/MapEdit/TexturePalette.m +++ b/tools/Forge/Bundles/MapEdit/TexturePalette.m @@ -215,8 +215,20 @@ TEX_InitFromWad (const char *path) lumpinfo = wad->lumps; - if (strcmp (lumpinfo->name, "PALETTE")) - Sys_Error ("TEX_InitFromWad: %s doesn't have palette as 0", path); + if (strcmp (lumpinfo->name, "PALETTE")) { + 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);