Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numiwadlumps needs re-evaluation, else embedded DEHACKED lumps are skipped #1101

Closed
kitchen-ace opened this issue Sep 29, 2023 · 4 comments · Fixed by chocolate-doom/chocolate-doom#1630
Assignees
Labels

Comments

@kitchen-ace
Copy link
Collaborator

Here's an odd one: This wad contains a sprite named SPIDA0D0, the first & fourth frame of the spiderdemon with rotation set to 0 so it's the same from all angles. The sprite itself loads fine, but causes the included DEHACKED lump to not be loaded, even with the -dehlump switch. All the DEH does is start you with 5 bullets instead of 50, and change the mapname of the first map.

W_Init: Init WADfiles.
 adding /home/user/Games/doom/doom2.wad
 merging spidbug.wad !
  loaded 0 DEHACKED lumps from PWAD files.

Loading the dehacked separately with -deh works fine. Deleting the SPIDA0D0 lump also makes the DEHACKED from the wad load fine.

The wad & deh also load properly in Woof & DSDA-Doom. The deh doesn't load in Chocolate with -dehlump -merge but I don't know if that counts as accurate vanilla behaviour or not.

spidbug.zip

@kitchen-ace
Copy link
Collaborator Author

kitchen-ace commented Sep 29, 2023

Wad is derived from one the user in this DW thread sent me:
https://www.doomworld.com/forum/topic/140304-solved-crispy-doom-is-not-loading-the-deh-file-in-my-wad-anymore/?tab=comments#comment-2709024

Oddly enough, that wad had a lot more sprites and other content, and it was the H0 and I0 frames of the spiderdemon that were causing problems. Renaming those fixed the wad, even though frames like SPIDA0D0 still existed.

@fabiangreffrath
Copy link
Owner

Not that odd, actually. The culprit is the numiwadlumps check in D_DoomMain().

Once the engine loads the IWAD, its value is set to numiwadlumps = numlumps.

numiwadlumps = numlumps;

For my copy of DOOM2.wad that'd be 2919. Then the PWAD is loaded and the numlumps value is increased by 4 (i.e. S_START, SPIDA0D0, S_END, DEHACKED).

numlumps += numfilelumps;

But then the lumps are merged in DoMerge() and the numlumps value decreases to 2913, i.e. below the inital value that initialized numiwadlumps.

numlumps = num_newlumps;

Thus, the for (i = numiwadlumps; i < numlumps; ++i) loop will never execute.

for (i = numiwadlumps; i < numlumps; ++i)

@kitchen-ace
Copy link
Collaborator Author

Huh, neat, I was totally unaware of most of that.

I guess this is a Chocolate Doom problem then?

@fabiangreffrath
Copy link
Owner

I guess this is a Chocolate Doom problem then?

Yes, probably. I'll see if I can fix it there.

@fabiangreffrath fabiangreffrath self-assigned this Oct 19, 2023
@fabiangreffrath fabiangreffrath changed the title Sprite replacement with 0 for viewing angles prevent embedded dehacked loading numiwadlumps needs re-evaluation, else embedded DEHACKED lumps are skipped Oct 19, 2023
fabiangreffrath added a commit to chocolate-doom/chocolate-doom that referenced this issue Oct 20, 2023
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 fabiangreffrath#1101
fabiangreffrath added a commit to chocolate-doom/chocolate-doom that referenced this issue Oct 20, 2023
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 fabiangreffrath#1101
voutilad pushed a commit to voutilad/chocolate-doom that referenced this issue Nov 29, 2023
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 fabiangreffrath/crispy-doom#1101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants