fix #H1826 - split long worm with 0 hit points

From a bug report, a long worm with 0 HP
was observed via stethoscope after cutting one or more worms in half many
times, followed by an unspecified crash.  Cutting a worm doesn't reduce
its level below 3, but if a worm is drained to level 0 by some other means
and then gets cut in half (and still has at least 2 HP left), cutworm()
would give the new level 0 worm 0d8 (hence 0) for current and max HP.
That could confuse end-of-move monster cleanup, which thinks 0 HP is a
dead monster who has been removed from the map but not yet purged from the
fmon list.  Purging it would then leave a stale monster pointer on the map.

     cutworm() should have special cased level 0 to use 1d4 for HP, but
instead I've changed it to not produce a cloned worm if the source one is
lower than level 3.
This commit is contained in:
nethack.rankin
2009-03-06 02:22:14 +00:00
parent b76f8aab8d
commit 077606bc01
2 changed files with 12 additions and 13 deletions

View File

@@ -366,6 +366,7 @@ could get "suddenly you cannot see the <mon>" while invisible mon remained
displayed due to telepathy or extended detection
cutting a long worm in half would trigger segfault/accvio crash if the hit
took parent down to 1 hit point or if long worms had become extinct
cutting a level 0 long worm in half produced a new worm with 0 hit points
blinded invisible hero can't see self as invisible via ';' or '/'
a hangup save while picking up gold from shop floor could duplicate that gold
jellyfish do not technically have a head