From 39d85a5ce7f26670fdf91db1b595e69a3f5d7ca1 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 18 Dec 2018 03:01:50 -0800 Subject: [PATCH] life support for comatose code in explmu() Static analysis notices that if (physical_damage) tmp = Maybe_Half_Phys(tmp); will never pass the test because all code paths leading to it set 'physical_damage' to False. Instead of getting rid of it, add a fake case that leaves that True. --- src/mhitu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mhitu.c b/src/mhitu.c index 85293d57b..67966db5f 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mhitu.c $NHDT-Date: 1540767817 2018/10/28 23:03:37 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.159 $ */ +/* NetHack 3.6 mhitu.c $NHDT-Date: 1545130893 2018/12/18 11:01:33 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.160 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1989,12 +1989,12 @@ boolean ufound; if (mtmp->mcan) return 0; - if (!ufound) + if (!ufound) { pline("%s explodes at a spot in %s!", canseemon(mtmp) ? Monnam(mtmp) : "It", levl[mtmp->mux][mtmp->muy].typ == WATER ? "empty water" : "thin air"); - else { + } else { int tmp = d((int) mattk->damn, (int) mattk->damd); boolean not_affected = defends((int) mattk->adtyp, uwep); @@ -2012,6 +2012,13 @@ boolean ufound; case AD_ELEC: physical_damage = FALSE; not_affected |= Shock_resistance; + goto common; + case AD_PHYS: + /* there aren't any exploding creatures with AT_EXPL attack + for AD_PHYS damage but there might be someday; without this, + static analysis complains that 'physical_damage' is always + False when tested below; it's right, but having that in + place means one less thing to update if AD_PHYS gets added */ common: if (!not_affected) {