Skip to content

Commit

Permalink
Hexen: Adding a11y-Option - Flickering Sector Lighting (#1274)
Browse files Browse the repository at this point in the history
* Hexen: Adding A11Y Option to disable sector flickering

* Hexen: Refinement A11Y Flickering

* Hexen: Use Define for max. phase value

* Hexen: A11Y Flickering considering spawnlight cases

* Hexen: Modifying checks for Spawning Lights and Phases

* Hexen: Disable lightning in A11Y

* Hexen: Consider light changes for A11Y

* Hexen: Consider Fading Lights for A11Y

* Hexen: Simplify A11Y checks in p_lights.c

* Hexen: Remove unrequired comments from p_lights.c

* Hexen: Change comment for MAXPHASE define

* Hexen: Align light and phase thinker checks in sv_save with p_lights
  • Loading branch information
Noseey authored Feb 19, 2025
1 parent 40700b3 commit 6c6f3ba
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/hexen/h2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "i_swap.h" // [crispy] SHORT()
#include "i_system.h"
#include "i_timer.h"
#include "a11y.h" // [crispy] A11Y
#include "m_argv.h"
#include "m_config.h"
#include "m_controls.h"
Expand Down Expand Up @@ -180,6 +181,7 @@ void D_BindVariables(void)
M_BindIntVariable("messageson", &messageson);
M_BindIntVariable("screenblocks", &screenblocks);
M_BindIntVariable("snd_channels", &snd_Channels);
M_BindIntVariable("a11y_sector_lighting", &a11y_sector_lighting);
M_BindIntVariable("vanilla_savegame_limit", &vanilla_savegame_limit);
M_BindIntVariable("vanilla_demo_limit", &vanilla_demo_limit);

Expand Down
7 changes: 7 additions & 0 deletions src/hexen/p_anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "i_system.h"
#include "p_local.h"
#include "s_sound.h"
#include "a11y.h" // [crispy] A11Y

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -255,6 +256,8 @@ static void P_LightningFlash(void)
}
tempLight++;
}
if (a11y_sector_lighting)
tempSec->rlightlevel = tempSec->lightlevel; // [crispy] A11Y
}
}
else
Expand All @@ -270,6 +273,8 @@ static void P_LightningFlash(void)
tempSec->lightlevel = *tempLight;
tempLight++;
}
if (a11y_sector_lighting)
tempSec->rlightlevel = tempSec->lightlevel; // [crispy] A11Y
}
Sky1Texture = P_GetMapSky1Texture(gamemap);
}
Expand Down Expand Up @@ -314,6 +319,8 @@ static void P_LightningFlash(void)
tempLight++;
foundSec = true;
}
if (a11y_sector_lighting)
tempSec->rlightlevel = tempSec->lightlevel; // [crispy] A11Y
}
if (foundSec)
{
Expand Down
31 changes: 31 additions & 0 deletions src/hexen/p_lights.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "h2def.h"
#include "m_random.h"
#include "p_local.h"
#include "a11y.h" // [crispy] A11Y

//============================================================================
//
Expand Down Expand Up @@ -100,6 +101,10 @@ void T_Light(thinker_t *thinker)
default:
break;
}

// [crispy] A11Y
if (a11y_sector_lighting || light->type == LITE_FADE)
light->sector->rlightlevel = light->sector->lightlevel;
}

//============================================================================
Expand Down Expand Up @@ -147,6 +152,7 @@ boolean EV_SpawnLight(line_t * line, byte * arg, lighttype_t type)
light->type = type;
light->sector = sec;
light->count = 0;
light->value1 = 0; // [crispy] initialize value1 for A11Y usage
rtn = true;
switch (type)
{
Expand Down Expand Up @@ -222,6 +228,17 @@ boolean EV_SpawnLight(line_t * line, byte * arg, lighttype_t type)
rtn = false;
break;
}

// [crispy] A11Y
if (!a11y_sector_lighting && type >= LITE_GLOW) // [crispy] for glow, flicker and strobe
{
light->sector->rlightlevel = MAX(light->sector->rlightlevel, light->value1);
}
else
{
light->sector->rlightlevel = light->sector->lightlevel;
}

if (think)
{
P_AddThinker(&light->thinker);
Expand Down Expand Up @@ -257,6 +274,10 @@ void T_Phase(thinker_t *thinker)
phase_t *phase = (phase_t *) thinker;
phase->index = (phase->index + 1) & 63;
phase->sector->lightlevel = phase->base + PhaseTable[phase->index];

// [crispy] A11Y
if (a11y_sector_lighting)
phase->sector->rlightlevel = phase->sector->lightlevel;
}

