diff --git a/src/p_setup.h b/src/p_setup.h index 4118fb455..79acfff3f 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -93,6 +93,7 @@ void P_WriteThings(lumpnum_t lump); fixed_t P_SegLength(seg_t *seg); #endif +extern boolean reinitmaplight; void P_UpdateSegLightOffset(seg_t *li); boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector); boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector); diff --git a/src/p_spec.c b/src/p_spec.c index 786ba633f..30c14fdf4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5225,6 +5225,8 @@ static void P_RunLevelLoadExecutors(void) } } +// dumb thing to reset maplight on next map change when its toggled +boolean reinitmaplight = false; static void P_SetupDirectionalLight(void) { mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; @@ -5239,12 +5241,14 @@ static void P_SetupDirectionalLight(void) static INT16 oldmap = 0; // dont reset stuff when you restart a map static boolean oldencore = false; - if (gamemap != oldmap || encoremode != oldencore) + if (gamemap != oldmap || encoremode != oldencore || reinitmaplight) { maplighting.contrast = M_RandomRange(0, 58); maplighting.backlight = 0; maplighting.directional = M_RandomRange(0, 1); // either on or off maplighting.angle = M_RandomRange(-382, 382); + + reinitmaplight = false; } oldmap = gamemap; diff --git a/src/r_main.c b/src/r_main.c index f4054fbfd..276083778 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -159,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}; @@ -207,7 +209,13 @@ 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}; // randomized directional lightning -consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, DirLight_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +// tells to reset the maplight at next map change +static void DirLight_OnChange(void) +{ + reinitmaplight = true; +} void SplitScreen_OnChange(void) {