]> granicus.if.org Git - nethack/commitdiff
Unify unpolyable objects to single define
authorPasi Kallinen <paxed@alt.org>
Mon, 16 Nov 2020 16:42:12 +0000 (18:42 +0200)
committerPasi Kallinen <paxed@alt.org>
Mon, 16 Nov 2020 16:42:12 +0000 (18:42 +0200)
include/obj.h
src/potion.c
src/zap.c

index 4b6f6d5c8f15cd9deacab65537e720ea36d866a6..89d932251302e56bf26de71ed307a5f07a9f6de0 100644 (file)
@@ -356,6 +356,10 @@ struct obj {
          && !undiscovered_artifact(ART_EYES_OF_THE_OVERWORLD)))
 #define pair_of(o) ((o)->otyp == LENSES || is_gloves(o) || is_boots(o))
 
+#define unpolyable(o) ((o)->otyp == WAN_POLYMORPH \
+                       || (o)->otyp == SPE_POLYMORPH \
+                       || (o)->otyp == POT_POLYMORPH)
+
 /* achievement tracking; 3.6.x did this differently */
 #define is_mines_prize(o) ((o)->o_id == g.context.achieveo.mines_prize_oid)
 #define is_soko_prize(o) ((o)->o_id == g.context.achieveo.soko_prize_oid)
index 02484db07d582ade0f47ebffbebe0ee9f4f74137..a0e2256ed659c6a5de5fe858b3bea11988741d2a 100644 (file)
@@ -1978,7 +1978,7 @@ dodip()
     } else if (obj->otyp == POT_POLYMORPH || potion->otyp == POT_POLYMORPH) {
         /* some objects can't be polymorphed */
         if (obj->otyp == potion->otyp /* both POT_POLY */
-            || obj->otyp == WAN_POLYMORPH || obj->otyp == SPE_POLYMORPH
+            || unpolyable(obj)
             || obj == uball || obj == uskin
             || obj_resists(obj->otyp == POT_POLYMORPH ? potion : obj,
                            5, 95)) {
index 0494a9fb0c1a7be853ba20982a2b11c9318a3b0c..b8fd955ae3b73b405e16da7d7cb81371ee9b6d97 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1964,8 +1964,7 @@ struct obj *obj, *otmp;
         switch (otmp->otyp) {
         case WAN_POLYMORPH:
         case SPE_POLYMORPH:
-            if (obj->otyp == WAN_POLYMORPH || obj->otyp == SPE_POLYMORPH
-                || obj->otyp == POT_POLYMORPH || obj_resists(obj, 5, 95)) {
+            if (unpolyable(obj) || obj_resists(obj, 5, 95)) {
                 res = 0;
                 break;
             }