make zeroany, zeromonst, zeroobj 'const'

They're never modified.  Minor complication:  &zeroobj is used as
a special not-Null-but-not-an-object value in multiple places and
needs to have 'const' removed with a cast in that situation.
This commit is contained in:
PatR
2019-01-09 01:13:01 -08:00
parent d4e3f9d9d3
commit dd13b10cf2
6 changed files with 63 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 decl.h $NHDT-Date: 1496531104 2017/06/03 23:05:04 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.82 $ */ /* NetHack 3.6 decl.h $NHDT-Date: 1547025154 2019/01/09 09:12:34 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.147 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2007. */ /*-Copyright (c) Michael Allison, 2007. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -247,9 +247,10 @@ E NEARDATA struct obj *migrating_objs;
E NEARDATA struct obj *billobjs; E NEARDATA struct obj *billobjs;
E NEARDATA struct obj *current_wand, *thrownobj, *kickedobj; E NEARDATA struct obj *current_wand, *thrownobj, *kickedobj;
E NEARDATA struct obj zeroobj; /* for init; &zeroobj used as special value */ E NEARDATA const struct obj zeroobj; /* for init; also, &zeroobj is used
* as special value */
E NEARDATA anything zeroany; /* init'd and defined in decl.c */ E NEARDATA const anything zeroany; /* init'd and defined in decl.c */
#include "you.h" #include "you.h"
E NEARDATA struct you u; E NEARDATA struct you u;
@@ -261,7 +262,7 @@ E NEARDATA struct u_realtime urealtime;
#include "pm.h" #include "pm.h"
#endif #endif
E NEARDATA struct monst zeromonst; /* for init of new or temp monsters */ E NEARDATA const struct monst zeromonst; /* for init of new or temp monsters */
E NEARDATA struct monst youmonst; /* monster details when hero is poly'd */ E NEARDATA struct monst youmonst; /* monster details when hero is poly'd */
E NEARDATA struct monst *mydogs, *migrating_mons; E NEARDATA struct monst *mydogs, *migrating_mons;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 decl.c $NHDT-Date: 1446975463 2015/11/08 09:37:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */ /* NetHack 3.6 decl.c $NHDT-Date: 1547025164 2019/01/09 09:12:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.141 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2009. */ /*-Copyright (c) Michael Allison, 2009. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -198,10 +198,10 @@ NEARDATA struct obj *migrating_objs = (struct obj *) 0;
NEARDATA struct obj *billobjs = (struct obj *) 0; NEARDATA struct obj *billobjs = (struct obj *) 0;
/* used to zero all elements of a struct obj and a struct monst */ /* used to zero all elements of a struct obj and a struct monst */
NEARDATA struct obj zeroobj = DUMMY; NEARDATA const struct obj zeroobj = DUMMY;
NEARDATA struct monst zeromonst = DUMMY; NEARDATA const struct monst zeromonst = DUMMY;
/* used to zero out union any; initializer deliberately omitted */ /* used to zero out union any; initializer deliberately omitted */
NEARDATA anything zeroany; NEARDATA const anything zeroany;
/* originally from dog.c */ /* originally from dog.c */
NEARDATA char dogname[PL_PSIZ] = DUMMY; NEARDATA char dogname[PL_PSIZ] = DUMMY;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 invent.c $NHDT-Date: 1546770988 2019/01/06 10:36:28 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.249 $ */ /* NetHack 3.6 invent.c $NHDT-Date: 1547025166 2019/01/09 09:12:46 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.250 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */ /*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -426,7 +426,7 @@ const genericptr vptr2;
return val2 - val1; /* bigger is better */ return val2 - val1; /* bigger is better */
} }
tiebreak: tiebreak:
/* They're identical, as far as we're concerned. We want /* They're identical, as far as we're concerned. We want
to force a deterministic order, and do so by producing a to force a deterministic order, and do so by producing a
stable sort: maintain the original order of equal items. */ stable sort: maintain the original order of equal items. */
@@ -938,7 +938,7 @@ struct obj *obj;
&& obj->oartifact != ART_MJOLLNIR && obj->oartifact != ART_MJOLLNIR
&& (throwing_weapon(obj) || is_ammo(obj))) && (throwing_weapon(obj) || is_ammo(obj)))
setuqwep(obj); setuqwep(obj);
added: added:
addinv_core2(obj); addinv_core2(obj);
carry_obj_effects(obj); /* carrying affects the obj */ carry_obj_effects(obj); /* carrying affects the obj */
update_inventory(); update_inventory();
@@ -1702,9 +1702,9 @@ register const char *let, *word;
You("mime %s something%s%s.", ing_suffix(bp), suf ? " " : "", You("mime %s something%s%s.", ing_suffix(bp), suf ? " " : "",
suf ? suf : ""); suf ? suf : "");
} }
return (allownone ? &zeroobj : (struct obj *) 0); return (allownone ? (struct obj *) &zeroobj : (struct obj *) 0);
} }
redo_menu: redo_menu:
/* since gold is now kept in inventory, we need to do processing for /* since gold is now kept in inventory, we need to do processing for
select-from-invent before checking whether gold has been picked */ select-from-invent before checking whether gold has been picked */
if (ilet == '?' || ilet == '*') { if (ilet == '?' || ilet == '*') {
@@ -1735,7 +1735,7 @@ redo_menu:
if (!ilet) if (!ilet)
continue; continue;
if (ilet == HANDS_SYM) if (ilet == HANDS_SYM)
return &zeroobj; return (struct obj *) &zeroobj; /* cast away 'const' */
if (ilet == '\033') { if (ilet == '\033') {
if (flags.verbose) if (flags.verbose)
pline1(Never_mind); pline1(Never_mind);
@@ -2139,7 +2139,7 @@ int FDECL((*fn), (OBJ_P)), FDECL((*ckfn), (OBJ_P));
* For example, if a person specifies =/ then first all rings * For example, if a person specifies =/ then first all rings
* will be asked about followed by all wands. -dgk * will be asked about followed by all wands. -dgk
*/ */
nextclass: nextclass:
ilet = 'a' - 1; ilet = 'a' - 1;
if (*objchn && (*objchn)->oclass == COIN_CLASS) if (*objchn && (*objchn)->oclass == COIN_CLASS)
ilet--; /* extra iteration */ ilet--; /* extra iteration */
@@ -2249,7 +2249,7 @@ nextclass:
pline("That was all."); pline("That was all.");
else if (!dud && !cnt) else if (!dud && !cnt)
pline("No applicable objects."); pline("No applicable objects.");
ret: ret:
unsortloot(&sortedchn); unsortloot(&sortedchn);
bypass_objlist(*objchn, FALSE); bypass_objlist(*objchn, FALSE);
return cnt; return cnt;
@@ -2670,7 +2670,7 @@ long *out_cnt;
add_menu(win, NO_GLYPH, &any, HANDS_SYM, 0, ATR_NONE, add_menu(win, NO_GLYPH, &any, HANDS_SYM, 0, ATR_NONE,
xtra_choice, MENU_UNSELECTED); xtra_choice, MENU_UNSELECTED);
} }
nextclass: nextclass:
classcount = 0; classcount = 0;
for (srtinv = sortedinvent; (otmp = srtinv->obj) != 0; ++srtinv) { for (srtinv = sortedinvent; (otmp = srtinv->obj) != 0; ++srtinv) {
if (lets && !index(lets, otmp->invlet)) if (lets && !index(lets, otmp->invlet))
@@ -4101,7 +4101,7 @@ doorganize() /* inventory organizer by Del Lamb */
compatible stacks get collected along the way, compatible stacks get collected along the way,
but splitting to same slot is not */ but splitting to same slot is not */
|| (splitting && let == obj->invlet)) { || (splitting && let == obj->invlet)) {
noadjust: noadjust:
if (splitting) if (splitting)
(void) merged(&splitting, &obj); (void) merged(&splitting, &obj);
if (!ever_mind) if (!ever_mind)

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 muse.c $NHDT-Date: 1539804880 2018/10/17 19:34:40 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.85 $ */ /* NetHack 3.6 muse.c $NHDT-Date: 1547025167 2019/01/09 09:12:47 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.92 $ */
/* 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. */
@@ -477,7 +477,7 @@ struct monst *mtmp;
} }
} }
} }
toot: toot:
; ;
} }
@@ -585,7 +585,7 @@ struct monst *mtmp;
m.has_defense = MUSE_SCR_CREATE_MONSTER; m.has_defense = MUSE_SCR_CREATE_MONSTER;
} }
} }
botm: botm:
return (boolean) !!m.has_defense; return (boolean) !!m.has_defense;
#undef nomore #undef nomore
} }
@@ -648,7 +648,7 @@ struct monst *mtmp;
mzapmsg(mtmp, otmp, TRUE); mzapmsg(mtmp, otmp, TRUE);
otmp->spe--; otmp->spe--;
how = WAN_TELEPORTATION; how = WAN_TELEPORTATION;
mon_tele: mon_tele:
if (tele_restrict(mtmp)) { /* mysterious force... */ if (tele_restrict(mtmp)) { /* mysterious force... */
if (vismon && how) /* mentions 'teleport' */ if (vismon && how) /* mentions 'teleport' */
makeknown(how); makeknown(how);
@@ -886,7 +886,7 @@ struct monst *mtmp;
case MUSE_SSTAIRS: case MUSE_SSTAIRS:
m_flee(mtmp); m_flee(mtmp);
if (ledger_no(&u.uz) == 1) { if (ledger_no(&u.uz) == 1) {
escape: escape:
/* Monsters without the Amulet escape the dungeon and /* Monsters without the Amulet escape the dungeon and
* are gone for good when they leave up the up stairs. * are gone for good when they leave up the up stairs.
* A monster with the Amulet would leave it behind * A monster with the Amulet would leave it behind
@@ -995,7 +995,7 @@ struct monst *mtmp;
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)
return 0; return 0;
try_again: try_again:
switch (rn2(8 + (difficulty > 3) + (difficulty > 6) + (difficulty > 8))) { switch (rn2(8 + (difficulty > 3) + (difficulty > 6) + (difficulty > 8))) {
case 6: case 6:
case 9: case 9:
@@ -1791,7 +1791,7 @@ struct monst *mtmp;
(coord *) 0); (coord *) 0);
return 2; return 2;
} else { } else {
skipmsg: skipmsg:
if (vismon) { if (vismon) {
pline("%s looks uneasy.", Monnam(mtmp)); pline("%s looks uneasy.", Monnam(mtmp));
if (!objects[POT_GAIN_LEVEL].oc_name_known if (!objects[POT_GAIN_LEVEL].oc_name_known
@@ -2412,7 +2412,7 @@ boolean by_you;
} }
} }
if (t && t->ttyp == FIRE_TRAP) if (t && t->ttyp == FIRE_TRAP)
return muse_unslime(mon, &zeroobj, t, by_you); return muse_unslime(mon, (struct obj *) &zeroobj, t, by_you);
} /* MUSE */ } /* MUSE */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 objnam.c $NHDT-Date: 1546687293 2019/01/05 11:21:33 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.232 $ */ /* NetHack 3.6 objnam.c $NHDT-Date: 1547025168 2019/01/09 09:12:48 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.233 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -705,7 +705,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
if (has_oname(obj) && dknown) { if (has_oname(obj) && dknown) {
Strcat(buf, " named "); Strcat(buf, " named ");
nameit: nameit:
Strcat(buf, ONAME(obj)); Strcat(buf, ONAME(obj));
} }
@@ -1083,7 +1083,7 @@ unsigned doname_flags;
goto charges; goto charges;
break; break;
case WAND_CLASS: case WAND_CLASS:
charges: charges:
if (known) if (known)
Sprintf(eos(bp), " (%d:%d)", (int) obj->recharged, obj->spe); Sprintf(eos(bp), " (%d:%d)", (int) obj->recharged, obj->spe);
break; break;
@@ -1092,7 +1092,7 @@ unsigned doname_flags;
Strcat(bp, " (lit)"); Strcat(bp, " (lit)");
break; break;
case RING_CLASS: case RING_CLASS:
ring: ring:
if (obj->owornmask & W_RINGR) if (obj->owornmask & W_RINGR)
Strcat(bp, " (on right "); Strcat(bp, " (on right ");
if (obj->owornmask & W_RINGL) if (obj->owornmask & W_RINGL)
@@ -2035,7 +2035,7 @@ register const char *verb;
return strcpy(buf, verb); return strcpy(buf, verb);
} }
sing: sing:
Strcpy(buf, verb); Strcpy(buf, verb);
len = (int) strlen(buf); len = (int) strlen(buf);
bspot = buf + len - 1; bspot = buf + len - 1;
@@ -2379,7 +2379,7 @@ const char *oldstr;
/* Default: append an 's' */ /* Default: append an 's' */
Strcasecpy(spot + 1, "s"); Strcasecpy(spot + 1, "s");
bottom: bottom:
if (excess) if (excess)
Strcat(str, excess); Strcat(str, excess);
return str; return str;
@@ -2479,7 +2479,7 @@ const char *oldstr;
|| (p - 4 == bp && !strcmpi(p - 4, "lens"))) { || (p - 4 == bp && !strcmpi(p - 4, "lens"))) {
goto bottom; goto bottom;
} }
mins: mins:
*(p - 1) = '\0'; /* drop s */ *(p - 1) = '\0'; /* drop s */
} else { /* input doesn't end in 's' */ } else { /* input doesn't end in 's' */
@@ -2503,7 +2503,7 @@ const char *oldstr;
/* here we cannot find the plural suffix */ /* here we cannot find the plural suffix */
} }
bottom: bottom:
/* if we stripped off a suffix (" of bar" from "foo of bar"), /* if we stripped off a suffix (" of bar" from "foo of bar"),
put it back now [strcat() isn't actually 100% safe here...] */ put it back now [strcat() isn't actually 100% safe here...] */
if (excess) if (excess)
@@ -3376,7 +3376,7 @@ struct obj *no_wish;
} }
} }
retry: retry:
/* "grey stone" check must be before general "stone" */ /* "grey stone" check must be before general "stone" */
for (i = 0; i < SIZE(o_ranges); i++) for (i = 0; i < SIZE(o_ranges); i++)
if (!strcmpi(bp, o_ranges[i].name)) { if (!strcmpi(bp, o_ranges[i].name)) {
@@ -3425,7 +3425,7 @@ retry:
actualn = bp; actualn = bp;
if (!dn) if (!dn)
dn = actualn; /* ex. "skull cap" */ dn = actualn; /* ex. "skull cap" */
srch: srch:
/* check real names of gems first */ /* check real names of gems first */
if (!oclass && actualn) { if (!oclass && actualn) {
for (i = bases[GEM_CLASS]; i <= LAST_GEM; i++) { for (i = bases[GEM_CLASS]; i <= LAST_GEM; i++) {
@@ -3561,7 +3561,7 @@ srch:
* trap objects like beartraps. * trap objects like beartraps.
* Disallow such topology tweaks for WIZKIT startup wishes. * Disallow such topology tweaks for WIZKIT startup wishes.
*/ */
wiztrap: wiztrap:
if (wizard && !program_state.wizkit_wishing) { if (wizard && !program_state.wizkit_wishing) {
struct rm *lev; struct rm *lev;
int trap, x = u.ux, y = u.uy; int trap, x = u.ux, y = u.uy;
@@ -3583,7 +3583,7 @@ wiztrap:
(trap != MAGIC_PORTAL) ? "" : " to nowhere"); (trap != MAGIC_PORTAL) ? "" : " to nowhere");
} else } else
pline("Creation of %s failed.", an(tname)); pline("Creation of %s failed.", an(tname));
return &zeroobj; return (struct obj *) &zeroobj;
} }
/* furniture and terrain */ /* furniture and terrain */
@@ -3596,20 +3596,20 @@ wiztrap:
lev->blessedftn = 1; lev->blessedftn = 1;
pline("A %sfountain.", lev->blessedftn ? "magic " : ""); pline("A %sfountain.", lev->blessedftn ? "magic " : "");
newsym(x, y); newsym(x, y);
return &zeroobj; return (struct obj *) &zeroobj;
} }
if (!BSTRCMPI(bp, p - 6, "throne")) { if (!BSTRCMPI(bp, p - 6, "throne")) {
lev->typ = THRONE; lev->typ = THRONE;
pline("A throne."); pline("A throne.");
newsym(x, y); newsym(x, y);
return &zeroobj; return (struct obj *) &zeroobj;
} }
if (!BSTRCMPI(bp, p - 4, "sink")) { if (!BSTRCMPI(bp, p - 4, "sink")) {
lev->typ = SINK; lev->typ = SINK;
level.flags.nsinks++; level.flags.nsinks++;
pline("A sink."); pline("A sink.");
newsym(x, y); newsym(x, y);
return &zeroobj; return (struct obj *) &zeroobj;
} }
/* ("water" matches "potion of water" rather than terrain) */ /* ("water" matches "potion of water" rather than terrain) */
if (!BSTRCMPI(bp, p - 4, "pool") || !BSTRCMPI(bp, p - 4, "moat")) { if (!BSTRCMPI(bp, p - 4, "pool") || !BSTRCMPI(bp, p - 4, "moat")) {
@@ -3619,7 +3619,7 @@ wiztrap:
/* Must manually make kelp! */ /* Must manually make kelp! */
water_damage_chain(level.objects[x][y], TRUE); water_damage_chain(level.objects[x][y], TRUE);
newsym(x, y); newsym(x, y);
return &zeroobj; return (struct obj *) &zeroobj;
} }
if (!BSTRCMPI(bp, p - 4, "lava")) { /* also matches "molten lava" */ if (!BSTRCMPI(bp, p - 4, "lava")) { /* also matches "molten lava" */
lev->typ = LAVAPOOL; lev->typ = LAVAPOOL;
@@ -3628,7 +3628,7 @@ wiztrap:
if (!(Levitation || Flying)) if (!(Levitation || Flying))
(void) lava_effects(); (void) lava_effects();
newsym(x, y); newsym(x, y);
return &zeroobj; return (struct obj *) &zeroobj;
} }
if (!BSTRCMPI(bp, p - 5, "altar")) { if (!BSTRCMPI(bp, p - 5, "altar")) {
@@ -3648,7 +3648,7 @@ wiztrap:
lev->altarmask = Align2amask(al); lev->altarmask = Align2amask(al);
pline("%s altar.", An(align_str(al))); pline("%s altar.", An(align_str(al)));
newsym(x, y); newsym(x, y);
return &zeroobj; return (struct obj *) &zeroobj;
} }
if (!BSTRCMPI(bp, p - 5, "grave") if (!BSTRCMPI(bp, p - 5, "grave")
@@ -3657,7 +3657,7 @@ wiztrap:
pline("%s.", IS_GRAVE(lev->typ) ? "A grave" pline("%s.", IS_GRAVE(lev->typ) ? "A grave"
: "Can't place a grave here"); : "Can't place a grave here");
newsym(x, y); newsym(x, y);
return &zeroobj; return (struct obj *) &zeroobj;
} }
if (!BSTRCMPI(bp, p - 4, "tree")) { if (!BSTRCMPI(bp, p - 4, "tree")) {
@@ -3665,14 +3665,14 @@ wiztrap:
pline("A tree."); pline("A tree.");
newsym(x, y); newsym(x, y);
block_point(x, y); block_point(x, y);
return &zeroobj; return (struct obj *) &zeroobj;
} }
if (!BSTRCMPI(bp, p - 4, "bars")) { if (!BSTRCMPI(bp, p - 4, "bars")) {
lev->typ = IRONBARS; lev->typ = IRONBARS;
pline("Iron bars."); pline("Iron bars.");
newsym(x, y); newsym(x, y);
return &zeroobj; return (struct obj *) &zeroobj;
} }
} }
@@ -3688,10 +3688,10 @@ wiztrap:
if (!oclass) if (!oclass)
return ((struct obj *) 0); return ((struct obj *) 0);
any: any:
if (!oclass) if (!oclass)
oclass = wrpsym[rn2((int) sizeof(wrpsym))]; oclass = wrpsym[rn2((int) sizeof wrpsym)];
typfnd: typfnd:
if (typ) if (typ)
oclass = objects[typ].oc_class; oclass = objects[typ].oc_class;
@@ -3981,7 +3981,7 @@ typfnd:
|| (otmp->oartifact && rn2(nartifact_exist()) > 1)) && !wizard) { || (otmp->oartifact && rn2(nartifact_exist()) > 1)) && !wizard) {
artifact_exists(otmp, safe_oname(otmp), FALSE); artifact_exists(otmp, safe_oname(otmp), FALSE);
obfree(otmp, (struct obj *) 0); obfree(otmp, (struct obj *) 0);
otmp = &zeroobj; otmp = (struct obj *) &zeroobj;
pline("For a moment, you feel %s in your %s, but it disappears!", pline("For a moment, you feel %s in your %s, but it disappears!",
something, makeplural(body_part(HAND))); something, makeplural(body_part(HAND)));
} }

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 weapon.c $NHDT-Date: 1545964580 2018/12/28 02:36:20 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.67 $ */ /* NetHack 3.6 weapon.c $NHDT-Date: 1547025169 2019/01/09 09:12:49 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.68 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -402,7 +402,7 @@ register struct monst *mtmp;
char mlet = mtmp->data->mlet; char mlet = mtmp->data->mlet;
propellor = &zeroobj; propellor = (struct obj *) &zeroobj;
Oselect(EGG); /* cockatrice egg */ Oselect(EGG); /* cockatrice egg */
if (mlet == S_KOP) /* pies are first choice for Kops */ if (mlet == S_KOP) /* pies are first choice for Kops */
Oselect(CREAM_PIE); Oselect(CREAM_PIE);
@@ -461,25 +461,25 @@ register struct monst *mtmp;
} }
/* KMH -- This belongs here so darts will work */ /* KMH -- This belongs here so darts will work */
propellor = &zeroobj; propellor = (struct obj *) &zeroobj;
prop = (objects[rwep[i]]).oc_skill; prop = objects[rwep[i]].oc_skill;
if (prop < 0) { if (prop < 0) {
switch (-prop) { switch (-prop) {
case P_BOW: case P_BOW:
propellor = (oselect(mtmp, YUMI)); propellor = oselect(mtmp, YUMI);
if (!propellor) if (!propellor)
propellor = (oselect(mtmp, ELVEN_BOW)); propellor = oselect(mtmp, ELVEN_BOW);
if (!propellor) if (!propellor)
propellor = (oselect(mtmp, BOW)); propellor = oselect(mtmp, BOW);
if (!propellor) if (!propellor)
propellor = (oselect(mtmp, ORCISH_BOW)); propellor = oselect(mtmp, ORCISH_BOW);
break; break;
case P_SLING: case P_SLING:
propellor = (oselect(mtmp, SLING)); propellor = oselect(mtmp, SLING);
break; break;
case P_CROSSBOW: case P_CROSSBOW:
propellor = (oselect(mtmp, CROSSBOW)); propellor = oselect(mtmp, CROSSBOW);
} }
if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != propellor if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != propellor
&& mtmp->weapon_check == NO_WEAPON_WANTED) && mtmp->weapon_check == NO_WEAPON_WANTED)
@@ -681,6 +681,7 @@ register struct monst *mon;
} }
if (obj && obj != &zeroobj) { if (obj && obj != &zeroobj) {
struct obj *mw_tmp = MON_WEP(mon); struct obj *mw_tmp = MON_WEP(mon);
if (mw_tmp && mw_tmp->otyp == obj->otyp) { if (mw_tmp && mw_tmp->otyp == obj->otyp) {
/* already wielding it */ /* already wielding it */
mon->weapon_check = NEED_WEAPON; mon->weapon_check = NEED_WEAPON;