]> granicus.if.org Git - nethack/commitdiff
raceptr()
authornethack.allison <nethack.allison>
Mon, 30 Dec 2002 01:42:36 +0000 (01:42 +0000)
committernethack.allison <nethack.allison>
Mon, 30 Dec 2002 01:42:36 +0000 (01:42 +0000)
Add a routine for returning a ptr
to the correct race of monst.
Compensates for polyd and non-polyd player.

include/extern.h
src/mondata.c
src/worn.c

index 6394878e91d37a7c51a0e6f4e2752413909379bc..1c292041766da60827a387fbd6b911ebd8de95d8 100644 (file)
@@ -1167,6 +1167,7 @@ E int FDECL(big_to_little, (int));
 E const char *FDECL(locomotion, (const struct permonst *,const char *));
 E const char *FDECL(stagger, (const struct permonst *,const char *));
 E const char *FDECL(on_fire, (struct permonst *,struct attack *));
+E const struct permonst *FDECL(raceptr, (struct monst *));
 
 /* ### monmove.c ### */
 
index 81dbe913e6cd420473745746ce2d87a609eabb5d..fd15557a2d49f7537d394842c8bee669368497e1 100644 (file)
@@ -616,6 +616,19 @@ int montype;
        return montype;
 }
 
+/*
+ * Return the permonst ptr for the race of the monster.
+ * Returns correct pointer for non-polymorphed and polymorphed
+ * player.  It does not return a pointer to player role character.
+ */
+const struct permonst *
+raceptr(mtmp)
+struct monst *mtmp;
+{
+    if (mtmp == &youmonst && !Upolyd) return(&mons[urace.malenum]);
+    else return(mtmp->data);
+}
+
 static const char *levitate[4] = { "float", "Float", "wobble", "Wobble" };
 static const char *flys[4]     = { "fly", "Fly", "flutter", "Flutter" };
 static const char *flyl[4]     = { "fly", "Fly", "stagger", "Stagger" };
index 40693d8149154ad5be6452ebe62e330574248ee3..b89f0ddc6fb58153adc3d5f76676887d0f914dbf 100644 (file)
@@ -761,10 +761,7 @@ racial_exception(mon, obj)
 struct monst *mon;
 struct obj *obj;
 {
-    struct permonst *ptr;
-
-    if (mon == &youmonst && !Upolyd) ptr = &mons[urace.malenum];
-    else ptr = mon->data;
+    const struct permonst *ptr = raceptr(mon);
 
     /* Acceptable Exceptions: */
     /* Allow hobbits to wear elven armor - LoTR */