From: PatR Date: Mon, 4 May 2020 16:19:37 +0000 (-0700) Subject: makemon and goodpos flags X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88461e192355c65f259e506eb14e10b0a4a9bd63;p=nethack 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'. --- diff --git a/include/extern.h b/include/extern.h index 61e0d954a..376e50f20 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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)); diff --git a/include/hack.h b/include/hack.h index e9aaa931c..4ea786b33 100644 --- a/include/hack.h +++ b/include/hack.h @@ -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 diff --git a/src/makemon.c b/src/makemon.c index a6aee572d..eafcf2360 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -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); diff --git a/src/teleport.c b/src/teleport.c index 6ba3ab56e..a29808b00 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -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;