updated .lit loader, forgot to commit this a while back

This commit is contained in:
Forest Hale 2000-12-07 08:59:56 +00:00
parent 3feecbde94
commit be6e940417

View file

@ -67,23 +67,35 @@ Mod_LoadLighting
void Mod_LoadLighting (lump_t *l) void Mod_LoadLighting (lump_t *l)
{ {
int i; int i;
byte *in, *out; byte *in, *out, *data;
byte d; byte d;
char litfilename[1024]; char litfilename[1024];
if (!l->filelen)
{
loadmodel->lightdata = NULL; loadmodel->lightdata = NULL;
return; // LordHavoc: check for a .lit file to load
}
strcpy(litfilename, loadmodel->name); strcpy(litfilename, loadmodel->name);
COM_StripExtension(litfilename, litfilename); COM_StripExtension(litfilename, litfilename);
strncat (litfilename, ".lit", sizeof(litfilename) - strlen (litfilename)); strncat (litfilename, ".lit", sizeof(litfilename) - strlen (litfilename));
data = (byte*) COM_LoadHunkFile (litfilename);
loadmodel->lightdata = (byte*) COM_LoadHunkFile (litfilename); if (data)
if (!loadmodel->lightdata) // expand the white lighting data
{ {
if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I' && data[3] == 'T')
{
i = LittleLong(((int *)data)[1]);
if (i == 1)
{
Con_DPrintf("%s loaded", litfilename);
loadmodel->lightdata = data + 8;
return;
}
else
Con_Printf("Unknown .lit file version (%d)\n", i);
}
else
Con_Printf("Corrupt .lit file (old version?), ignoring\n");
}
// LordHavoc: oh well, expand the white lighting data
if (!l->filelen)
return;
loadmodel->lightdata = Hunk_AllocName ( l->filelen*3, litfilename); loadmodel->lightdata = Hunk_AllocName ( l->filelen*3, litfilename);
in = loadmodel->lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write in = loadmodel->lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write
out = loadmodel->lightdata; out = loadmodel->lightdata;
@ -95,5 +107,4 @@ void Mod_LoadLighting (lump_t *l)
*out++ = d; *out++ = d;
*out++ = d; *out++ = d;
} }
}
} }