From 35eb289cc3b33096354e9605651bdeaa85cdec69 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 23 Dec 2023 16:15:38 -0800 Subject: [PATCH] "partly used candle" fix If you wished for "lit candle" you'd get an unused candle that is pre-lit but the feedback as it's added to inventory would be "partly used candle (lit)". If snuffed out immediately, it reverts to "candle" (ie, not partly used). This fixes the first aspect: you will get "candle (lit)" added to inventory. On the next turn it changes to partly used as expected. The second aspect, reverting to not-used-yet after being lit during the wish is left as-is. --- doc/fixes3-7-0.txt | 2 ++ src/objnam.c | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 06de24736..c2683835e 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1335,6 +1335,8 @@ riding negates stealth unless the steed is flying previous hero rising as undead in bones retains intrinsics level temperature affects monster generation amulet of unchanging cannot be polymorphed +wishing for a "lit candle" provided one, but the feedback as it was added into + invent was "partly used candle (lit)" because of how 'lit' timer works Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/objnam.c b/src/objnam.c index a7ee15687..683c9963b 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1293,9 +1293,25 @@ doname_base( break; } else if (obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP || obj->otyp == BRASS_LANTERN || Is_candle(obj)) { - if (Is_candle(obj) - && obj->age < 20L * (long) objects[obj->otyp].oc_cost) - Strcat(prefix, "partly used "); + if (Is_candle(obj)) { + anything timer; + long full_burn_time = 20L * (long) objects[obj->otyp].oc_cost, + turns_left = obj->age; + + if (obj->lamplit) { + timer = cg.zeroany; + timer.a_obj = obj; + /* without this, wishing for "lit candle" yields + "partly used candle (lit)" because the time it can + burn gets adjusted when it becomes lit; matters for + the message as it gets added to invent and also if it + gets snuffed out immediately (where it will end up as + not partly used after all) */ + turns_left += peek_timer(BURN_OBJECT, &timer) - gm.moves; + } + if (turns_left < full_burn_time) + Strcat(prefix, "partly used "); + } if (obj->lamplit) Strcat(bp, " (lit)"); break;