Don't error out when lookup.dat can't be read.

git-svn-id: https://svn.eduke32.com/eduke32@5347 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-09-23 17:54:55 +00:00
parent ce7a20d4f2
commit 2a237a3d72
5 changed files with 29 additions and 40 deletions

View file

@ -8537,16 +8537,15 @@ int32_t loadlookups(int32_t fp)
{
uint8_t numlookups;
char remapbuf[256];
int32_t j;
if (kread(fp, &numlookups, 1) != 1)
if (kread_and_test(fp, &numlookups, 1))
return -1;
for (j=0; j<numlookups; j++)
for (int j=0; j<numlookups; j++)
{
uint8_t palnum;
if (kread(fp, &palnum, 1) != 1)
if (kread_and_test(fp, &palnum, 1))
return -1;
if (palnum >= 256-RESERVEDPALS)
@ -8555,7 +8554,7 @@ int32_t loadlookups(int32_t fp)
return -2;
}
if (kread(fp, remapbuf, 256) != 256)
if (kread_and_test(fp, remapbuf, 256))
return -1;
makepalookup(palnum, remapbuf, 0,0,0, 0);

View file

@ -2341,17 +2341,6 @@ static inline void SpriteName(int16_t spritenum, char *lo2)
Bstrcpy(lo2, names[sprite[spritenum].picnum]);
}// end SpriteName
// Returns: did error?
static int32_t ReadPaletteTable(void)
{
// Make base shade table at shade 0 into the identity map.
// (In the shade table of Duke3D's PALETTE.DAT, palookup[0][239]==143.)
// This makes it possible to sensibly use Lunatic's engine.saveLookupDat().
palookup[0][239] = 239;
return G_LoadLookups();
}
static void m32_showmouse(void)
{
@ -9915,8 +9904,7 @@ int32_t ExtPostStartupWindow(void)
return -1;
}
if (ReadPaletteTable())
return 0;
G_LoadLookups();
loadtilegroups(default_tiles_cfg);
@ -9946,6 +9934,15 @@ int32_t ExtPostStartupWindow(void)
void ExtPostInit(void)
{
InitCustomColors();
// Make base shade table at shade 0 into the identity map.
// (In the shade table of Duke3D's PALETTE.DAT, palookup[0][239]==143.)
// This makes it possible to sensibly use Lunatic's engine.saveLookupDat().
palookup[0][239] = 239;
generatefogpals();
fillemptylookups();
}
void ExtUnInit(void)

View file

@ -1009,18 +1009,13 @@ uint8_t *basepaltable[BASEPALCOUNT] = {
NULL /*anim_pal*/
};
int32_t G_LoadLookups(void)
void G_LoadLookups(void)
{
int32_t fp, j;
if ((fp=kopen4loadfrommod("lookup.dat",0)) == -1)
{
if ((fp=kopen4loadfrommod("lookup.dat",1)) == -1)
{
initprintf("ERROR: File \"lookup.dat\" not found.\n");
return 1;
}
}
return;
j = loadlookups(fp);
@ -1028,26 +1023,20 @@ int32_t G_LoadLookups(void)
{
if (j == -1)
initprintf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
return 1;
return kclose(fp);
}
for (j=1; j<=5; j++)
{
// Account for TITLE and REALMS swap between basepal number and on-disk order.
// XXX: this reordering is better off as an argument to us.
int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j;
if (kread(fp, basepaltable[basepalnum], 768) != 768)
return -1;
if (kread_and_test(fp, basepaltable[basepalnum], 768))
return kclose(fp);
}
kclose(fp);
generatefogpals();
fillemptylookups();
return 0;
}
#if defined HAVE_FLAC || defined HAVE_VORBIS

View file

@ -126,7 +126,7 @@ void G_DoAutoload(const char *dirname);
extern uint8_t *basepaltable[BASEPALCOUNT];
extern int32_t G_LoadLookups(void);
extern void G_LoadLookups(void);
//////////

View file

@ -10979,16 +10979,18 @@ static inline void G_CheckGametype(void)
ud.m_respawn_items = ud.m_respawn_inventory = 1;
}
static void G_LoadExtraPalettes(void)
static void G_PostLoadPalette(void)
{
G_LoadLookups();
// Make color index 255 of default/water/slime palette black.
Bmemset(&basepaltable[BASEPAL][255*3], 0, 3);
Bmemset(&basepaltable[WATERPAL][255*3], 0, 3);
Bmemset(&basepaltable[SLIMEPAL][255*3], 0, 3);
generatefogpals();
E_ReplaceTransparentColorWithBlack();
fillemptylookups();
}
#define SETFLAG(Tilenum, Flag) g_tile[Tilenum].flags |= Flag
@ -11260,7 +11262,7 @@ static void G_Startup(void)
picanm[LOADSCREEN].sf |= PICANM_NOFULLBRIGHT_BIT;
// initprintf("Loading palette/lookups...\n");
G_LoadExtraPalettes();
G_LoadLookups();
ReadSaveGameHeaders();
@ -11709,6 +11711,8 @@ int32_t app_main(int32_t argc, const char **argv)
if (E_PostInit())
G_FatalEngineError();
G_PostLoadPalette();
Gv_ResetSystemDefaults(); // called here to populate our fake tilesizx and tilesizy arrays presented to CON with sizes generated by dummytiles
if (numplayers == 1 && boardfilename[0] != 0)