avoid War message if tinning a Rider corpse fails
prevent long messages from triggering access violation or segmentation fault
due to buffer overflow in pline()
+cursed corpse wielded by a monster isn't welded to its hand or paw
Platform- and/or Interface-Specific Fixes
E int FDECL(welded, (struct obj *));
E void FDECL(weldmsg, (struct obj *));
E void FDECL(setmnotwielded, (struct monst *,struct obj *));
+E boolean FDECL(mwelded, (struct obj *));
/* ### windows.c ### */
mon_hand = 0; /* lint suppression */
You("wrap your bullwhip around %s.", yname(otmp));
- if (gotit && otmp->cursed) {
+ if (gotit && mwelded(otmp)) {
pline("%s welded to %s %s%c",
(otmp->quan == 1L) ? "It is" : "They are",
mhis(mtmp), mon_hand,
struct monst *mon;
{
struct obj *obj, *mwep;
+ boolean welded_wep;
/* monkeys who manage to steal tins can't open and eat them
even if they happen to also have the appropriate tool */
if (is_animal(mon->data)) return FALSE;
mwep = MON_WEP(mon);
+ welded_wep = mwep && mwelded(mwep);
/* this is different from the player; tin opener or dagger doesn't
have to be wielded, and knife can be used instead of dagger
(even so, non-nymphs don't pick up tins, so only nymphs might
end up being able to benefit from them) */
for (obj = mon->minvent; obj; obj = obj->nobj) {
/* if stuck with a cursed weapon, don't check rest of inventory */
- if (mwep && mwep->cursed && obj != mwep) continue;
+ if (welded_wep && obj != mwep) continue;
if (obj->otyp == TIN_OPENER ||
(obj->oclass == WEAPON_CLASS &&
-/* SCCS Id: @(#)weapon.c 3.5 2006/12/14 */
+/* SCCS Id: @(#)weapon.c 3.5 2007/02/09 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
case P_CROSSBOW:
propellor = (oselect(mtmp, CROSSBOW));
}
- if ((otmp = MON_WEP(mtmp)) && otmp->cursed && otmp != propellor
+ if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != propellor
&& mtmp->weapon_check == NO_WEAPON_WANTED)
propellor = 0;
}
if (rwep[i] != LOADSTONE) {
/* Don't throw a cursed weapon-in-hand or an artifact */
if ((otmp = oselect(mtmp, rwep[i])) && !otmp->oartifact
- && (!otmp->cursed || otmp != MON_WEP(mtmp)))
+ && !(otmp == MON_WEP(mtmp) && mwelded(otmp)))
return(otmp);
} else for(otmp=mtmp->minvent; otmp; otmp=otmp->nobj) {
if (otmp->otyp == LOADSTONE && !otmp->cursed)
* polymorphed into little monster. But it's not quite clear how to
* handle this anyway....
*/
- if (!(mw_tmp->cursed && mon->weapon_check == NO_WEAPON_WANTED))
+ if (!(mwelded(mw_tmp) && mon->weapon_check == NO_WEAPON_WANTED))
mon->weapon_check = NEED_WEAPON;
return;
}
* can know it's cursed and needn't even bother trying.
* Still....
*/
- if (mw_tmp && mw_tmp->cursed && mw_tmp->otyp != CORPSE) {
+ if (mw_tmp && mwelded(mw_tmp)) {
if (canseemon(mon)) {
char welded_buf[BUFSZ];
const char *mon_hand = mbodypart(mon, HAND);
mon->weapon_check = NEED_WEAPON;
if (canseemon(mon)) {
pline("%s wields %s!", Monnam(mon), doname(obj));
- if (obj->cursed && obj->otyp != CORPSE) {
+ if (mwelded(mw_tmp)) {
pline("%s %s to %s %s!",
Tobjnam(obj, "weld"),
is_plural(obj) ? "themselves" : "itself",
obj->owornmask = savewornmask;
}
+/* test whether monster's wielded weapon is stuck to hand/paw/whatever */
+boolean
+mwelded(obj)
+struct obj *obj;
+{
+ /* caller is responsible for making sure this is a monster's item */
+ if (obj && (obj->owornmask & W_WEP) && will_weld(obj)) return TRUE;
+ return FALSE;
+}
+
/*wield.c*/