Skip to content

Commit

Permalink
Doom: Reconstruct maxlight if no a11y_sector_lighting when unarchivin…
Browse files Browse the repository at this point in the history
…g thinker.
  • Loading branch information
Noseey committed Dec 18, 2024
1 parent f39b4ec commit a10b521
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 35 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
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

0 comments on commit a10b521

Please sign in to comment.