Deprecate "makedefs -m".

mons[].difficulty takes over for monstr[]
Invoking "makedefs -m" gives a deprecation message; it is also included
in the (now mostly empty) monstr.c.
Ports should now remove "makedefs -m" from their build procedures but this
commit does not include that change.
This commit is contained in:
keni
2018-10-17 15:37:24 -04:00
parent b9d99b343d
commit f222023bd8
9 changed files with 445 additions and 522 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 permonst.h $NHDT-Date: 1432512778 2015/05/25 00:12:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */ /* NetHack 3.6 permonst.h $NHDT-Date: 1539804913 2018/10/17 19:35:13 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.12 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */ /*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -58,6 +58,7 @@ struct permonst {
unsigned long mflags1, /* boolean bitflags */ unsigned long mflags1, /* boolean bitflags */
mflags2; /* more boolean bitflags */ mflags2; /* more boolean bitflags */
unsigned short mflags3; /* yet more boolean bitflags */ unsigned short mflags3; /* yet more boolean bitflags */
uchar difficulty; /* toughness (formerly from makedefs -m) */
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
uchar mcolor; /* color to use */ uchar mcolor; /* color to use */
#endif #endif

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 allmain.c $NHDT-Date: 1518193644 2018/02/09 16:27:24 $ $NHDT-Branch: githash $:$NHDT-Revision: 1.86 $ */ /* NetHack 3.6 allmain.c $NHDT-Date: 1539804859 2018/10/17 19:34:19 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.89 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -35,7 +35,6 @@ boolean resuming;
*/ */
decl_init(); decl_init();
monst_init(); monst_init();
monstr_init(); /* monster strengths */
objects_init(); objects_init();
/* if a save file created in normal mode is now being restored in /* if a save file created in normal mode is now being restored in

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 end.c $NHDT-Date: 1528332335 2018/06/07 00:45:35 $ $NHDT-Branch: NetHack-3.6.2 $:$NHDT-Revision: 1.141 $ */ /* NetHack 3.6 end.c $NHDT-Date: 1539804880 2018/10/17 19:34:40 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.146 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1574,8 +1574,6 @@ int status;
nethack_exit(status); nethack_exit(status);
} }
extern const int monstr[];
enum vanq_order_modes { enum vanq_order_modes {
VANQ_MLVL_MNDX = 0, VANQ_MLVL_MNDX = 0,
VANQ_MSTR_MNDX, VANQ_MSTR_MNDX,
@@ -1620,7 +1618,7 @@ const genericptr vptr2;
break; break;
case VANQ_MSTR_MNDX: case VANQ_MSTR_MNDX:
/* sort by monster toughness */ /* sort by monster toughness */
mstr1 = monstr[indx1], mstr2 = monstr[indx2]; mstr1 = mons[indx1].difficulty, mstr2 = mons[indx2].difficulty;
res = mstr2 - mstr1; /* monstr high to low */ res = mstr2 - mstr1; /* monstr high to low */
break; break;
case VANQ_ALPHA_SEP: case VANQ_ALPHA_SEP:

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 makemon.c $NHDT-Date: 1537477761 2018/09/20 21:09:21 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.124 $ */ /* NetHack 3.6 makemon.c $NHDT-Date: 1539804904 2018/10/17 19:35:04 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.127 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -25,12 +25,10 @@ STATIC_DCL void FDECL(m_initinv, (struct monst *));
STATIC_DCL boolean FDECL(makemon_rnd_goodpos, (struct monst *, STATIC_DCL boolean FDECL(makemon_rnd_goodpos, (struct monst *,
unsigned, coord *)); unsigned, coord *));
extern const int monstr[];
#define m_initsgrp(mtmp, x, y) m_initgrp(mtmp, x, y, 3) #define m_initsgrp(mtmp, x, y) m_initgrp(mtmp, x, y, 3)
#define m_initlgrp(mtmp, x, y) m_initgrp(mtmp, x, y, 10) #define m_initlgrp(mtmp, x, y) m_initgrp(mtmp, x, y, 10)
#define toostrong(monindx, lev) (monstr[monindx] > lev) #define toostrong(monindx, lev) (mons[monindx].difficulty > lev)
#define tooweak(monindx, lev) (monstr[monindx] < lev) #define tooweak(monindx, lev) (mons[monindx].difficulty < lev)
boolean boolean
is_home_elemental(ptr) is_home_elemental(ptr)
@@ -1652,7 +1650,7 @@ int spc;
if (mk_gen_ok(last, G_GONE, mask)) { if (mk_gen_ok(last, G_GONE, mask)) {
/* consider it */ /* consider it */
if (num && toostrong(last, maxmlev) if (num && toostrong(last, maxmlev)
&& monstr[last] != monstr[last - 1] && rn2(2)) && mons[last].difficulty != mons[last - 1].difficulty && rn2(2))
break; break;
num += mons[last].geno & G_FREQ; num += mons[last].geno & G_FREQ;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 muse.c $NHDT-Date: 1505181522 2017/09/12 01:58:42 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.80 $ */ /* NetHack 3.6 muse.c $NHDT-Date: 1539804880 2018/10/17 19:34:40 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.85 $ */
/* Copyright (C) 1990 by Ken Arromdee */ /* Copyright (C) 1990 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -8,8 +8,6 @@
#include "hack.h" #include "hack.h"
extern const int monstr[];
boolean m_using = FALSE; boolean m_using = FALSE;
/* Let monsters use magic items. Arbitrary assumptions: Monsters only use /* Let monsters use magic items. Arbitrary assumptions: Monsters only use
@@ -991,7 +989,7 @@ rnd_defensive_item(mtmp)
struct monst *mtmp; struct monst *mtmp;
{ {
struct permonst *pm = mtmp->data; struct permonst *pm = mtmp->data;
int difficulty = monstr[(monsndx(pm))]; int difficulty = mons[(monsndx(pm))].difficulty;
int trycnt = 0; int trycnt = 0;
if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data) if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data)
@@ -1556,7 +1554,7 @@ rnd_offensive_item(mtmp)
struct monst *mtmp; struct monst *mtmp;
{ {
struct permonst *pm = mtmp->data; struct permonst *pm = mtmp->data;
int difficulty = monstr[(monsndx(pm))]; int difficulty = mons[(monsndx(pm))].difficulty;
if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data) if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data)
|| pm->mlet == S_GHOST || pm->mlet == S_KOP) || pm->mlet == S_GHOST || pm->mlet == S_KOP)
@@ -1636,7 +1634,7 @@ struct monst *mtmp;
return FALSE; return FALSE;
if (!stuck && !immobile && (mtmp->cham == NON_PM) if (!stuck && !immobile && (mtmp->cham == NON_PM)
&& monstr[(pmidx = monsndx(mdat))] < 6) { && mons[(pmidx = monsndx(mdat))].difficulty < 6) {
boolean ignore_boulders = (verysmall(mdat) || throws_rocks(mdat) boolean ignore_boulders = (verysmall(mdat) || throws_rocks(mdat)
|| passes_walls(mdat)), || passes_walls(mdat)),
diag_ok = !NODIAG(pmidx); diag_ok = !NODIAG(pmidx);
@@ -1722,13 +1720,13 @@ struct monst *mtmp;
} }
nomore(MUSE_WAN_POLYMORPH); nomore(MUSE_WAN_POLYMORPH);
if (obj->otyp == WAN_POLYMORPH && obj->spe > 0 if (obj->otyp == WAN_POLYMORPH && obj->spe > 0
&& (mtmp->cham == NON_PM) && monstr[monsndx(mdat)] < 6) { && (mtmp->cham == NON_PM) && mons[monsndx(mdat)].difficulty < 6) {
m.misc = obj; m.misc = obj;
m.has_misc = MUSE_WAN_POLYMORPH; m.has_misc = MUSE_WAN_POLYMORPH;
} }
nomore(MUSE_POT_POLYMORPH); nomore(MUSE_POT_POLYMORPH);
if (obj->otyp == POT_POLYMORPH && (mtmp->cham == NON_PM) if (obj->otyp == POT_POLYMORPH && (mtmp->cham == NON_PM)
&& monstr[monsndx(mdat)] < 6) { && mons[monsndx(mdat)].difficulty < 6) {
m.misc = obj; m.misc = obj;
m.has_misc = MUSE_POT_POLYMORPH; m.has_misc = MUSE_POT_POLYMORPH;
} }
@@ -1997,7 +1995,7 @@ rnd_misc_item(mtmp)
struct monst *mtmp; struct monst *mtmp;
{ {
struct permonst *pm = mtmp->data; struct permonst *pm = mtmp->data;
int difficulty = monstr[(monsndx(pm))]; int difficulty = mons[(monsndx(pm))].difficulty;
if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data) if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data)
|| pm->mlet == S_GHOST || pm->mlet == S_KOP) || pm->mlet == S_GHOST || pm->mlet == S_KOP)
@@ -2052,7 +2050,7 @@ struct obj *obj;
if (typ == WAN_DIGGING) if (typ == WAN_DIGGING)
return (boolean) !is_floater(mon->data); return (boolean) !is_floater(mon->data);
if (typ == WAN_POLYMORPH) if (typ == WAN_POLYMORPH)
return (boolean) (monstr[monsndx(mon->data)] < 6); return (boolean) (mons[monsndx(mon->data)].difficulty < 6);
if (objects[typ].oc_dir == RAY || typ == WAN_STRIKING if (objects[typ].oc_dir == RAY || typ == WAN_STRIKING
|| typ == WAN_TELEPORTATION || typ == WAN_CREATE_MONSTER) || typ == WAN_TELEPORTATION || typ == WAN_CREATE_MONSTER)
return TRUE; return TRUE;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pray.c $NHDT-Date: 1519662898 2018/02/26 16:34:58 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.96 $ */ /* NetHack 3.6 pray.c $NHDT-Date: 1539804904 2018/10/17 19:35:04 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.103 $ */
/* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */ /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1325,7 +1325,6 @@ dosacrifice()
if (otmp->otyp == CORPSE) { if (otmp->otyp == CORPSE) {
register struct permonst *ptr = &mons[otmp->corpsenm]; register struct permonst *ptr = &mons[otmp->corpsenm];
struct monst *mtmp; struct monst *mtmp;
extern const int monstr[];
/* KMH, conduct */ /* KMH, conduct */
u.uconduct.gnostic++; u.uconduct.gnostic++;
@@ -1338,7 +1337,7 @@ dosacrifice()
if (otmp->corpsenm == PM_ACID_BLOB if (otmp->corpsenm == PM_ACID_BLOB
|| (monstermoves <= peek_at_iced_corpse_age(otmp) + 50)) { || (monstermoves <= peek_at_iced_corpse_age(otmp) + 50)) {
value = monstr[otmp->corpsenm] + 1; value = mons[otmp->corpsenm].difficulty + 1;
if (otmp->oeaten) if (otmp->oeaten)
value = eaten_stat(value, otmp); value = eaten_stat(value, otmp);
} }

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 wizard.c $NHDT-Date: 1456618999 2016/02/28 00:23:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.48 $ */ /* NetHack 3.6 wizard.c $NHDT-Date: 1539804905 2018/10/17 19:35:05 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.53 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2016. */ /*-Copyright (c) Robert Patrick Rankin, 2016. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -11,8 +11,6 @@
#include "hack.h" #include "hack.h"
#include "qtext.h" #include "qtext.h"
extern const int monstr[];
STATIC_DCL short FDECL(which_arti, (int)); STATIC_DCL short FDECL(which_arti, (int));
STATIC_DCL boolean FDECL(mon_has_arti, (struct monst *, SHORT_P)); STATIC_DCL boolean FDECL(mon_has_arti, (struct monst *, SHORT_P));
STATIC_DCL struct monst *FDECL(other_mon_has_arti, (struct monst *, SHORT_P)); STATIC_DCL struct monst *FDECL(other_mon_has_arti, (struct monst *, SHORT_P));
@@ -588,7 +586,8 @@ struct monst *summoner;
m_cls = mons[makeindex].mlet; m_cls = mons[makeindex].mlet;
} while (summoner } while (summoner
&& ((attacktype(&mons[makeindex], AT_MAGC) && ((attacktype(&mons[makeindex], AT_MAGC)
&& monstr[makeindex] >= monstr[summoner->mnum]) && mons[makeindex].difficulty
>= mons[summoner->mnum].difficulty)
|| (s_cls == S_DEMON && m_cls == S_ANGEL) || (s_cls == S_DEMON && m_cls == S_ANGEL)
|| (s_cls == S_ANGEL && m_cls == S_DEMON))); || (s_cls == S_ANGEL && m_cls == S_DEMON)));
/* do this after picking the monster to place */ /* do this after picking the monster to place */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 makedefs.c $NHDT-Date: 1520022901 2018/03/02 20:35:01 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.121 $ */ /* NetHack 3.6 makedefs.c $NHDT-Date: 1539804926 2018/10/17 19:35:26 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.126 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */ /*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */
/* Copyright (c) M. Stephenson, 1990, 1991. */ /* Copyright (c) M. Stephenson, 1990, 1991. */
@@ -183,8 +183,6 @@ static boolean FDECL(get_gitinfo, (char *, char *));
static void FDECL(do_rnd_access_file, (const char *)); static void FDECL(do_rnd_access_file, (const char *));
static boolean FDECL(d_filter, (char *)); static boolean FDECL(d_filter, (char *));
static boolean FDECL(h_filter, (char *)); static boolean FDECL(h_filter, (char *));
static boolean FDECL(ranged_attk, (struct permonst *));
static int FDECL(mstrength, (struct permonst *));
static void NDECL(build_savebones_compat_string); static void NDECL(build_savebones_compat_string);
static void NDECL(windowing_sanity); static void NDECL(windowing_sanity);
@@ -2183,89 +2181,18 @@ do_dungeon()
return; return;
} }
static boolean
ranged_attk(ptr) /* returns TRUE if monster can attack at range */
register struct permonst *ptr;
{
register int i, j;
register int atk_mask = (1 << AT_BREA) | (1 << AT_SPIT) | (1 << AT_GAZE);
for (i = 0; i < NATTK; i++) {
if ((j = ptr->mattk[i].aatyp) >= AT_WEAP || (atk_mask & (1 << j)))
return TRUE;
}
return FALSE;
}
/* This routine is designed to return an integer value which represents
* an approximation of monster strength. It uses a similar method of
* determination as "experience()" to arrive at the strength.
*/
static int
mstrength(ptr)
struct permonst *ptr;
{
int i, tmp2, n, tmp = ptr->mlevel;
if (tmp > 49) /* special fixed hp monster */
tmp = 2 * (tmp - 6) / 4;
/* For creation in groups */
n = (!!(ptr->geno & G_SGROUP));
n += (!!(ptr->geno & G_LGROUP)) << 1;
/* For ranged attacks */
if (ranged_attk(ptr))
n++;
/* For higher ac values */
n += (ptr->ac < 4);
n += (ptr->ac < 0);
/* For very fast monsters */
n += (ptr->mmove >= 18);
/* For each attack and "special" attack */
for (i = 0; i < NATTK; i++) {
tmp2 = ptr->mattk[i].aatyp;
n += (tmp2 > 0);
n += (tmp2 == AT_MAGC);
n += (tmp2 == AT_WEAP && (ptr->mflags2 & M2_STRONG));
}
/* For each "special" damage type */
for (i = 0; i < NATTK; i++) {
tmp2 = ptr->mattk[i].adtyp;
if ((tmp2 == AD_DRLI) || (tmp2 == AD_STON) || (tmp2 == AD_DRST)
|| (tmp2 == AD_DRDX) || (tmp2 == AD_DRCO) || (tmp2 == AD_WERE))
n += 2;
else if (strcmp(ptr->mname, "grid bug"))
n += (tmp2 != AD_PHYS);
n += ((int) (ptr->mattk[i].damd * ptr->mattk[i].damn) > 23);
}
/* Leprechauns are special cases. They have many hit dice so they can
hit and are hard to kill, but they don't really do much damage. */
if (!strcmp(ptr->mname, "leprechaun"))
n -= 2;
/* Finally, adjust the monster level 0 <= n <= 24 (approx.) */
if (n == 0)
tmp--;
else if (n >= 6)
tmp += (n / 2);
else
tmp += (n / 3 + 1);
return (tmp >= 0) ? tmp : 0;
}
void void
do_monstr() do_monstr()
{ {
register struct permonst *ptr; /* Don't break anything for ports that haven't been updated. */
register int i, j; printf("DEPRECATION WARNINGS:\n");
printf("'makedefs -m' is deprecated. Remove all references\n");
printf(" to it from the build process.\n");
printf("'monstr.c' is deprecated. Remove all references to\n");
printf(" it from the build process.\n");
printf("monstr[] is deprecated. Replace monstr[x] with\n");
printf(" mons[x].difficulty\n");
printf("monstr_init() is deprecated. Remove all references to it.\n");
/* /*
* create the source file, "monstr.c" * create the source file, "monstr.c"
@@ -2281,15 +2208,18 @@ do_monstr()
} }
Fprintf(ofp, "%s", Dont_Edit_Code); Fprintf(ofp, "%s", Dont_Edit_Code);
Fprintf(ofp, "#include \"config.h\"\n"); Fprintf(ofp, "#include \"config.h\"\n");
Fprintf(ofp, "\nconst int monstr[] = {\n"); Fprintf(ofp, "\nconst int monstrXXX[] = {\n");
for (ptr = &mons[0], j = 0; ptr->mlet; ptr++) { Fprintf(ofp, "0};\n");
SpinCursor(3); Fprintf(ofp, "/*\n");
Fprintf(ofp, "DEPRECATION WARNINGS:\n");
i = mstrength(ptr); Fprintf(ofp, "'makedefs -m' is deprecated. Remove all references\n");
Fprintf(ofp, "%2d,%c", i, (++j & 15) ? ' ' : '\n'); Fprintf(ofp, " to it from the build process.\n");
} Fprintf(ofp, "'monstr.c' is deprecated. Remove all references to\n");
/* might want to insert a final 0 entry here instead of just newline */ Fprintf(ofp, " it from the build process.\n");
Fprintf(ofp, "%s};\n", (j & 15) ? "\n" : ""); Fprintf(ofp, "monstr[] is deprecated. Replace monstr[x] with\n");
Fprintf(ofp, " mons[x].difficulty\n");
Fprintf(ofp, "monstr_init() is deprecated. Remove all references to it.\n");
Fprintf(ofp, "*/\n");
Fprintf(ofp, "\nvoid NDECL(monstr_init);\n"); Fprintf(ofp, "\nvoid NDECL(monstr_init);\n");
Fprintf(ofp, "\nvoid\n"); Fprintf(ofp, "\nvoid\n");