]> granicus.if.org Git - nethack/commitdiff
candelabrum weight and burn out
authorPatR <rankin@nethack.org>
Mon, 25 Sep 2017 20:20:30 +0000 (13:20 -0700)
committerPatR <rankin@nethack.org>
Mon, 25 Sep 2017 20:20:30 +0000 (13:20 -0700)
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.

doc/fixes36.1
include/obj.h
src/apply.c
src/mkobj.c
src/timeout.c

index c73d215dd3bfeb7b3c27850001fcc29b3381c90c..799450eeaca7d6d81d8fcafd58e895acd54b4d46 100644 (file)
@@ -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
index 4cf4c3d9eddd6cb562de7b010cda6c2f6f674cbc..75b35779d355c5597eb9496f0c543ee5d8bc5149 100644 (file)
@@ -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;
index c72d65fbcfe49644e595559168d4acd04ac30f52..e19e86b71627ce8f6be0874377fc7b03309ef6f7 100644 (file)
@@ -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();
     }
 }
 
index 78bb826f1a46af0b77a80f0464873c93b3468d77..ab59719b744dc9b4e7b61ac1dc08656cc7c17f61 100644 (file)
@@ -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);
 }
index 94808fe8874c59189bfb139e3dc76583d29460ca..a85baf552db80a1101ce37a4b2e7dbaca5bde1ae 100644 (file)
@@ -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();
 }
 
 /*