]> git.pond.sub.org Git - empserver/commitdiff
fire: Clean up damage sanity check and printing of range
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 8 Feb 2015 11:45:52 +0000 (12:45 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 2 Mar 2015 07:20:52 +0000 (08:20 +0100)
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>
src/lib/commands/mfir.c

index e679074efa7c3b0d9fcd79c1717acda762f9368f..d74b25d6144631f470fc6997c9abe3f77d59aaa7 100644 (file)
@@ -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: