]> granicus.if.org Git - nethack/commitdiff
Use macros for monster appearances
authorPasi Kallinen <paxed@alt.org>
Sun, 18 Oct 2015 10:55:11 +0000 (13:55 +0300)
committerPasi Kallinen <paxed@alt.org>
Sun, 18 Oct 2015 10:55:11 +0000 (13:55 +0300)
include/monst.h
src/display.c
src/eat.c
src/hack.c
src/lock.c
src/mcastu.c
src/mon.c
src/monmove.c
src/pager.c
src/vision.c
src/zap.c

index 0e686e07bdf4270b932c0b2b23437003e6e81500..3c88d017276337acbd7a23fa4964d4cb0fb55068 100644 (file)
@@ -159,4 +159,8 @@ struct monst {
 #define is_vampshifter(mon)                                      \
     ((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LORD \
      || (mon)->cham == PM_VLAD_THE_IMPALER)
+#define is_door_mappear(mon) ((mon)->m_ap_type == M_AP_FURNITURE \
+     && ((mon)->mappearance == S_hcdoor || (mon)->mappearance == S_vcdoor))
+#define is_obj_mappear(mon,otyp) ((mon)->m_ap_type == M_AP_OBJECT \
+     && (mon)->mappearance == (otyp))
 #endif /* MONST_H */
