]> granicus.if.org Git - nethack/commitdiff
wielded candles vs rust (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 17 Jun 2006 04:43:44 +0000 (04:43 +0000)
committernethack.rankin <nethack.rankin>
Sat, 17 Jun 2006 04:43:44 +0000 (04:43 +0000)
     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
src/trap.c
src/wield.c

index f7efa6e2ecd800cd201b89ff9f16d9391fc483cd..771e13ade5adcd5672a7e9067cbce961e0f6b3cc 100644 (file)
@@ -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
index ba05e90bc824a2a951afb991087ca66f1d7d849f..bb05aa4e131a5ffde245e28b3259f146413e83dd 100644 (file)
@@ -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));
index 1708c4d869f29bc962d8f96056601c4e090787dd..c6507c2e358550738f26f3c35d0f1977f94e0db6 100644 (file)
@@ -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;