]> granicus.if.org Git - nethack/commitdiff
drink_ok() tweak
authorPatR <rankin@nethack.org>
Sun, 17 Apr 2022 08:39:34 +0000 (01:39 -0700)
committerPatR <rankin@nethack.org>
Sun, 17 Apr 2022 08:39:34 +0000 (01:39 -0700)
Fix a comment typo and change the 'if obj/!obj' logic to be like what
was recently added to eat_ok()/offer_ok()/tin_ok().

src/potion.c

index 049952baf24aca0cb95b7142093c7722b6fab038..560ee592cfaa9426e8dd1a0ec9bfcaafe912e806 100644 (file)
@@ -500,18 +500,18 @@ ghost_from_bottle(void)
 static int
 drink_ok(struct obj *obj)
 {
-    if (obj && obj->oclass == POTION_CLASS)
-        return GETOBJ_SUGGEST;
-
     /* getobj()'s callback to test whether hands/self is a valid "item" to
        pick is used here to communicate the fact that player has already
        passed up an opportunity to perform the action (drink or dip) on a
        non-inventory dungeon feature, so if there are no potions in invent
        the message will be "you have nothing /else/ to {drink | dip into}";
        if player used 'm' prefix to bypass dungeon features, drink_ok_extra
-       will be 0 and the potential "else" will omitted */
-    if (!obj && drink_ok_extra)
-        return GETOBJ_EXCLUDE_NONINVENT;
+       will be 0 and the potential "else" will be omitted */
+    if (!obj)
+        return drink_ok_extra ? GETOBJ_EXCLUDE_NONINVENT : GETOBJ_EXCLUDE;
+
+    if (obj->oclass == POTION_CLASS)
+        return GETOBJ_SUGGEST;
 
     return GETOBJ_EXCLUDE;
 }
@@ -1065,7 +1065,7 @@ peffect_gain_level(struct obj *otmp)
         /* they went up a level */
         if ((ledger_no(&u.uz) == 1 && u.uhave.amulet)
             || Can_rise_up(u.ux, u.uy, &u.uz)) {
-            static const char *riseup = "rise up, through the %s!";
+            static const char riseup[] = "rise up, through the %s!";
 
             if (ledger_no(&u.uz) == 1) {
                 You(riseup, ceiling(u.ux, u.uy));