commit 7d44fa1959d7d9058edbeead1bb2baaf23b0d102
Author: Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Fri Oct 20 12:42:07 2023 +0200
Commit: GitHub <noreply@github.com>
CommitDate: Fri Oct 20 12:42:07 2023 +0200
evaluate `numiwadlumps` after `DoMerge()` has been called (#1630)
If a merged PWAD contains sprites, these get mangled into the IWAD
sprites, changing the value of `numlumps` and thus invalidating the
value of `numiwadlumps` determined earlier. Also, this variable is
only used in one occasion, so only evaluate it as needed.
This approach makes sure `numiwadlumps` points past the index of the
last IWAD lump in the linear `lumpinfo[]` array.
Fixes https://github.com/fabiangreffrath/crispy-doom/issues/1101
---
src/doom/d_main.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index 0bab43c1..d2e0c635 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1294,7 +1294,6 @@ void D_DoomMain (void)
int p;
char file[256];
char demolumpname[9];
- int numiwadlumps;
I_AtExit(D_Endoom, false);
@@ -1504,7 +1503,6 @@ void D_DoomMain (void)
DEH_printf("W_Init: Init WADfiles.\n");
D_AddFile(iwadfile);
- numiwadlumps = numlumps;
W_CheckCorrectIWAD(doom);
@@ -1706,6 +1704,12 @@ void D_DoomMain (void)
if (M_ParmExists("-dehlump"))
{
int i, loaded = 0;
+ int numiwadlumps = numlumps;
+
+ while (!W_IsIWADLump(lumpinfo[numiwadlumps - 1]))
+ {
+ numiwadlumps--;
+ }
for (i = numiwadlumps; i < numlumps; ++i)
{