fix github issue #1191 - obj->age of oil potions

Issue reported by AmyBSOD:  several actions change the object type of
a potion rather than force creation of a replacement one, and if/when
the type was changed to oil, the age wasn't converted from absolute
to relative.  Relative age is the amount available and/or the number
of turns it will burn if applied.  The later in a game a potion got
converted into oil, the longer it would burn.  Not mentioned:  reverse
situation was also the case, although that didn't have any noticeable
effect since incorrect absolute age of former oil doesn't matter.

Not thoroughly tested.  I got a potion of oil from a horn of plenty
and it burned for 400 turns, but it might have been created directly
rather than be a rejected magic potion that was converted into oil.

Closes #1191
This commit is contained in:
PatR
2024-01-03 13:29:15 -08:00
parent db4a44735e
commit c6897bf331
5 changed files with 51 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 potion.c $NHDT-Date: 1699582924 2023/11/10 02:22:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.251 $ */
/* NetHack 3.7 potion.c $NHDT-Date: 1704316448 2024/01/03 21:14:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.256 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2504,6 +2504,9 @@ potion_dip(struct obj *obj, struct obj *potion)
case 4:
otmp = mkobj(POTION_CLASS, FALSE);
obj->otyp = otmp->otyp;
/* oil uses obj->age field differently from other potions */
if (obj->otyp == POT_OIL || otmp->otyp == POT_OIL)
fixup_oil(obj, otmp);
obfree(otmp, (struct obj *) 0);
break;
default: