]> granicus.if.org Git - nethack/commitdiff
makemon and goodpos flags
authorPatR <rankin@nethack.org>
Mon, 4 May 2020 16:19:37 +0000 (09:19 -0700)
committerPatR <rankin@nethack.org>
Mon, 4 May 2020 16:19:37 +0000 (09:19 -0700)
I added another goodpos flag to simplify handling displacer beast
and that pushed the total number of makemon and goodpos flags past
16.  'int' and 'unsigned' might be too small, so change the flags
and several function arguments to 'long'.

include/extern.h
include/hack.h
src/makemon.c
src/teleport.c

index 61e0d954aff1867f6ac4b5f6fa95bc6fde44df99..376e50f20e633d182176156b63074929e45a471c 100644 (file)
@@ -1225,8 +1225,8 @@ E void FDECL(newmonhp, (struct monst *, int));
 E struct mextra *NDECL(newmextra);
 E void FDECL(copy_mextra, (struct monst *, struct monst *));
 E void FDECL(dealloc_mextra, (struct monst *));
-E struct monst *FDECL(makemon, (struct permonst *, int, int, int));
-E struct monst *FDECL(unmakemon, (struct monst *, int));
+E struct monst *FDECL(makemon, (struct permonst *, int, int, long));
+E struct monst *FDECL(unmakemon, (struct monst *, long));
 E boolean FDECL(create_critters, (int, struct permonst *, BOOLEAN_P));
 E struct permonst *NDECL(rndmonst);
 E struct permonst *FDECL(mkclass, (CHAR_P, int));
@@ -2584,10 +2584,10 @@ E boolean FDECL(stucksteed, (BOOLEAN_P));
 /* ### teleport.c ### */
 
 E boolean FDECL(noteleport_level, (struct monst *));
-E boolean FDECL(goodpos, (int, int, struct monst *, unsigned));
+E boolean FDECL(goodpos, (int, int, struct monst *, long));
 E boolean FDECL(enexto, (coord *, XCHAR_P, XCHAR_P, struct permonst *));
 E boolean FDECL(enexto_core, (coord *, XCHAR_P, XCHAR_P,
-                              struct permonst *, unsigned));
+                              struct permonst *, long));
 E void FDECL(teleds, (int, int, int));
 E boolean FDECL(safe_teleds, (int));
 E boolean FDECL(teleport_pet, (struct monst *, BOOLEAN_P));
index e9aaa931c8f1f4ba21f40e5bb8e3b736d5c2cd19..4ea786b337f6edebe56da88eab1ce06fd53af101 100644 (file)
@@ -289,27 +289,26 @@ typedef struct sortloot_item Loot;
 #include "extern.h"
 #endif /* USE_TRAMPOLI */
 
-/* flags to control makemon(); goodpos() uses some plus has some of its own;
-   these flags have exceeded 16-bits worth so ought to be changed to 'long' */
-#define NO_MM_FLAGS 0x00000 /* use this rather than plain 0 */
-#define NO_MINVENT  0x00001 /* suppress minvent when creating mon */
-#define MM_NOWAIT   0x00002 /* don't set STRAT_WAITMASK flags */
-#define MM_NOCOUNTBIRTH 0x00004 /* don't increment born count (for revival) */
-#define MM_IGNOREWATER  0x00008 /* ignore water when positioning */
-#define MM_ADJACENTOK   0x00010 /* acceptable to use adjacent coordinates */
-#define MM_ANGRY    0x00020 /* monster is created angry */
-#define MM_NONAME   0x00040 /* monster is not christened */
-#define MM_EGD      0x00100 /* add egd structure */
-#define MM_EPRI     0x00200 /* add epri structure */
-#define MM_ESHK     0x00400 /* add eshk structure */
-#define MM_EMIN     0x00800 /* add emin structure */
-#define MM_EDOG     0x01000 /* add edog structure */
-#define MM_ASLEEP   0x02000 /* monsters should be generated asleep */
-#define MM_NOGRP    0x04000 /* suppress creation of monster groups */
+/* flags to control makemon(); goodpos() uses some plus has some of its own*/
+#define NO_MM_FLAGS 0x000000L /* use this rather than plain 0 */
+#define NO_MINVENT  0x000001L /* suppress minvent when creating mon */
+#define MM_NOWAIT   0x000002L /* don't set STRAT_WAITMASK flags */
+#define MM_NOCOUNTBIRTH 0x0004L /* don't increment born count (for revival) */
+#define MM_IGNOREWATER  0x0008L /* ignore water when positioning */
+#define MM_ADJACENTOK   0x0010L /* acceptable to use adjacent coordinates */
+#define MM_ANGRY    0x000020L /* monster is created angry */
+#define MM_NONAME   0x000040L /* monster is not christened */
+#define MM_EGD      0x000100L /* add egd structure */
+#define MM_EPRI     0x000200L /* add epri structure */
+#define MM_ESHK     0x000400L /* add eshk structure */
+#define MM_EMIN     0x000800L /* add emin structure */
+#define MM_EDOG     0x001000L /* add edog structure */
+#define MM_ASLEEP   0x002000L /* monsters should be generated asleep */
+#define MM_NOGRP    0x004000L /* suppress creation of monster groups */
 /* if more MM_ flag masks are added, skip or renumber the GP_ one(s) */
-#define GP_ALLOW_XY 0x08000 /* [actually used by enexto() to decide whether
-                             * to make an extra call to goodpos()]          */
-#define GP_ALLOW_U  0x10000 /* don't reject hero's location */
+#define GP_ALLOW_XY 0x008000L /* [actually used by enexto() to decide whether
+                               * to make an extra call to goodpos()]        */
+#define GP_ALLOW_U  0x010000L /* don't reject hero's location */
 
 /* flags for make_corpse() and mkcorpstat() */
 #define CORPSTAT_NONE 0x00
index a6aee572d1007c4a4ed2f8b81b2d63ddb92845fc..eafcf23605cbb860e2d1e65826626e4f817181db 100644 (file)
@@ -22,8 +22,7 @@ static void FDECL(m_initgrp, (struct monst *, int, int, int, int));
 static void FDECL(m_initthrow, (struct monst *, int, int));
 static void FDECL(m_initweap, (struct monst *));
 static void FDECL(m_initinv, (struct monst *));
-static boolean FDECL(makemon_rnd_goodpos, (struct monst *,
-                                               unsigned, coord *));
+static boolean FDECL(makemon_rnd_goodpos, (struct monst *, long, coord *));
 
 #define m_initsgrp(mtmp, x, y, mmf) m_initgrp(mtmp, x, y, 3, mmf)
 #define m_initlgrp(mtmp, x, y, mmf) m_initgrp(mtmp, x, y, 10, mmf)
@@ -1046,11 +1045,11 @@ newmextra()
 static boolean
 makemon_rnd_goodpos(mon, gpflags, cc)
 struct monst *mon;
