diff --git a/src/p_setup.c b/src/p_setup.c index 21738ff88..a071bc47c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -327,7 +327,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->numCustomOptions = 0; } -static void P_ClearDirectionalLightMapHeaderInfo(INT16 i) // lol dont always reset this on every map load +void P_ClearDirectionalLightMapHeaderInfo(INT16 i) // lol dont always reset this on every map load { mapheaderinfo[i]->light_contrast = cv_randomdirlight.value ? M_RandomRange(0, 58) : 8; mapheaderinfo[i]->sprite_backlight = 0; diff --git a/src/p_setup.h b/src/p_setup.h index b96a216a0..e10e4c3bd 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -98,6 +98,8 @@ boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector); boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector); boolean P_SectorUsesDirectionalLighting(const sector_t *sector); size_t P_PrecacheLevelFlats(void); + +void P_ClearDirectionalLightMapHeaderInfo(INT16 i); void P_AllocMapHeader(INT16 i); #endif diff --git a/src/r_main.c b/src/r_main.c index d33f2cb2f..e908e88d4 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -29,6 +29,7 @@ #include "d_main.h" #include "v_video.h" #include "p_spec.h" // skyboxmo +#include "p_setup.h" #include "z_zone.h" #include "m_random.h" // quake camera shake #include "r_portal.h" @@ -158,6 +159,8 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); +static void DirLight_OnChange(void); + static void Precipstuff_OnChange(void); consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -205,7 +208,28 @@ consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +// randomized directional lightning +consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, DirLight_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +static void DirLight_OnChange(void) +{ + for (int i = 0; i < NUMMAPS; i++) + { + if (!mapheaderinfo[i]) + continue; + + P_ClearDirectionalLightMapHeaderInfo(i); + } + + //current map + if (mapheaderinfo[gamemap-1]) + { + maplighting.contrast = mapheaderinfo[gamemap-1]->light_contrast; + maplighting.backlight = mapheaderinfo[gamemap-1]->sprite_backlight; + maplighting.directional = mapheaderinfo[gamemap-1]->use_light_angle; + maplighting.angle = mapheaderinfo[gamemap-1]->light_angle; + } +} void SplitScreen_OnChange(void) {