From 3faa0029ff19aa01104551d5d632e02ae8454727 Mon Sep 17 00:00:00 2001 From: Erik Lunna Date: Tue, 19 Sep 2023 21:38:15 +0200 Subject: [PATCH] fix #K4006 - 'null obj after quiver merge' panic (NetHack 3.7) 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. --- hackem_changelog.txt | 1 + src/apply.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hackem_changelog.txt b/hackem_changelog.txt index 22b70af2b..58a4d6447 100644 --- a/hackem_changelog.txt +++ b/hackem_changelog.txt @@ -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). diff --git a/src/apply.c b/src/apply.c index e11b0b88b..1a06d5c41 100644 --- a/src/apply.c +++ b/src/apply.c @@ -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.");