-unsigned gpflags;
+long gpflags;
 coord *cc;
 {
     int tryct = 0;
-    int nx,ny;
+    int nx, ny;
     boolean good;
 
     do {
@@ -1119,7 +1118,7 @@ struct monst *
 makemon(ptr, x, y, mmflags)
 register struct permonst *ptr;
 register int x, y;
-int mmflags;
+long mmflags;
 {
     register struct monst *mtmp;
     struct monst fakemon;
@@ -1425,7 +1424,7 @@ int mmflags;
 struct monst *
 unmakemon(mon, mmflags)
 struct monst *mon;
-int mmflags;
+long mmflags;
 {
     boolean countbirth = ((mmflags & MM_NOCOUNTBIRTH) == 0);
     int mndx = monsndx(mon->data);
index 6ba3ab56e5be131142ad7687b10f993ddb2052dc..a29808b00eecbe72d2979f57e90f847af46ba7ef 100644 (file)
@@ -42,7 +42,7 @@ boolean
 goodpos(x, y, mtmp, gpflags)
 int x, y;
 struct monst *mtmp;
-unsigned gpflags;
+long gpflags;
 {
     struct permonst *mdat = (struct permonst *) 0;
     boolean ignorewater = ((gpflags & MM_IGNOREWATER) != 0),
@@ -147,7 +147,7 @@ enexto_core(cc, xx, yy, mdat, entflags)
 coord *cc;
 xchar xx, yy;
 struct permonst *mdat;
-unsigned entflags;
+long entflags;
 {
 #define MAX_GOOD 15
     coord good[MAX_GOOD], *good_ptr;
@@ -251,28 +251,28 @@ int x1, y1, x2, y2;
         return FALSE;
     if (g.dndest.nlx > 0) {
         /* if inside a restricted region, can't teleport outside */
-        if (within_bounded_area(x1, y1, g.dndest.nlx, g.dndest.nly, g.dndest.nhx,
-                                g.dndest.nhy)
+        if (within_bounded_area(x1, y1, g.dndest.nlx, g.dndest.nly,
+                                g.dndest.nhx, g.dndest.nhy)
             && !within_bounded_area(x2, y2, g.dndest.nlx, g.dndest.nly,
                                     g.dndest.nhx, g.dndest.nhy))
             return FALSE;
         /* and if outside, can't teleport inside */
-        if (!within_bounded_area(x1, y1, g.dndest.nlx, g.dndest.nly, g.dndest.nhx,
-                                 g.dndest.nhy)
-            && within_bounded_area(x2, y2, g.dndest.nlx, g.dndest.nly, g.dndest.nhx,
-                                   g.dndest.nhy))
+        if (!within_bounded_area(x1, y1, g.dndest.nlx, g.dndest.nly,
+                                 g.dndest.nhx, g.dndest.nhy)
+            && within_bounded_area(x2, y2, g.dndest.nlx, g.dndest.nly,
+                                   g.dndest.nhx, g.dndest.nhy))
             return FALSE;
     }
     if (g.updest.nlx > 0) { /* ditto */
-        if (within_bounded_area(x1, y1, g.updest.nlx, g.updest.nly, g.updest.nhx,
-                                g.updest.nhy)
+        if (within_bounded_area(x1, y1, g.updest.nlx, g.updest.nly,
+                                g.updest.nhx, g.updest.nhy)
             && !within_bounded_area(x2, y2, g.updest.nlx, g.updest.nly,
                                     g.updest.nhx, g.updest.nhy))
             return FALSE;
-        if (!within_bounded_area(x1, y1, g.updest.nlx, g.updest.nly, g.updest.nhx,
-                                 g.updest.nhy)
-            && within_bounded_area(x2, y2, g.updest.nlx, g.updest.nly, g.updest.nhx,
-                                   g.updest.nhy))
+        if (!within_bounded_area(x1, y1, g.updest.nlx, g.updest.nly,
+                                 g.updest.nhx, g.updest.nhy)
+            && within_bounded_area(x2, y2, g.updest.nlx, g.updest.nly,
+                                   g.updest.nhx, g.updest.nhy))
             return FALSE;
     }
     return TRUE;
@@ -1126,7 +1126,7 @@ unsigned trflags;
     char verbbuf[BUFSZ];
     boolean intentional = FALSE;
 
-    if ((trflags & (VIASITTING|FORCETRAP)) != 0) {
+    if ((trflags & (VIASITTING | FORCETRAP)) != 0) {
         Strcpy(verbbuf, "trigger"); /* follows "You sit down." */
         intentional = TRUE;
     } else
@@ -1181,13 +1181,15 @@ struct monst *mtmp;
             return (within_bounded_area(x, y, g.updest.lx, g.updest.ly,
                                         g.updest.hx, g.updest.hy)
                     && (!g.updest.nlx
-                        || !within_bounded_area(x, y, g.updest.nlx, g.updest.nly,
+                        || !within_bounded_area(x, y,
+                                                g.updest.nlx, g.updest.nly,
                                                 g.updest.nhx, g.updest.nhy)));
         if (g.dndest.lx && (yy & 1) == 0) /* moving down */
             return (within_bounded_area(x, y, g.dndest.lx, g.dndest.ly,
                                         g.dndest.hx, g.dndest.hy)
                     && (!g.dndest.nlx
-                        || !within_bounded_area(x, y, g.dndest.nlx, g.dndest.nly,
+                        || !within_bounded_area(x, y,
+                                                g.dndest.nlx, g.dndest.nly,
                                                 g.dndest.nhx, g.dndest.nhy)));
     } else {
         /* [try to] prevent a shopkeeper or temple priest from being
@@ -1497,7 +1499,8 @@ register struct obj *obj;
              || (g.dndest.nlx && On_W_tower_level(&u.uz)
                  && within_bounded_area(tx, ty, g.dndest.nlx, g.dndest.nly,
                                         g.dndest.nhx, g.dndest.nhy)
-                    != within_bounded_area(otx, oty, g.dndest.nlx, g.dndest.nly,
+                    != within_bounded_area(otx, oty,
+                                           g.dndest.nlx, g.dndest.nly,
                                            g.dndest.nhx, g.dndest.nhy)));
 
     if (flooreffects(obj, tx, ty, "fall")) {
@@ -1566,8 +1569,8 @@ random_teleport_level()
         max_depth = bottom + (g.dungeons[u.uz.dnum].depth_start - 1);
     } else {
         min_depth = 1;
-        max_depth =
-            dunlevs_in_dungeon(&u.uz) + (g.dungeons[u.uz.dnum].depth_start - 1);
+        max_depth = dunlevs_in_dungeon(&u.uz)
+                    + (g.dungeons[u.uz.dnum].depth_start - 1);
         /* can't reach Sanctum if the invocation hasn't been performed */
         if (Inhell && !u.uevent.invoked)
             max_depth -= 1;