diff --git a/include/QF/model.h b/include/QF/model.h index 2b6a43597..c33ec0006 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -479,7 +479,6 @@ extern struct cvar_s *gl_mesh_cache; extern struct cvar_s *gl_subdivide_size; extern model_t *loadmodel; extern char loadname[32]; -extern const int mod_lightmap_bytes; extern byte *mod_base; extern byte mod_novis[MAX_MAP_LEAFS / 8]; diff --git a/libs/models/brush/gl_model_brush.c b/libs/models/brush/gl_model_brush.c index 9063a69a3..60b645f7b 100644 --- a/libs/models/brush/gl_model_brush.c +++ b/libs/models/brush/gl_model_brush.c @@ -50,7 +50,8 @@ static const char rcsid[] = #include "compat.h" -const int mod_lightmap_bytes = 3; +int mod_lightmap_bytes = 3; + void Mod_ProcessTexture (miptex_t *mt, texture_t *tx) @@ -117,34 +118,46 @@ Mod_LoadLighting (lump_t *l) char litfilename[1024]; loadmodel->lightdata = NULL; - // LordHavoc: check for a .lit file to load - strcpy (litfilename, loadmodel->name); - COM_StripExtension (litfilename, litfilename); - strncat (litfilename, ".lit", sizeof (litfilename) - strlen (litfilename)); - data = (byte *) COM_LoadHunkFile (litfilename); - if (data) { - if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I' - && data[3] == 'T') { - i = LittleLong (((int *) data)[1]); - if (i == 1) { - Sys_DPrintf ("%s loaded", litfilename); - loadmodel->lightdata = data + 8; - return; + if (mod_lightmap_bytes > 1) { + // LordHavoc: check for a .lit file to load + strcpy (litfilename, loadmodel->name); + COM_StripExtension (litfilename, litfilename); + strncat (litfilename, ".lit", sizeof (litfilename) - + strlen (litfilename)); + data = (byte *) COM_LoadHunkFile (litfilename); + if (data) { + if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I' + && data[3] == 'T') { + i = LittleLong (((int *) data)[1]); + if (i == 1) { + Sys_DPrintf ("%s loaded", litfilename); + loadmodel->lightdata = data + 8; + return; + } else + Sys_Printf ("Unknown .lit file version (%d)\n", i); } else - Sys_Printf ("Unknown .lit file version (%d)\n", i); - } else - Sys_Printf ("Corrupt .lit file (old version?), ignoring\n"); + Sys_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 * mod_lightmap_bytes, + litfilename); in = mod_base + l->fileofs; out = loadmodel->lightdata; - for (i = 0; i < l->filelen; i++) { - d = *in++; - *out++ = d; - *out++ = d; - *out++ = d; + + if (mod_lightmap_bytes > 1) { + for (i = 0; i < l->filelen ; i++) { + d = *in++; + *out++ = d; + *out++ = d; + *out++ = d; + } + } else { + for (i = 0; i < l->filelen ; i++) { + d = *in++; + *out++ = d; + } } } diff --git a/libs/models/brush/model_brush.c b/libs/models/brush/model_brush.c index b61f54894..a59af6a44 100644 --- a/libs/models/brush/model_brush.c +++ b/libs/models/brush/model_brush.c @@ -51,14 +51,12 @@ static const char rcsid[] = #include "compat.h" -void R_InitSky (struct texture_s *mt); - - - +extern int mod_lightmap_bytes; byte mod_novis[MAX_MAP_LEAFS / 8]; +cvar_t *gl_sky_divide; void GL_SubdivideSurface (msurface_t *fa); -cvar_t *gl_sky_divide; +void R_InitSky (struct texture_s *mt); mleaf_t * diff --git a/libs/models/brush/sw_model_brush.c b/libs/models/brush/sw_model_brush.c index 767f27016..38f93817a 100644 --- a/libs/models/brush/sw_model_brush.c +++ b/libs/models/brush/sw_model_brush.c @@ -43,7 +43,7 @@ static const char rcsid[] = #include "QF/model.h" -const int mod_lightmap_bytes = 1; +int mod_lightmap_bytes = 1; void