From 165fbed512d339cdd452c5dbed69c2950bc8d7f3 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 8 Feb 2015 12:45:52 +0100 Subject: [PATCH] fire: Clean up damage sanity check and printing of range Repeated for ship, sector and land unit firing. The latter prints range only when the sanity check succeeds. Factor out, changing ship and sector to behave like land unit firing. When the sanity check fails, print "Jammed!" instead of "Klick!", because "Klick!" suggests no shells. Used to be printed exactly then, but the condition first became impossible (Chainsaw), then generalized to "can't fire for whatever reason" (commit 22c6fd8, v4.3.12). Signed-off-by: Markus Armbruster --- src/lib/commands/mfir.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/lib/commands/mfir.c b/src/lib/commands/mfir.c index e679074ef..d74b25d61 100644 --- a/src/lib/commands/mfir.c +++ b/src/lib/commands/mfir.c @@ -272,7 +272,6 @@ multifire(void) } range = shp_fire_range(&fship); range2 = roundrange(range); - pr("range is %d.00 (%.2f)\n", range2, range); /* Use depth charges against subs, but only when in range */ if (target == targ_ship && trange <= range2 && (mchr[vship.shp_type].m_flags & M_SUB) @@ -284,10 +283,6 @@ multifire(void) dam = shp_fire(&fship); fship.shp_mission = 0; putship(fship.shp_uid, &fship); - if (CANT_HAPPEN(dam < 0)) { - pr("Klick! ...\n"); - continue; - } if (opt_NOMOBCOST == 0) { fship.shp_mobil = MAX(fship.shp_mobil - 15, -100); putship(fship.shp_uid, &fship); @@ -304,14 +299,9 @@ multifire(void) } range = lnd_fire_range(&fland); range2 = roundrange(range); - pr("range is %d.00 (%.2f)\n", range2, range); dam = lnd_fire(&fland); fland.lnd_mission = 0; putland(fland.lnd_uid, &fland); - if (CANT_HAPPEN(dam < 0)) { - pr("Klick! ...\n"); - continue; - } if (target == targ_ship) { if (chance(lnd_acc(&fland) / 100.0)) dam = ldround(dam / 2.0, 1); @@ -328,15 +318,15 @@ multifire(void) } dam = fort_fire(&fsect); putsect(&fsect); - if (CANT_HAPPEN(dam < 0)) { - pr("Klick! ...\n"); - continue; - } range = fortrange(&fsect); range2 = roundrange(range); - pr("range is %d.00 (%.2f)\n", range2, range); } + if (CANT_HAPPEN(dam < 0)) { + pr("Jammed!\n"); + continue; + } + pr("range is %d.00 (%.2f)\n", range2, range); nfiring++; switch (target) { case targ_sub: -- 2.43.0