Skip to content

Commit

Permalink
Doom: a11y Flickering Option Improvements (#1248)
Browse files Browse the repository at this point in the history
* Doom: a11y flickering fix

- Fixed issue having static strobe/glow/flash lightlevel != maxlight when loading save-files.
- Fixed issue having flickering-glitches in some level segment compositions (e. g. Doom2, Lvl09 YK)

* Doom: Remove writing / reading of RLightlevel from extsaveg

* Revert "Doom: Remove writing / reading of RLightlevel from extsaveg"

This reverts commit 475c33f.

* Doom: Reconstruct maxlight if no a11y_sector_lighting when unarchiving thinker.

* Doom: Removed unnecessary quotation mark from p_extsaveg.c
  • Loading branch information
Noseey authored Dec 18, 2024
1 parent a87b615 commit 9317be8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 38 deletions.
39 changes: 4 additions & 35 deletions src/doom/p_extsaveg.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "s_sound.h"
#include "s_musinfo.h"
#include "z_zone.h"
#include "a11y.h"

#define MAX_LINE_LEN 260
#define MAX_STRING_LEN 80
Expand Down Expand Up @@ -164,6 +165,9 @@ static void P_ReadFireFlicker (const char *key)

flick->thinker.function.acp1 = (actionf_p1)T_FireFlicker;

if (!a11y_sector_lighting)
flick->sector->rlightlevel = flick->maxlight;

P_AddThinker(&flick->thinker);
}
}
Expand Down Expand Up @@ -236,40 +240,6 @@ static void P_ReadOldSpecial (const char *key)
}
}

// sector->rlightlevel

static void P_WriteRLightlevel (const char *key)
{
int i;
sector_t *sector;

for (i = 0, sector = sectors; i < numsectors; i++, sector++)
{
if (sector->rlightlevel != sector->lightlevel)
{
M_snprintf(line, MAX_LINE_LEN, "%s %d %d\n",
key,
i,
(int)sector->rlightlevel);
fputs(line, save_stream);
}
}
}

static void P_ReadRLightlevel (const char *key)
{
int sector, rlightlevel;

if (sscanf(line, "%s %d %d\n",
string,
&sector,
&rlightlevel) == 3 &&
!strncmp(string, key, MAX_STRING_LEN))
{
sectors[sector].rlightlevel = (short)rlightlevel;
}
}

// buttonlist[]

extern void P_StartButton (line_t *line, bwhere_e w, int texture, int time);
Expand Down Expand Up @@ -484,7 +454,6 @@ static const extsavegdata_t extsavegdata[] =
{"fireflicker", P_WriteFireFlicker, P_ReadFireFlicker, 1},
{"soundtarget", P_WriteSoundTarget, P_ReadSoundTarget, 1},
{"oldspecial", P_WriteOldSpecial, P_ReadOldSpecial, 1},
{"rlightlevel", P_WriteRLightlevel, P_ReadRLightlevel, 1},
{"button", P_WriteButton, P_ReadButton, 1},
{"braintarget", P_WriteBrainTarget, P_ReadBrainTarget, 1},
{"markpoints", P_WriteMarkPoints, P_ReadMarkPoints, 1},
Expand Down
8 changes: 8 additions & 0 deletions src/doom/p_lights.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void T_FireFlicker (fireflicker_t* flick)
// [crispy] A11Y
if (a11y_sector_lighting)
flick->sector->rlightlevel = flick->sector->lightlevel;
else
flick->sector->rlightlevel = flick->maxlight;
}


Expand Down Expand Up @@ -112,6 +114,8 @@ void T_LightFlash (lightflash_t* flash)
// [crispy] A11Y
if (a11y_sector_lighting)
flash->sector->rlightlevel = flash->sector->lightlevel;
else
flash->sector->rlightlevel = flash->maxlight;
}


Expand Down Expand Up @@ -172,6 +176,8 @@ void T_StrobeFlash (strobe_t* flash)
// [crispy] A11Y
if (a11y_sector_lighting)
flash->sector->rlightlevel = flash->sector->lightlevel;
else
flash->sector->rlightlevel = flash->maxlight;
}


Expand Down Expand Up @@ -347,6 +353,8 @@ void T_Glow(glow_t* g)
// [crispy] A11Y
if (a11y_sector_lighting)
g->sector->rlightlevel = g->sector->lightlevel;
else
g->sector->rlightlevel = g->maxlight;
}


Expand Down
10 changes: 10 additions & 0 deletions src/doom/p_saveg.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "z_zone.h"
#include "p_local.h"
#include "p_saveg.h"
#include "a11y.h"

// State.
#include "doomstat.h"
Expand Down Expand Up @@ -1283,6 +1284,9 @@ static void saveg_read_lightflash_t(lightflash_t *str)

// int mintime;
str->mintime = saveg_read32();

if (!a11y_sector_lighting)
str->sector->rlightlevel = str->maxlight;
}

static void saveg_write_lightflash_t(lightflash_t *str)
Expand Down Expand Up @@ -1338,6 +1342,9 @@ static void saveg_read_strobe_t(strobe_t *str)

// int brighttime;
str->brighttime = saveg_read32();

if (!a11y_sector_lighting)
str->sector->rlightlevel = str->maxlight;
}

static void saveg_write_strobe_t(strobe_t *str)
Expand Down Expand Up @@ -1387,6 +1394,9 @@ static void saveg_read_glow_t(glow_t *str)

// int direction;
str->direction = saveg_read32();

if (!a11y_sector_lighting)
str->sector->rlightlevel = str->maxlight;
}

static void saveg_write_glow_t(glow_t *str)
Expand Down
2 changes: 1 addition & 1 deletion src/doom/r_bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ void R_AddLine (seg_t* line)
// and no middle texture.
if (backsector->ceilingpic == frontsector->ceilingpic
&& backsector->floorpic == frontsector->floorpic
&& backsector->lightlevel == frontsector->lightlevel
&& backsector->rlightlevel == frontsector->rlightlevel
&& curline->sidedef->midtexture == 0)
{
return;
Expand Down
4 changes: 2 additions & 2 deletions src/doom/r_segs.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ R_StoreWallRange

if (worldlow != worldbottom
|| backsector->floorpic != frontsector->floorpic
|| backsector->lightlevel != frontsector->lightlevel)
|| backsector->rlightlevel != frontsector->rlightlevel)
{
markfloor = true;
}
Expand All @@ -741,7 +741,7 @@ R_StoreWallRange

if (worldhigh != worldtop
|| backsector->ceilingpic != frontsector->ceilingpic
|| backsector->lightlevel != frontsector->lightlevel)
|| backsector->rlightlevel != frontsector->rlightlevel)
{
markceiling = true;
}
Expand Down

0 comments on commit 9317be8

Please sign in to comment.