diff --git a/src/deh_soc.c b/src/deh_soc.c index 8843cb099..6de5a04a4 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1402,10 +1402,12 @@ void readlevelheader(MYFILE *f, char * name) else if (fastcmp(word, "LIGHTCONTRAST")) { usemaplighting(num, word)->light_contrast = (UINT8)i; + usemaplighting(num, word)->use_custom_light = true; } else if (fastcmp(word, "SPRITEBACKLIGHT") || fastcmp(word, "ENCORESPRITEBACKLIGHT")) { usemaplighting(num, word)->sprite_backlight = (SINT8)i; + usemaplighting(num, word)->use_custom_light = true; } else if (fastcmp(word, "LIGHTANGLE") || fastcmp(word, "ENCORELIGHTANGLE")) { @@ -1421,6 +1423,7 @@ void readlevelheader(MYFILE *f, char * name) lighting->use_light_angle = true; lighting->light_angle = FixedAngle(FloatToFixed(atof(word2))); } + usemaplighting(num, word)->use_custom_light = true; } // Individual triggers for level flags, for ease of use (and 2.0 compatibility) else if (fastcmp(word, "SCRIPTISFILE")) diff --git a/src/doomstat.h b/src/doomstat.h index 7c1ce5491..377ed086f 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -339,6 +339,7 @@ struct customoption_t struct mapheader_lighting_t { + boolean use_custom_light; ///< Decides if this should use custom lighting. UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting. SINT8 sprite_backlight; ///< Subtract from wall lighting for sprites only. boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional. diff --git a/src/p_setup.c b/src/p_setup.c index 2f8332196..42e412e05 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -387,6 +387,7 @@ void P_DeleteFlickies(INT16 i) static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting) { + lighting->use_custom_light = false; lighting->light_contrast = 16; lighting->sprite_backlight = 0; lighting->use_light_angle = false; @@ -3785,6 +3786,16 @@ boolean P_SectorUsesDirectionalLighting(const sector_t *sector) boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector) { + mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (lighting->use_custom_light == false) + return (baselightnum < LIGHTLEVELS-1 && baselightnum > 0); + if (!P_SectorUsesDirectionalLighting(sector)) { return false; @@ -3797,6 +3808,16 @@ boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector) boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector) { + mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (lighting->use_custom_light == false) + return (baselightlevel < LIGHTLEVELS-1 && baselightlevel > 0); + if (!P_SectorUsesDirectionalLighting(sector)) { return false;