From: PatR Date: Mon, 25 Sep 2017 20:20:30 +0000 (-0700) Subject: candelabrum weight and burn out X-Git-Tag: NetHack-3.6.1_RC01~339 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26dd89103893755f7b244e06cb23a884fd39d547;p=nethack candelabrum weight and burn out Adjust the Candelabrum of Invocation's weight when it has candles attached. This has been a known issue ever since the candelabrum and candles were introduced. When the candelabrum burns out, update persistent inventory window to show that it no longer has candles. --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index c73d215dd..799450eea 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -443,11 +443,13 @@ fix buffer overflow in wizard mode for '#' command when 'extmenu' option is on "you suddenly vomit" was given two turns before actually vomiting, so you could get that message, move a bit, then get "you can move again" after the 2 turn freeze applied along with the actual vomit -fix mention_walls reporting secret doors as solid walls corpses and other flammable items not subject to direct burning or fire-based erosion which were thrown or dropped into lava remained intact if a potion on the floor survived a land mine explosion and got propelled at the hero, it didn't behave like a potion if it hit +adjust candelabrum's weight when candles are attached +when lit candelabrum burned out, persistent inventory window showed that it + was no longer lit but still showed phantom candles attached Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository @@ -504,6 +506,7 @@ hero poly'd into vampire could drain monster down to 0 HP without killing it, triggering impossible "dmonsfree: 1 removed doesn't match 0 pending" "you observe a fog cloud where a vampire/bat was" if an unseen vampire on the far side of a closed door shifted shape to pass under that door +fix mention_walls reporting secret doors as solid stone Platform- and/or Interface-Specific Fixes diff --git a/include/obj.h b/include/obj.h index 4cf4c3d9e..75b35779d 100644 --- a/include/obj.h +++ b/include/obj.h @@ -42,6 +42,7 @@ struct obj { schar spe; /* quality of weapon, weptool, armor or ring (+ or -); number of charges for wand or charged tool ( >= -1 ); + number of candles attached to candelabrum; marks your eggs, tin variety and spinach tins; Schroedinger's Box (1) or royal coffers for a court (2); tells which fruit a fruit is; diff --git a/src/apply.c b/src/apply.c index c72d65fbc..e19e86b71 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1224,6 +1224,9 @@ struct obj **optr; end_burn(obj, TRUE); /* candles are now gone */ useupall(obj); + /* candelabrum's weight is changing */ + otmp->owt = weight(otmp); + update_inventory(); } } diff --git a/src/mkobj.c b/src/mkobj.c index 78bb826f1..ab59719b7 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1339,7 +1339,7 @@ int weight(obj) register struct obj *obj; { - int wt = objects[obj->otyp].oc_weight; + int wt = (int) objects[obj->otyp].oc_weight; /* glob absorpsion means that merging globs accumulates weight while quantity stays 1, so update 'wt' to reflect that, unless owt is 0, @@ -1390,6 +1390,8 @@ register struct obj *obj; return (int) ((obj->quan + 50L) / 100L); } else if (obj->otyp == HEAVY_IRON_BALL && obj->owt != 0) { return (int) obj->owt; /* kludge for "very" heavy iron ball */ + } else if (obj->otyp == CANDELABRUM_OF_INVOCATION && obj->spe) { + return wt + obj->spe * (int) objects[TALLOW_CANDLE].oc_weight; } return (wt ? wt * (int) obj->quan : ((int) obj->quan + 1) >> 1); } diff --git a/src/timeout.c b/src/timeout.c index 94808fe88..a85baf552 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -966,7 +966,7 @@ anything *arg; long timeout; { struct obj *obj = arg->a_obj; - boolean canseeit, many, menorah, need_newsym; + boolean canseeit, many, menorah, need_newsym, need_invupdate; xchar x, y; char whose[BUFSZ]; @@ -983,6 +983,7 @@ long timeout; if (menorah) { obj->spe = 0; /* no more candles */ + obj->owt = weight(obj); } else if (Is_candle(obj) || obj->otyp == POT_OIL) { /* get rid of candles and burning oil potions; we know this object isn't carried by hero, @@ -1007,7 +1008,7 @@ long timeout; } else { canseeit = FALSE; } - need_newsym = FALSE; + need_newsym = need_invupdate = FALSE; /* obj->age is the age remaining at this point. */ switch (obj->otyp) { @@ -1016,6 +1017,8 @@ long timeout; if (canseeit) { switch (obj->where) { case OBJ_INVENT: + need_invupdate = TRUE; + /*FALLTHRU*/ case OBJ_MINVENT: pline("%spotion of oil has burnt away.", whose); break; @@ -1077,6 +1080,8 @@ long timeout; if (canseeit || obj->where == OBJ_INVENT) { switch (obj->where) { case OBJ_INVENT: + need_invupdate = TRUE; + /*FALLTHRU*/ case OBJ_MINVENT: if (obj->otyp == BRASS_LANTERN) pline("%slantern has run out of power.", whose); @@ -1154,6 +1159,8 @@ long timeout; if (menorah) { switch (obj->where) { case OBJ_INVENT: + need_invupdate = TRUE; + /*FALLTHRU*/ case OBJ_MINVENT: pline("%scandelabrum's flame%s.", whose, many ? "s die" : " dies"); @@ -1166,15 +1173,18 @@ long timeout; } else { switch (obj->where) { case OBJ_INVENT: + /* no need_invupdate for update_inventory() necessary; + useupall() -> freeinv() handles it */ + /*FALLTHRU*/ case OBJ_MINVENT: pline("%s %s consumed!", Yname2(obj), many ? "are" : "is"); break; case OBJ_FLOOR: /* - You see some wax candles consumed! - You see a wax candle consumed! - */ + You see some wax candles consumed! + You see a wax candle consumed! + */ You_see("%s%s consumed!", many ? "some " : "", many ? xname(obj) : an(xname(obj))); need_newsym = TRUE; @@ -1192,6 +1202,7 @@ long timeout; if (menorah) { obj->spe = 0; + obj->owt = weight(obj); } else { if (carried(obj)) { useupall(obj); @@ -1205,7 +1216,7 @@ long timeout; } obj = (struct obj *) 0; } - break; + break; /* case [age ==] 0 */ default: /* @@ -1218,8 +1229,7 @@ long timeout; if (obj && obj->age) begin_burn(obj, TRUE); - - break; + break; /* case [otyp ==] candelabrum|tallow_candle|wax_candle */ default: impossible("burn_object: unexpeced obj %s", xname(obj)); @@ -1227,6 +1237,8 @@ long timeout; } if (need_newsym) newsym(x, y); + if (need_invupdate) + update_inventory(); } /*