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 <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2015-02-08 12:45:52 +01:00
parent ee3b02c514
commit 165fbed512

View file

@ -272,7 +272,6 @@ multifire(void)
} }
range = shp_fire_range(&fship); range = shp_fire_range(&fship);
range2 = roundrange(range); range2 = roundrange(range);
pr("range is %d.00 (%.2f)\n", range2, range);
/* Use depth charges against subs, but only when in range */ /* Use depth charges against subs, but only when in range */
if (target == targ_ship && trange <= range2 if (target == targ_ship && trange <= range2
&& (mchr[vship.shp_type].m_flags & M_SUB) && (mchr[vship.shp_type].m_flags & M_SUB)
@ -284,10 +283,6 @@ multifire(void)
dam = shp_fire(&fship); dam = shp_fire(&fship);
fship.shp_mission = 0; fship.shp_mission = 0;
putship(fship.shp_uid, &fship); putship(fship.shp_uid, &fship);
if (CANT_HAPPEN(dam < 0)) {
pr("Klick! ...\n");
continue;
}
if (opt_NOMOBCOST == 0) { if (opt_NOMOBCOST == 0) {
fship.shp_mobil = MAX(fship.shp_mobil - 15, -100); fship.shp_mobil = MAX(fship.shp_mobil - 15, -100);
putship(fship.shp_uid, &fship); putship(fship.shp_uid, &fship);
@ -304,14 +299,9 @@ multifire(void)
} }
range = lnd_fire_range(&fland); range = lnd_fire_range(&fland);
range2 = roundrange(range); range2 = roundrange(range);
pr("range is %d.00 (%.2f)\n", range2, range);
dam = lnd_fire(&fland); dam = lnd_fire(&fland);
fland.lnd_mission = 0; fland.lnd_mission = 0;
putland(fland.lnd_uid, &fland); putland(fland.lnd_uid, &fland);
if (CANT_HAPPEN(dam < 0)) {
pr("Klick! ...\n");
continue;
}
if (target == targ_ship) { if (target == targ_ship) {
if (chance(lnd_acc(&fland) / 100.0)) if (chance(lnd_acc(&fland) / 100.0))
dam = ldround(dam / 2.0, 1); dam = ldround(dam / 2.0, 1);
@ -328,15 +318,15 @@ multifire(void)
} }
dam = fort_fire(&fsect); dam = fort_fire(&fsect);
putsect(&fsect); putsect(&fsect);
if (CANT_HAPPEN(dam < 0)) {
pr("Klick! ...\n");
continue;
}
range = fortrange(&fsect); range = fortrange(&fsect);
range2 = roundrange(range); 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++; nfiring++;
switch (target) { switch (target) {
case targ_sub: case targ_sub: