Skip to content

Commit

Permalink
fix #K4006 - 'null obj after quiver merge' panic (NetHack 3.7)
Browse files Browse the repository at this point in the history
Using apply to unlight a lit potion of oil makes it unlit, removes
it from inventory, and then re-adds it to try to force it to merge
with other potions of oil.  If it was wielded and the other potions
were quivered, the game would panic.  When merging, they get forced
into the weapon slot in preference to the quiver slot.

Unwearing it before freeinv+addinv would solve this but also leave
the hero with nothing wielded, even if it didn't merge with another
stack.  Instead, don't try to merge if the potion being unlit happens
to be worn.
  • Loading branch information
elunna committed Sep 19, 2023
1 parent 3ef25c9 commit 3faa002
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions hackem_changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Version 1.2.1 (unreleased)

fix #K4006 - 'null obj after quiver merge' panic (NetHack 3.7)
Gave fire bolt a little to-hit boost.
Chaotic dragons can betray you (from SLASH'EM).
Fix: follow-up to last commit (kicking and martial arts) (From EvilHack).
Expand Down
10 changes: 7 additions & 3 deletions src/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,10 +1674,14 @@ struct obj **optr;
/*
* Free & add to re-merge potion. This will average the
* age of the potions. Not exactly the best solution,
* but its easy.
* but its easy. Don't do that unless obj is not worn (uwep,
* uswapwep, or uquiver) because if wielded and other oil is
* quivered a "null obj after quiver merge" panic will occur.
*/
freeinv(obj);
*optr = addinv(obj);
if (!obj->owornmask) {
freeinv(obj);
*optr = addinv(obj);
}
return;
} else if (Underwater) {
There("is not enough oxygen to sustain a fire.");
Expand Down

0 comments on commit 3faa002

Please sign in to comment.