fix #K4006 - 'null obj after quiver merge' panic
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. 3.6.x was subject to this too and the fix is small+isolated but the situation is so uncommon that I haven't bothered backporting it. Applying a lump of royal jelly and then not picking anything to rub it on had a similar problem. It also panicked if the applied lump was wielded and other lumps were quivered. The fix is different because the stack it gets split from during apply is known. This one doesn't impact 3.6.x; applying jelly to eggs wasn't implemented yet.
This commit is contained in:
@@ -1583,7 +1583,9 @@ nhl_gamestate(lua_State *L)
|
||||
wornmask = otmp->owornmask;
|
||||
otmp->owornmask = 0L;
|
||||
extract_nobj(otmp, &gmst_invent);
|
||||
otmp->nomerge = 1;
|
||||
addinv(otmp);
|
||||
otmp->nomerge = 0;
|
||||
if (wornmask)
|
||||
setworn(otmp, wornmask);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user