//==========================================================================
Expand All @@ -283,6 +304,16 @@ void P_SpawnPhasedLight(sector_t * sector, int base, int index)
phase->base = base & 255;
sector->lightlevel = phase->base + PhaseTable[phase->index];
phase->thinker.function = T_Phase;

// [crispy] A11Y
if (!a11y_sector_lighting)
{
phase->sector->rlightlevel = MAX(phase->base + MAXPHASE, phase->sector->rlightlevel);
}
else
{
phase->sector->rlightlevel = phase->sector->lightlevel;
}

sector->special = 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/hexen/p_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#define MELEERANGE (64*FRACUNIT)
#define MISSILERANGE (32*64*FRACUNIT)

#define MAXPHASE 128 // [crispy] Max value out of the p_lights.c PhaseTable

typedef enum
{
DI_EAST,
Expand Down
2 changes: 2 additions & 0 deletions src/hexen/p_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ void P_LoadSectors(int lump)
ss->floorpic = R_FlatNumForName(ms->floorpic);
ss->ceilingpic = R_FlatNumForName(ms->ceilingpic);
ss->lightlevel = SHORT(ms->lightlevel);
// [crispy] A11Y light level used for rendering
ss->rlightlevel = ss->lightlevel;
ss->special = SHORT(ms->special);
ss->tag = SHORT(ms->tag);
ss->thinglist = NULL;
Expand Down
7 changes: 4 additions & 3 deletions src/hexen/r_bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void R_AddLine(seg_t * line)
// reject empty lines used for triggers and special events
if (backsector->ceilingpic == frontsector->ceilingpic
&& backsector->floorpic == frontsector->floorpic
&& backsector->lightlevel == frontsector->lightlevel
&& backsector->rlightlevel == frontsector->rlightlevel
&& backsector->special == frontsector->special
&& curline->sidedef->midtexture == 0)
return;
Expand Down Expand Up @@ -467,7 +467,7 @@ void R_Subsector(int num)
{
floorplane = R_FindPlane(frontsector->interpfloorheight,
frontsector->floorpic,
frontsector->lightlevel,
frontsector->rlightlevel, // [crispy] A11Y
frontsector->special);
}
else
Expand All @@ -480,7 +480,8 @@ void R_Subsector(int num)
{
ceilingplane = R_FindPlane(frontsector->interpceilingheight,
frontsector->ceilingpic,
frontsector->lightlevel, 0);
frontsector->rlightlevel, // [crispy] A11Y
0);
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions src/hexen/r_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ typedef struct
// the renderer.
fixed_t interpfloorheight;
fixed_t interpceilingheight;

// [crispy] A11Y light level used for rendering
short rlightlevel;
} sector_t;

typedef struct
Expand Down
8 changes: 4 additions & 4 deletions src/hexen/r_segs.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void R_RenderMaskedSegRange(drawseg_t * ds, int x1, int x2)
backsector = curline->backsector;
texnum = texturetranslation[curline->sidedef->midtexture];

lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT) + (extralight * LIGHTBRIGHT); // [crispy] smooth diminishing lighting
lightnum = (frontsector->rlightlevel >> LIGHTSEGSHIFT) + (extralight * LIGHTBRIGHT); // [crispy] smooth diminishing lighting, A11Y
//if (curline->v1->y == curline->v2->y)
// lightnum--;
//else if (curline->v1->x == curline->v2->x)
Expand Down Expand Up @@ -654,15 +654,15 @@ void R_StoreWallRange(int start, int stop)

if (worldlow != worldbottom
|| backsector->floorpic != frontsector->floorpic
|| backsector->lightlevel != frontsector->lightlevel
|| backsector->rlightlevel != frontsector->rlightlevel
|| backsector->special != frontsector->special)
markfloor = true;
else
markfloor = false; // same plane on both sides

