From ff895f32518dac61f83c88481ec239e451ef8477 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Jan 2025 19:53:46 +0100 Subject: [PATCH 1/2] fix frame flag clash --- src/p_pspr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_pspr.h b/src/p_pspr.h index c5e736d91..2c173608b 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -41,12 +41,12 @@ #define FF_HORIZONTALFLIP 0x400 /// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION) #define FF_PAPERSPRITE 0x800 +/// \brief mobj_t.lightlevel is absolute instead of relative +#define FF_ABSOLUTELIGHTLEVEL 0x2000 /// \brief Frame flags: Simple stateless animation #define FF_ANIMATE 0x4000 /// \brief Frame flags: frame always appears full bright #define FF_FULLBRIGHT 0x8000 -/// \brief mobj_t.lightlevel is absolute instead of relative -#define FF_ABSOLUTELIGHTLEVEL 0x40000 /// \brief Frame flags: 0 = no trans(opaque), 1-15 = transl. table #define FF_TRANSMASK 0xf0000 /// \brief shift for FF_TRANSMASK From 2b13af236772b7e29ece63771e2b64ed820351e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jan 2025 08:05:51 +0100 Subject: [PATCH 2/2] setup maplight stuff earlier otherwise it doesent init early enough --- src/p_setup.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/p_spec.c | 40 ---------------------------------------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 1dbb43bac..27f8ba3a3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -596,6 +596,50 @@ boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector) return (baselightlevel < 255 && baselightlevel > 0); } +// 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; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (cv_randomdirlight.value && lighting->use_custom_light == false) + { + static INT16 oldmap = 0; // dont reset stuff when you restart a map + static boolean oldencore = false; + + 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; + oldencore = encoremode; + return; + } + else if (lighting->use_custom_light == false) + { + maplighting.contrast = 8; + maplighting.backlight = 0; + maplighting.directional = false; + maplighting.angle = 0; + } + + maplighting.contrast = lighting->light_contrast; + maplighting.backlight = lighting->sprite_backlight; + maplighting.directional = lighting->use_light_angle; + maplighting.angle = lighting->light_angle; +} + // Loads the SEGS resource from a level. static void P_LoadRawSegs(UINT8 *data) { @@ -605,6 +649,9 @@ static void P_LoadRawSegs(UINT8 *data) line_t *ldef; size_t i; + // Set map lighting settings. + P_SetupDirectionalLight(); + for (i = 0; i < numsegs; i++, li++, ml++) { li->v1 = &vertexes[SHORT(ml->v1)]; diff --git a/src/p_spec.c b/src/p_spec.c index 30c14fdf4..d272764be 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5225,43 +5225,6 @@ 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; - - if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) - { - lighting = &mapheaderinfo[gamemap-1]->lighting_encore; - } - - if (cv_randomdirlight.value && lighting->use_custom_light == false) - { - static INT16 oldmap = 0; // dont reset stuff when you restart a map - static boolean oldencore = false; - - 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; - oldencore = encoremode; - return; - } - - maplighting.contrast = lighting->light_contrast; - maplighting.backlight = lighting->sprite_backlight; - maplighting.directional = lighting->use_light_angle; - maplighting.angle = lighting->light_angle; -} - /** After the map has loaded, scans for specials that spawn 3Dfloors and * thinkers. * @@ -5287,9 +5250,6 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) // Set the default gravity. Custom gravity overrides this setting. gravity = (FRACUNIT*8)/10; - // Set map lighting settings. - P_SetupDirectionalLight(); - // Defaults in case levels don't have them set. sstimer = 90*TICRATE + 6; totalrings = 1;