makemon and goodpos flags

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