index 000900efe95bf8a4c5fc208d113cd5b8512ee6ac..84f895494f1437ed5bafa8676e3d4a7b8c8921d6 100644 (file)
@@ -1179,11 +1179,8 @@ set_mimic_blocking()
     for (mon = fmon; mon; mon = mon->nmon) {
         if (DEADMONSTER(mon))
             continue;
-        if (mon->minvis && ((mon->m_ap_type == M_AP_FURNITURE
-                             && (mon->mappearance == S_vcdoor
-                                 || mon->mappearance == S_hcdoor))
-                            || (mon->m_ap_type == M_AP_OBJECT
-                                && mon->mappearance == BOULDER))) {
+        if (mon->minvis && (is_door_mappear(mon)
+                            || is_obj_mappear(mon,BOULDER))) {
             if (See_invisible)
                 block_point(mon->mx, mon->my);
             else
index 4367e652803bc4f27105160b677c2c00bc9b79a9..8bf0653b906c5a0235d60430ccf5ebfcd7ce2f26 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -161,13 +161,11 @@ eatmupdate()
     if (!eatmbuf || nomovemsg != eatmbuf)
         return;
 
-    if (youmonst.m_ap_type == M_AP_OBJECT && youmonst.mappearance == ORANGE
-        && !Hallucination) {
+    if (is_obj_mappear(&youmonst,ORANGE) && !Hallucination) {
         /* revert from hallucinatory to "normal" mimicking */
         altmsg = "You now prefer mimicking yourself.";
         altapp = GOLD_PIECE;
-    } else if (youmonst.m_ap_type == M_AP_OBJECT
-               && youmonst.mappearance == GOLD_PIECE && Hallucination) {
+    } else if (is_obj_mappear(&youmonst,GOLD_PIECE) && Hallucination) {
         /* won't happen; anything which might make immobilized
            hero begin hallucinating (black light attack, theft
            of Grayswandir) will terminate the mimicry first */
index a94ed9183e0f996de5db632973721649b5b09414..bbe6df83f73cc6dde6966f306929236e005ee199 100644 (file)
@@ -2416,9 +2416,7 @@ lookaround()
                 || IS_AIR(levl[x][y].typ))
                 continue;
             else if (closed_door(x, y)
-                     || (mtmp && mtmp->m_ap_type == M_AP_FURNITURE
-                         && (mtmp->mappearance == S_hcdoor
-                             || mtmp->mappearance == S_vcdoor))) {
+                     || (mtmp && is_door_mappear(mtmp))) {
                 if (x != u.ux && y != u.uy)
                     continue;
                 if (context.run != 1)
index c2c06067af9b7db682c3847f675df0b18a4b3744..869860fec4c9267783641685c271b6aece2a5ba2 100644 (file)
@@ -389,11 +389,7 @@ register struct obj *pick;
                 pline("I don't think %s would appreciate that.",
                       mon_nam(mtmp));
             return PICKLOCK_LEARNED_SOMETHING;
-        } else if (mtmp && mtmp->m_ap_type == M_AP_FURNITURE &&
-                   /* not IS_DOOR() here; for M_AP_FURNITURE, mappearance
-                      holds a map symbol rather than a topology type */
-                   (mtmp->mappearance == S_vcdoor
-                    || mtmp->mappearance == S_hcdoor)) {
+        } else if (mtmp && is_door_mappear(mtmp)) {
             /* "The door actually was a <mimic>!" */
             stumble_onto_mimic(mtmp);
             /* mimic might keep the key (50% chance, 10% for PYEC) */
@@ -539,8 +535,7 @@ stumble_on_door_mimic(x, y)
 int x, y;
 {
     struct monst *mtmp;
-    if ((mtmp = m_at(x, y)) && mtmp->m_ap_type == M_AP_FURNITURE
-        && (mtmp->mappearance == S_hcdoor || mtmp->mappearance == S_vcdoor)
+    if ((mtmp = m_at(x, y)) && is_door_mappear(mtmp)
         && !Protection_from_shape_changers) {
         stumble_onto_mimic(mtmp);
         return TRUE;
index 94a4d97e3cdbfe669a5ecfc00469a3770e557b62..3b3c032864a587710e1260478e893a1390035f8c 100644 (file)
@@ -55,8 +55,7 @@ boolean undirected;
             point_msg = "all around, then curses";
         else if ((Invis && !perceives(mtmp->data)
                   && (mtmp->mux != u.ux || mtmp->muy != u.uy))
-                 || (youmonst.m_ap_type == M_AP_OBJECT
-                     && youmonst.mappearance == STRANGE_OBJECT)
+                 || is_obj_mappear(&youmonst, STRANGE_OBJECT)
                  || u.uundetected)
             point_msg = "and curses in your general direction";
         else if (Displaced && (mtmp->mux != u.ux || mtmp->muy != u.uy))
index 786471e3485592657a2336cfd4d7053f568ff021..a620fb592a134763b0472ca353147410b20761fb 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -2531,8 +2531,8 @@ void
 seemimic(mtmp)
 register struct monst *mtmp;
 {
-    unsigned old_app = mtmp->mappearance;
-    uchar old_ap_type = mtmp->m_ap_type;
+    boolean is_blocker_appear = is_door_mappear(mtmp) ||
+        is_obj_mappear(mtmp, BOULDER);
 
     if (has_mcorpsenm(mtmp))
         freemcorpsenm(mtmp);
@@ -2543,9 +2543,7 @@ register struct monst *mtmp;
     /*
      *  Discovered mimics don't block light.
      */
-    if (((old_ap_type == M_AP_FURNITURE
-          && (old_app == S_hcdoor || old_app == S_vcdoor))
-         || (old_ap_type == M_AP_OBJECT && old_app == BOULDER))
+    if (is_blocker_appear
         && !does_block(mtmp->mx, mtmp->my, &levl[mtmp->mx][mtmp->my]))
         unblock_point(mtmp->mx, mtmp->my);
 
index 92baf26a0e44da53c14e83ef1c4f425f7f4287c9..e9e14cd8ec8da32b0b3a8575f5c27f178e12e44e 100644 (file)
@@ -845,10 +845,8 @@ not_special:
 
         if (!mtmp->mcansee
             || (should_see && Invis && !perceives(ptr) && rn2(11))
-            || (youmonst.m_ap_type == M_AP_OBJECT
-                && youmonst.mappearance == STRANGE_OBJECT) || u.uundetected
-            || (youmonst.m_ap_type == M_AP_OBJECT
-                && youmonst.mappearance == GOLD_PIECE && !likes_gold(ptr))
+            || is_obj_mappear(&youmonst,STRANGE_OBJECT) || u.uundetected
+            || (is_obj_mappear(&youmonst,GOLD_PIECE) && !likes_gold(ptr))
             || (mtmp->mpeaceful && !mtmp->isshk) || /* allow shks to follow */
             ((monsndx(ptr) == PM_STALKER || ptr->mlet == S_BAT
               || ptr->mlet == S_LIGHT) && !rn2(3)))
index 1138c06ac8feaf95388b639efba446b422cb384b..94ffcd18a4c21f542e19e65cecee08472d6bc59e 100644 (file)
@@ -89,8 +89,7 @@ struct obj **obj_p;
     *obj_p = (struct obj *) 0;
     /* there might be a mimic here posing as an object */
     mtmp = m_at(x, y);
-    if (mtmp && mtmp->m_ap_type == M_AP_OBJECT
-        && mtmp->mappearance == (unsigned) glyphotyp)
+    if (mtmp && is_obj_mappear(mtmp, (unsigned) glyphotyp))
         otmp = 0;
     else
         mtmp = 0;
index 10e01abec562b5908fa16641b12664a1b2eb1b1d..c3e072ab2b2ff79aaa59e9d6b2cbd900f1cea79a 100644 (file)
@@ -178,11 +178,7 @@ register struct rm *lev;
 
     /* Mimics mimicing a door or boulder block light. */
     if ((mon = m_at(x, y)) && (!mon->minvis || See_invisible)
-        && ((mon->m_ap_type == M_AP_FURNITURE
-             && (mon->mappearance == S_hcdoor
-                 || mon->mappearance == S_vcdoor))
-            || (mon->m_ap_type == M_AP_OBJECT
-                && mon->mappearance == BOULDER)))
+        && (is_door_mappear(mon) || is_obj_mappear(mon,BOULDER)))
         return 1;
 
     return 0;
index 9ed99017d1cba323102140c6e449cce29a40cd44..106f9bfc2fa99950871a4082a43cb4625a35cc84 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -320,8 +320,7 @@ struct obj *otmp;
             }
             if (canseemon(mtmp)) {
                 if (disguised_mimic) {
-                    if (mtmp->m_ap_type == M_AP_OBJECT
-                        && mtmp->mappearance == STRANGE_OBJECT) {
+                    if (is_obj_mappear(mtmp,STRANGE_OBJECT)) {
                         /* it can do better now */
                         set_mimic_sym(mtmp);
                         newsym(mtmp->mx, mtmp->my);