From b6ed17d9fca12b269937152dad02e27031d56da3 Mon Sep 17 00:00:00 2001 From: Sally Coolatta <tehrealsalt@gmail.com> Date: Tue, 24 May 2022 23:04:48 -0400 Subject: [PATCH] Allow adjusting map contrast --- src/deh_soc.c | 17 +++++++++++++++++ src/doomstat.h | 11 +++++++++++ src/g_game.c | 2 ++ src/p_setup.c | 5 ++++- src/p_slopes.c | 2 +- src/p_spec.c | 5 +++++ 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/deh_soc.c b/src/deh_soc.c index adb44c61ed..6178576094 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1566,6 +1566,23 @@ void readlevelheader(MYFILE *f, INT32 num) mapheaderinfo[num-1]->mobj_scale = get_number(word2); else if (fastcmp(word, "DEFAULTWAYPOINTRADIUS")) mapheaderinfo[num-1]->default_waypoint_radius = get_number(word2); + else if (fastcmp(word, "LIGHTCONTRAST")) + { + mapheaderinfo[num-1]->light_contrast = (UINT8)i; + } + else if (fastcmp(word, "LIGHTANGLE")) + { + if (fastcmp(word2, "EVEN")) + { + mapheaderinfo[num-1]->use_light_angle = false; + mapheaderinfo[num-1]->light_angle = 0; + } + else + { + mapheaderinfo[num-1]->use_light_angle = true; + mapheaderinfo[num-1]->light_angle = FixedAngle(FloatToFixed(atof(word2))); + } + } // 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 163bfee96d..fdf263117d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -386,6 +386,10 @@ typedef struct fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 fixed_t default_waypoint_radius; ///< 0 is a special value for DEFAULT_WAYPOINT_RADIUS, but scaled with mobjscale + UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting. + boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional. + angle_t light_angle; ///< Angle of directional wall lighting. + // Music stuff. UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds char musintername[7]; ///< Intermission screen music. @@ -666,6 +670,13 @@ extern tic_t racecountdown, exitcountdown; extern fixed_t gravity; extern fixed_t mapobjectscale; +extern struct maplighting +{ + UINT8 contrast; + boolean directional; + angle_t angle; +} maplighting; + //for CTF balancing extern INT16 autobalance; extern INT16 teamscramble; diff --git a/src/g_game.c b/src/g_game.c index 21467e592a..140bd91aea 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -288,6 +288,8 @@ tic_t racecountdown, exitcountdown; // for racing fixed_t gravity; fixed_t mapobjectscale; +struct maplighting maplighting; + INT16 autobalance; //for CTF team balance INT16 teamscramble; //for CTF team scramble INT16 scrambleplayers[MAXPLAYERS]; //for CTF team scramble diff --git a/src/p_setup.c b/src/p_setup.c index 632602a683..80a2e51443 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -413,6 +413,9 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->menuflags = 0; mapheaderinfo[num]->mobj_scale = FRACUNIT; mapheaderinfo[num]->default_waypoint_radius = 0; + mapheaderinfo[num]->light_contrast = 0; + mapheaderinfo[num]->use_light_angle = false; + mapheaderinfo[num]->light_angle = 0; #if 1 // equivalent to "FlickyList = DEMO" P_SetDemoFlickies(num); #else // equivalent to "FlickyList = NONE" @@ -2322,7 +2325,7 @@ static inline float P_SegLengthFloat(seg_t *seg) */ void P_UpdateSegLightOffset(seg_t *li) { - const UINT8 contrast = 16; + const UINT8 contrast = maplighting.contrast; fixed_t extralight = 0; extralight = -((fixed_t)contrast*FRACUNIT) + diff --git a/src/p_slopes.c b/src/p_slopes.c index 2f4d64be7a..e7ca22c2a3 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -35,7 +35,7 @@ static void P_SetupAnchoredSlopes (void); void P_UpdateSlopeLightOffset(pslope_t *slope) { const boolean ceiling = (slope->normal.z < 0); - const UINT8 contrast = 16; + const UINT8 contrast = maplighting.contrast; fixed_t contrastFixed = (contrast * FRACUNIT); fixed_t zMul = FRACUNIT; diff --git a/src/p_spec.c b/src/p_spec.c index b6079e6cfa..1035cba1f0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5884,6 +5884,11 @@ void P_InitSpecials(void) // Set the default gravity. Custom gravity overrides this setting. gravity = mapheaderinfo[gamemap-1]->gravity; + // Set map lighting settings. + maplighting.contrast = mapheaderinfo[gamemap-1]->light_contrast; + maplighting.directional = mapheaderinfo[gamemap-1]->use_light_angle; + maplighting.angle = mapheaderinfo[gamemap-1]->light_angle; + // Defaults in case levels don't have them set. sstimer = mapheaderinfo[gamemap-1]->sstimer*TICRATE + 6; ssspheres = mapheaderinfo[gamemap-1]->ssspheres; -- GitLab