From e79a41ccb61159beb6f163da97f753165213d350 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sat, 17 Jun 2006 04:43:44 +0000 Subject: [PATCH] wielded candles vs rust (trunk only) From a bug report: [ slashem-Bugs-1206099 ] Torches are not extinguished with rust traps). A rust trap that hits the torso candles causes all lit objects being carried to be extinguished, but one which hit the weapon arm didn't have same affect on a wielded light. This fix causes wielded candles or lamps (not Sunsword) to go out if affected by any rust, such as hitting a rust monster with one, rather than use his patch that just handled the trap case. It also excludes wielded lights from the existing torso splash since having them be hit by both instances is too obviously buggy. I think brass lanterns ought to be exempt from being extinguished by water (at least splashing which is less drastic than total submersion) since there are references to them operating by batteries rather than fire, but I didn't want to track all the places which would be affected. --- doc/fixes35.0 | 1 + src/trap.c | 36 ++++++++++++++++++------------------ src/wield.c | 10 ++++++++-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index f7efa6e2e..771e13ade 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -148,6 +148,7 @@ limit recursive calls to spoteffects (poly'd hero fell into water, reverted ensure that the punishment ball and chain make it into the save file after being temporarily orphaned from the normal chains in the swallowing code charge for thrown wand that shatters into a thousand pieces in a shop +wielded light source susceptible to water gets extinguished when weapon rusts Platform- and/or Interface-Specific Fixes diff --git a/src/trap.c b/src/trap.c index ba05e90bc..bb05aa4e1 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)trap.c 3.5 2006/05/08 */ +/* SCCS Id: @(#)trap.c 3.5 2006/06/16 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -892,8 +892,10 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst); goto glovecheck; default: pline("%s you!", A_gush_of_water_hits); - for (otmp=invent; otmp; otmp = otmp->nobj) - (void) snuff_lit(otmp); + for (otmp = invent; otmp; otmp = otmp->nobj) + if (otmp->lamplit && otmp != uwep && + (otmp != uswapwep || !u.twoweap)) + (void) snuff_lit(otmp); if (uarmc) (void) rust_dmg(uarmc, cloak_simple_name(uarmc), 1, TRUE, &youmonst); @@ -1980,24 +1982,22 @@ glovecheck: target = which_armor(mtmp, W_ARMG); if (in_sight) pline("%s %s!", A_gush_of_water_hits, mon_nam(mtmp)); - for (otmp=mtmp->minvent; otmp; otmp = otmp->nobj) - (void) snuff_lit(otmp); - target = which_armor(mtmp, W_ARMC); - if (target) - (void) rust_dmg(target, cloak_simple_name(target), - 1, TRUE, mtmp); - else { - target = which_armor(mtmp, W_ARM); - if (target) - (void) rust_dmg(target, "armor", 1, TRUE, mtmp); + for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) + if (otmp->lamplit && + (otmp->owornmask & (W_WEP|W_SWAPWEP)) == 0) + (void) snuff_lit(otmp); + if ((target = which_armor(mtmp, W_ARMC)) != 0) + (void) rust_dmg(target, + cloak_simple_name(target), + 1, TRUE, mtmp); + else if ((target = which_armor(mtmp, W_ARM)) != 0) + (void) rust_dmg(target, "armor", 1, TRUE, mtmp); #ifdef TOURIST - else { - target = which_armor(mtmp, W_ARMU); - (void) rust_dmg(target, "shirt", 1, TRUE, mtmp); - } + else if ((target = which_armor(mtmp, W_ARMU)) != 0) + (void) rust_dmg(target, "shirt", 1, TRUE, mtmp); #endif - } } + if (mptr == &mons[PM_IRON_GOLEM]) { if (in_sight) pline("%s falls to pieces!", Monnam(mtmp)); diff --git a/src/wield.c b/src/wield.c index 1708c4d86..c6507c2e3 100644 --- a/src/wield.c +++ b/src/wield.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)wield.c 3.5 2006/04/14 */ +/* SCCS Id: @(#)wield.c 3.5 2006/06/16 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -619,6 +619,7 @@ boolean for_dip; struct monst *victim; boolean vismon, visobj, chill; boolean ret = FALSE; + boolean already_affected = FALSE; if (!target) return FALSE; @@ -627,6 +628,10 @@ boolean for_dip; vismon = victim && (victim != &youmonst) && canseemon(victim); visobj = !victim && cansee(bhitpos.x, bhitpos.y); /* assume thrown */ + if (!acid_dmg && target->lamplit) { + already_affected = snuff_lit(target); + if (already_affected) ret = TRUE; + } erosion = acid_dmg ? target->oeroded2 : target->oeroded; if (target->greased) { @@ -671,7 +676,8 @@ boolean for_dip; (acid_dmg ? !is_corrodeable(target) : !is_rustprone(target))) { if (flags.verbose || !(target->oerodeproof && target->rknown)) { if (((victim == &youmonst) || vismon) && !for_dip) - pline("%s not affected.", Yobjnam2(target, "are")); + pline("%s not %s.", Yobjnam2(target, "are"), + already_affected ? "harmed" : "affected"); /* no message if not carried or dipping */ } if (target->oerodeproof) target->rknown = !for_dip; -- 2.40.0