fix pull request #621 - potential divide by 0

The pull request by argrath changes weight_cap() to never return a
value less than 1 because try_lift() divides by that return value
and a 0 would trigger a crash.  The code involved is used when
attempting to pull a monster out of a pit via #untrap.

I'm fairly sure that weight_cap() can never produce a value that's
less than 1 already, but have put in a variation of the PR's fix.
I've also implemented a different fix that removes the division
from try_lift().  The original code seems to have gone out of its
way to avoid calculating inv_weight() twice, but doing the latter
(for the once in a hundred games where it might happen) greatly
simplifies things by removing details of carrying capacity.

Fixes #621
This commit is contained in:
PatR
2021-10-25 14:51:26 -07:00
parent 27fcf8999f
commit b4908f6928
3 changed files with 20 additions and 20 deletions

View File

@@ -660,6 +660,8 @@ using 'F'orcefight against iron bars while wielding something breakable could
called twice and could yield results that conflicted
have applying a polearm give feedback similar to 'F' for melee weapon when
attacking a wall or boulder
if weight_cap() ever returned 0 (which probably can't happen), using #untrap
to pull a monster out of a pit would trigger a divide by 0 crash
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository