]> git.pond.sub.org Git - empserver/commitdiff
Fix fire not to disclose retreat and wipe out target shell use
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 May 2008 19:58:29 +0000 (21:58 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 5 May 2008 04:53:33 +0000 (06:53 +0200)
multifire() clobbered any changes to the target ship or sector made by
defend().  This let the target fire back for free.

multifire() retreated the target ship before reporting its location to
the player.  This disclosed its new location.

Fix by damaging and retreating the target after calling defend().

src/lib/commands/mfir.c

index e3b59e5183a3093ae0945e6c5ec0a8f35ac63e5b..0e0aa697b2c7e06a9ac8f9228e417b17060801bf 100644 (file)
@@ -443,8 +443,6 @@ multifire(void)
        case targ_sub:
            pr_beep();
            pr("Kawhomp!!!\n");
-           if (vship.shp_rflags & RET_DCHRGED)
-               retreat_ship(&vship, 'd');
            break;
        default:
            pr_beep();
@@ -470,18 +468,11 @@ multifire(void)
                   player->cnum, xyas(x, y, vict), dam);
            pr("Shells hit sector %s for %d damage.\n",
               xyas(x, y, player->cnum), dam);
-           if (target != targ_bogus)
-               sectdamage(&vsect, dam);
            break;
        case targ_ship:
            nreport(player->cnum, N_SHP_SHELL, vict, 1);
            /* fall through */
        default:
-           if ((target != targ_sub) ||
-               ((vship.shp_rflags & RET_DCHRGED) == 0))
-               check_retreat_and_do_shipdamage(&vship, dam);
-           else
-               shipdamage(&vship, dam);
            if (vict) {
                wu(0, vict,
                   "Country #%d shelled %s in %s for %d damage.\n",
@@ -491,10 +482,6 @@ multifire(void)
            pr("Shells hit %s in %s for %d damage.\n",
               prsub(&vship),
               xyas(vship.shp_x, vship.shp_y, player->cnum), dam);
-
-           if (vship.shp_effic < SHIP_MINEFF)
-               pr("%s sunk!\n", prsub(&vship));
-
            break;
        }
        /*  Ok, now, check if we had a bogus target.  If so,
@@ -509,9 +496,19 @@ multifire(void)
        totaldefdam = defend(&fired, &defended, attgp, vict, &ndefending);
        switch (target) {
        case targ_land:
+           getsect(x, y, &vsect);
+           sectdamage(&vsect, dam);
            putsect(&vsect);
            break;
        default:
+           getship(vshipno, &vship);
+           check_retreat_and_do_shipdamage(&vship, dam);
+           if (vship.shp_effic < SHIP_MINEFF)
+               pr("%s sunk!\n", prsub(&vship));
+           else if (target == targ_sub
+               && (vship.shp_rflags & RET_DCHRGED)
+               && !(vship.shp_rflags & RET_INJURED))
+               retreat_ship(&vship, 'd');
            putship(vship.shp_uid, &vship);
            break;
        }