Skip to content

Commit

Permalink
Heretic: Adding a11y-Option - Flickering Sector Lighting (#1246)
Browse files Browse the repository at this point in the history
* Heretic: Adding a11y Flickering Option

Option added based upon the crispy doom implementation.

* Heretic: Fixing segment check to use correct rlightlevel

* Heretic: Store rlightlevel in Saves to have consistent lighting on unarchiving.

* Heretic: Undo rlightlevel saving, reconstruct rlightlevel from maxlight for flashers

* Heretic: Fixing whitespaces in p_setup.c

* Heretic: Fixing whitespaces in p_lights.c

* Heretic: Check rlightlevel instead of llightlevel for rejecting empty lines and triggers

* Heretic: Restore rlightlevel when unarchiving

..  to reflect light-changes done throughout the map.
  • Loading branch information
Noseey authored Dec 17, 2024
1 parent bd87fce commit a87b615
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 26 deletions.
2 changes: 2 additions & 0 deletions src/heretic/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "i_system.h"
#include "i_timer.h"
#include "i_video.h"
#include "a11y.h" // [crispy] A11Y
#include "m_argv.h"
#include "m_config.h"
#include "m_controls.h"
Expand Down Expand Up @@ -852,6 +853,7 @@ void D_BindVariables(void)
M_BindIntVariable("music_volume", &snd_MusicVolume);
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);
M_BindIntVariable("show_endoom", &show_endoom);
Expand Down
21 changes: 21 additions & 0 deletions src/heretic/p_lights.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "m_random.h"
#include "p_local.h"
#include "v_video.h"
#include "a11y.h" // [crispy] A11Y

//==================================================================
//==================================================================
Expand Down Expand Up @@ -52,6 +53,11 @@ void T_LightFlash(thinker_t *thinker)
flash->count = (P_Random() & flash->maxtime) + 1;
}

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


Expand Down Expand Up @@ -111,6 +117,11 @@ void T_StrobeFlash(thinker_t *thinker)
flash->count = flash->darktime;
}

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

//==================================================================
Expand Down Expand Up @@ -193,6 +204,8 @@ void EV_TurnTagLightsOff(line_t * line)
min = tsec->lightlevel;
}
sector->lightlevel = min;
// [crispy] A11Y
sector->rlightlevel = sector->lightlevel;
}
}

Expand Down Expand Up @@ -231,6 +244,8 @@ void EV_LightTurnOn(line_t * line, int bright)
}
}
sector->lightlevel = bright;
// [crispy] A11Y
sector->rlightlevel = sector->lightlevel;
}
}

Expand Down Expand Up @@ -262,6 +277,12 @@ void T_Glow(thinker_t *thinker)
}
break;
}

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

void P_SpawnGlowingLight(sector_t * sector)
Expand Down
1 change: 1 addition & 0 deletions src/heretic/p_saveg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,7 @@ void P_UnArchiveWorld(void)
sec->floorpic = SV_ReadWord();
sec->ceilingpic = SV_ReadWord();
sec->lightlevel = SV_ReadWord();
sec->rlightlevel = sec->lightlevel; // [crispy] A11Y
sec->special = SV_ReadWord(); // needed?
sec->tag = SV_ReadWord(); // needed?
sec->specialdata = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/heretic/p_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,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/heretic/r_bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,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 // [crispy] check for special as well
&& curline->sidedef->midtexture == 0)
return;
Expand Down Expand Up @@ -469,7 +469,7 @@ void R_Subsector(int num)
frontsector->floorpic == skyflatnum &&
frontsector->sky & PL_SKYFLAT ? frontsector->sky :
frontsector->floorpic,
frontsector->lightlevel,
frontsector->rlightlevel, // [crispy] A11Y
frontsector->special);
else
floorplane = NULL;
Expand All @@ -480,7 +480,8 @@ void R_Subsector(int num)
frontsector->ceilingpic == skyflatnum &&
frontsector->sky & PL_SKYFLAT ? frontsector->sky :
frontsector->ceilingpic,
frontsector->lightlevel, 0);
frontsector->rlightlevel, // [crispy] A11Y
0);
else
ceilingplane = NULL;

Expand Down
3 changes: 3 additions & 0 deletions src/heretic/r_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,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
10 changes: 6 additions & 4 deletions src/heretic/r_segs.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ 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

// [crispy] smoother fake contrast
lightnum += curline->fakecontrast;
/*
Expand Down Expand Up @@ -675,15 +676,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) // [crispy] check for special as well
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 @@ -748,7 +749,8 @@ 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

// [crispy] smoother fake contrast
lightnum += curline->fakecontrast;
/*
Expand Down
5 changes: 3 additions & 2 deletions src/heretic/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,8 @@ 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 @@ -903,7 +904,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
43 changes: 27 additions & 16 deletions src/setup/accessibility.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,36 @@ void AccessibilitySettings(TXT_UNCAST_ARG(widget), void *user_data)

TXT_SetWindowHelpURL(window, WINDOW_HELP_URL);

TXT_AddWidgets(window,
TXT_NewCheckBox("Flickering Sector Lighting",
&a11y_sector_lighting),
TXT_NewCheckBox("Weapon Flash Lighting",
&a11y_weapon_flash),
TXT_NewCheckBox("Weapon Flash Sprite",
&a11y_weapon_pspr),
TXT_NewCheckBox("Palette Changes",
&a11y_palette_changes),
TXT_NewCheckBox("Invulnerability Colormap",
&a11y_invul_colormap),
NULL);
if (gamemission == doom || gamemission == heretic)
{
TXT_AddWidget(window,
TXT_NewCheckBox("Flickering Sector Lighting",
&a11y_sector_lighting));
}

if (gamemission == doom)
{
TXT_AddWidgets(window,
TXT_NewCheckBox("Weapon Flash Lighting",
&a11y_weapon_flash),
TXT_NewCheckBox("Weapon Flash Sprite",
&a11y_weapon_pspr),
TXT_NewCheckBox("Palette Changes",
&a11y_palette_changes),
TXT_NewCheckBox("Invulnerability Colormap",
&a11y_invul_colormap),
NULL);
}

TXT_SetTableColumns(window, 2);

TXT_AddWidgets(window,
TXT_NewLabel("Extra Lighting"),
TXT_NewSpinControl(&a11y_extra_lighting, 0, 8),
NULL);
if (gamemission == doom)
{
TXT_AddWidgets(window,
TXT_NewLabel("Extra Lighting"),
TXT_NewSpinControl(&a11y_extra_lighting, 0, 8),
NULL);
}

}

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)
if (gamemission == doom || gamemission == heretic)
{
TXT_AddWidget(window,
TXT_NewButton2("Accessibility",
Expand Down

0 comments on commit a87b615

Please sign in to comment.