diff --git a/include/extern.h b/include/extern.h index d2c251c11..a21b76988 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1578764033 2020/01/11 17:33:53 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.783 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1578895332 2020/01/13 06:02:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.785 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1342,8 +1342,9 @@ E void FDECL(new_omailcmd, (struct obj *, const char *)); E void FDECL(free_omailcmd, (struct obj *)); E struct obj *FDECL(mkobj_at, (CHAR_P, int, int, BOOLEAN_P)); E struct obj *FDECL(mksobj_at, (int, int, int, BOOLEAN_P, BOOLEAN_P)); -E struct obj *FDECL(mksobj_migr_to_species, (int, unsigned, BOOLEAN_P, BOOLEAN_P)); -E struct obj *FDECL(mkobj, (CHAR_P, BOOLEAN_P)); +E struct obj *FDECL(mksobj_migr_to_species, (int, unsigned, + BOOLEAN_P, BOOLEAN_P)); +E struct obj *FDECL(mkobj, (int, BOOLEAN_P)); E int NDECL(rndmonnum); E boolean FDECL(bogon_is_pname, (CHAR_P)); E struct obj *FDECL(splitobj, (struct obj *, long)); diff --git a/include/objclass.h b/include/objclass.h index a74526c78..031d8595e 100644 --- a/include/objclass.h +++ b/include/objclass.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 objclass.h $NHDT-Date: 1547255901 2019/01/12 01:18:21 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.20 $ */ +/* NetHack 3.6 objclass.h $NHDT-Date: 1578895344 2020/01/13 06:02:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.21 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -163,6 +163,8 @@ enum obj_class_types { MAXOCLASSES = 18 }; +/* for mkobj() use ONLY! odd '-SPBOOK_CLASS' is in case of unsigned enums */ +#define SPBOOK_no_NOVEL (0 - (int) SPBOOK_CLASS) #define ALLOW_COUNT (MAXOCLASSES + 1) /* Can be used in the object class */ #define ALL_CLASSES (MAXOCLASSES + 2) /* input to getobj(). */ diff --git a/src/mkobj.c b/src/mkobj.c index 15fd1f90c..91e12b882 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkobj.c $NHDT-Date: 1578855620 2020/01/12 19:00:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.173 $ */ +/* NetHack 3.6 mkobj.c $NHDT-Date: 1578895344 2020/01/13 06:02:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.174 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -245,7 +245,7 @@ boolean init, artif; result is always non-Null */ struct obj * mkobj(oclass, artif) -char oclass; +int oclass; boolean artif; { int tprob, i, prob = rnd(1000); @@ -257,13 +257,18 @@ boolean artif; : (const struct icp *) mkobjprobs; for (tprob = rnd(100); (tprob -= iprobs->iprob) > 0; iprobs++) - ; + continue; oclass = iprobs->iclass; } - i = g.bases[(int) oclass]; - while ((prob -= objects[i].oc_prob) > 0) - i++; + if (oclass == SPBOOK_no_NOVEL) { + i = rnd_class(g.bases[SPBOOK_CLASS], SPE_BLANK_PAPER); + oclass = SPBOOK_CLASS; /* for sanity check below */ + } else { + i = g.bases[oclass]; + while ((prob -= objects[i].oc_prob) > 0) + ++i; + } if (objects[i].oc_class != oclass || !OBJ_NAME(objects[i])) panic("probtype error, oclass=%d i=%d", (int) oclass, i); @@ -1054,10 +1059,10 @@ boolean artif; case STATUE: /* possibly overridden by mkcorpstat() */ otmp->corpsenm = rndmonnum(); - /* note: might produce a novel rather than a spellbook */ if (!verysmall(&mons[otmp->corpsenm]) && rn2(level_difficulty() / 2 + 10) > 10) - (void) add_to_container(otmp, mkobj(SPBOOK_CLASS, FALSE)); + (void) add_to_container(otmp, + mkobj(SPBOOK_no_NOVEL, FALSE)); } break; case COIN_CLASS: diff --git a/src/pray.c b/src/pray.c index b028ea109..173996c09 100644 --- a/src/pray.c +++ b/src/pray.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pray.c $NHDT-Date: 1578855625 2020/01/12 19:00:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.137 $ */ +/* NetHack 3.6 pray.c $NHDT-Date: 1578895347 2020/01/13 06:02:27 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.138 $ */ /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1182,12 +1182,8 @@ aligntyp g_align; int sp_no, trycnt = u.ulevel + 1; /* not yet known spells given preference over already known ones; - also, try to grant a spell for which there is a skill slot; - make sure that it's a spellbook and not a novel */ - /* otmp = mkobj(SPBOOK_CLASS, TRUE); --might yield NOVEL */ - otmp = mksobj(rnd_class(g.bases[SPBOOK_CLASS], - SPE_BLANK_PAPER), - TRUE, FALSE); + also, try to grant a spell for which there is a skill slot */ + otmp = mkobj(SPBOOK_no_NOVEL, TRUE); while (--trycnt > 0) { if (otmp->otyp != SPE_BLANK_PAPER) { for (sp_no = 0; sp_no < MAXSPELL; sp_no++) diff --git a/src/priest.c b/src/priest.c index 6521df407..ad17c0b8b 100644 --- a/src/priest.c +++ b/src/priest.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 priest.c $NHDT-Date: 1578855626 2020/01/12 19:00:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.56 $ */ +/* NetHack 3.6 priest.c $NHDT-Date: 1578895348 2020/01/13 06:02:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.57 $ */ /* Copyright (c) Izchak Miller, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -258,10 +258,7 @@ boolean sanctum; /* is it the seat of the high priest? */ } /* 2 to 4 spellbooks */ for (cnt = rn1(3, 2); cnt > 0; --cnt) { - /* avoid novel (used to be mkobj(SPBOOK_CLASS, FALSE) here) */ - (void) mpickobj(priest, mksobj(rnd_class(g.bases[SPBOOK_CLASS], - SPE_BLANK_PAPER), - TRUE, FALSE)); + (void) mpickobj(priest, mkobj(SPBOOK_no_NOVEL, FALSE)); } /* robe [via makemon()] */ if (rn2(2) && (otmp = which_armor(priest, W_ARMC)) != 0) {