if (worldhigh != worldtop
|| backsector->ceilingpic != frontsector->ceilingpic
|| backsector->lightlevel != frontsector->lightlevel)
|| backsector->rlightlevel != frontsector->rlightlevel)
markceiling = true;
else
markceiling = false; // same plane on both sides
Expand Down Expand Up @@ -727,7 +727,7 @@ void R_StoreWallRange(int start, int stop)
if (!fixedcolormap)
{
lightnum =
(frontsector->lightlevel >> LIGHTSEGSHIFT) + (extralight * LIGHTBRIGHT); // [crispy] smooth diminishing lighting;
(frontsector->rlightlevel >> LIGHTSEGSHIFT) + (extralight * LIGHTBRIGHT); // [crispy] smooth diminishing lighting, A11Y
//if (curline->v1->y == curline->v2->y)
// lightnum--;
//else if (curline->v1->x == curline->v2->x)
Expand Down
4 changes: 2 additions & 2 deletions src/hexen/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ void R_AddSprites(sector_t * sec)

sec->validcount = validcount;

lightnum = (sec->lightlevel >> LIGHTSEGSHIFT) + (extralight * LIGHTBRIGHT); // [crispy] smooth diminishing lighting
lightnum = (sec->rlightlevel >> LIGHTSEGSHIFT) + (extralight * LIGHTBRIGHT); // [crispy] smooth diminishing lighting, A11Y
if (lightnum < 0)
spritelights = scalelight[0];
else if (lightnum >= LIGHTLEVELS)
Expand Down Expand Up @@ -924,7 +924,7 @@ void R_DrawPlayerSprites(void)
// get light level
//
lightnum =
(viewplayer->mo->subsector->sector->lightlevel >> LIGHTSEGSHIFT) +
(viewplayer->mo->subsector->sector->rlightlevel >> LIGHTSEGSHIFT) + // [crispy] A11Y
(extralight * LIGHTBRIGHT); // [crispy] smooth diminishing lighting
if (lightnum < 0)
spritelights = scalelight[0];
Expand Down
8 changes: 8 additions & 0 deletions src/hexen/sv_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "m_misc.h"
#include "i_swap.h"
#include "p_local.h"
#include "a11y.h"

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -1429,6 +1430,9 @@ static void StreamIn_light_t(thinker_t *thinker)

// int count;
str->count = SV_ReadLong();

if (!a11y_sector_lighting && str->type >= LITE_GLOW) // [crispy] A11Y - maxlight among competing thinkers.
str->sector->rlightlevel = MAX(str->sector->rlightlevel, str->value1);
}

static void StreamOut_light_t(thinker_t *thinker)
Expand Down Expand Up @@ -1549,6 +1553,9 @@ static void StreamIn_phase_t(thinker_t *thinker)

// int base;
str->base = SV_ReadLong();

if (!a11y_sector_lighting) // [crispy] A11Y - maxlight among competing thinkers.
str->sector->rlightlevel = MAX(str->base + MAXPHASE, str->sector->rlightlevel);
}

static void StreamOut_phase_t(thinker_t *thinker)
Expand Down Expand Up @@ -2585,6 +2592,7 @@ static void UnarchiveWorld(void)
sec->floorpic = SV_ReadWord();
sec->ceilingpic = SV_ReadWord();
sec->lightlevel = SV_ReadWord();
sec->rlightlevel = sec->lightlevel; // [crispy] A11Y
sec->special = SV_ReadWord();
sec->tag = SV_ReadWord();
sec->seqType = SV_ReadWord();
Expand Down
8 changes: 7 additions & 1 deletion src/setup/accessibility.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ void AccessibilitySettings(TXT_UNCAST_ARG(widget), void *user_data)

TXT_SetWindowHelpURL(window, WINDOW_HELP_URL);

if (gamemission == doom || gamemission == heretic)
if (gamemission == doom || gamemission == heretic || gamemission == hexen)
{
TXT_AddWidgets(window,
TXT_NewCheckBox("Flickering Sector Lighting",
&a11y_sector_lighting),
NULL);
}

if (gamemission == doom || gamemission == heretic)
{
TXT_AddWidgets(window,
TXT_NewCheckBox("Weapon Flash Lighting",
&a11y_weapon_flash),
TXT_NewCheckBox("Weapon Flash Sprite",
Expand Down
2 changes: 1 addition & 1 deletion src/setup/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void MainMenu(void)
(TxtWidgetSignalFunc) CompatibilitySettings, NULL),
*/
// [crispy]
if (gamemission == doom || gamemission == heretic)
if (gamemission == doom || gamemission == heretic || gamemission == hexen)
{
TXT_AddWidget(window,
TXT_NewButton2("Accessibility",
Expand Down

0 comments on commit 6c6f3ba

Please sign in to comment.