]> granicus.if.org Git - nethack/commitdiff
fix github pull request #418 - towel wetness
authorPatR <rankin@nethack.org>
Sat, 12 Dec 2020 20:04:20 +0000 (12:04 -0800)
committerPatR <rankin@nethack.org>
Sat, 12 Dec 2020 20:04:20 +0000 (12:04 -0800)
Fire damage would dry out a wet towel but never all the way to 0.
Water damage would wet a towel but if it was already wet, its
wetness might decrease.

This uses the pull request's change for increasing the wetness
but changes dry_a_towel so that the original code for decreasing
that will work as is.  Using wet_a_towel() to set wetness to 0
doesn't make much sense, so still won't do so; dry_a_towel() does
and now will.

This also adds missing perm_invent update for towels in inventory
changing wetness.

Fixes #418

doc/fixes37.0
src/trap.c
src/weapon.c

index bc44a85e57e32141167d0512d2c5f05885b1e2ed..7474295049fccc44997a03176cdd3cf216a3dd32 100644 (file)
@@ -332,6 +332,10 @@ selling a container to a shop for gold leaves any contents that the shop
        contents without giving any additional credit; mark out of place
        contents 'no_charge' so that hero can reclaim them without buying
 add some new demonic and angelic maledictions
+when fire damage dried a wet towel, it would never reduce the wetness to 0
+when water damage wet a towel, the new wetness might randomly become less
+when the wetness of a towel in inventory changed, persistent inventory wasn't
+       updated to show that
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 746699d65636b94f0d80a8901caac10a6eed6891..60bd409f8cf71681a31ec9be596a50f972d9236f 100644 (file)
@@ -89,7 +89,7 @@ struct monst *victim;
     /* burning damage may dry wet towel */
     item = hitting_u ? carrying(TOWEL) : m_carrying(victim, TOWEL);
     while (item) {
-        if (is_wet_towel(item)) {
+        if (is_wet_towel(item)) { /* True => (item->spe > 0) */
             oldspe = item->spe;
             dry_a_towel(item, rn2(oldspe + 1), TRUE);
             if (item->spe != oldspe)
@@ -3882,7 +3882,10 @@ boolean force;
     if (obj->otyp == CAN_OF_GREASE && obj->spe > 0) {
         return ER_NOTHING;
     } else if (obj->otyp == TOWEL && obj->spe < 7) {
-        wet_a_towel(obj, rnd(7), TRUE);
+        /* a negative change induces a reverse increment, adding abs(change);
+           spe starts 0..6, arg passed to rnd() is 1..7, change is -7..-1,
+           final spe is 1..7 and always greater than its starting value */
+        wet_a_towel(obj, -rnd(7 - obj->spe), TRUE);
         return ER_NOTHING;
     } else if (obj->greased) {
         if (!rn2(2))
index a785f4fbfe3146b6d735c5a34e009ee46f829776..7e29213ccdaaeb51c6f0e5dba338ad3f97b10964 100644 (file)
@@ -984,16 +984,18 @@ boolean verbose;
        with your wet towel" message on next attack with it */
     if (obj == uwep)
         g.unweapon = !is_wet_towel(obj);
+    if (carried(obj))
+        update_inventory();
 }
 
-/* decrease a towel's wetness */
+/* decrease a towel's wetness; unlike when wetting, 0 is not a no-op */
 void
 dry_a_towel(obj, amt, verbose)
 struct obj *obj;
-int amt; /* positive: new value; negative: decrement by -amt; zero: no-op */
+int amt; /* positive or zero: new value; negative: decrement by abs(amt) */
 boolean verbose;
 {
-    int newspe = (amt <= 0) ? obj->spe + amt : amt;
+    int newspe = (amt < 0) ? obj->spe + amt : amt;
 
     /* new state is only reported if it's a decrease */
     if (newspe < obj->spe) {
@@ -1013,6 +1015,8 @@ boolean verbose;
        bashing with your towel" message on next attack with it */
     if (obj == uwep)
         g.unweapon = !is_wet_towel(obj);
+    if (carried(obj))
+        update_inventory();
 }
 
 /* copy the skill level name into the given buffer */