]> git.pond.sub.org Git - empserver/commitdiff
commands: Always put ship or land unit before retreating it
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 12 Jan 2015 21:19:32 +0000 (22:19 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 2 Mar 2015 07:20:51 +0000 (08:20 +0100)
boar() puts before retreating, the other callers afterwards.  Subtle
difference, because putting resets the owner of the dead to POGO.

Until the commit before previous, retreat didn't fully work after put.
Now it does.  The subtle difference between boar() and the other
callers still exists.  It's better to do it the same everywhere, as
subtle differences invite bugs.  Since changing boar() is not
practical, change the others.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/bomb.c
src/lib/commands/laun.c
src/lib/commands/mfir.c
src/lib/commands/torp.c

index 5e4888cd223b2f296070abab3cee746597ef38f2..38487f502969953d63dc3b26a204d5225e0edc23 100644 (file)
@@ -480,11 +480,11 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
            pr("%s at %s sunk!\n",
               prship(&ship),
               xyas(target->sct_x, target->sct_y, player->cnum));
+       putship(ship.shp_uid, &ship);
        if (dam && (ship.shp_rflags & RET_INJURED))
            retreat_ship(&ship, ship.shp_own, 'i');
        else if (ship.shp_rflags & RET_BOMBED)
            retreat_ship(&ship, ship.shp_own, 'b');
-       putship(ship.shp_uid, &ship);
        collateral_damage(target->sct_x, target->sct_y, dam / 2);
     }
 out:
@@ -670,12 +670,12 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
                cname(player->cnum), dam, prland(&land),
                xyas(target->sct_x, target->sct_y, own));
        landdamage(&land, dam);
+       putland(land.lnd_uid, &land);
        if (dam && (land.lnd_rflags & RET_INJURED))
            retreat_land(&land, own, 'i');
        else if (land.lnd_rflags & RET_BOMBED)
            retreat_land(&land, own, 'b');
        nreport(player->cnum, N_UNIT_BOMB, own, 1);
-       putland(land.lnd_uid, &land);
        collateral_damage(target->sct_x, target->sct_y, dam);
     }
 }
index 04900bac0a59468ba2db561f9236416758b526c5..21f4c244d2d5c2a45f1da98e8a5da3704bf9ba30 100644 (file)
@@ -276,9 +276,9 @@ launch_missile(struct plnstr *pp)
        shipdamage(&target_ship, dam);
        if (target_ship.shp_effic < SHIP_MINEFF)
            pr("%s sunk!\n", prship(&target_ship));
+       putship(target_ship.shp_uid, &target_ship);
        if (dam && (target_ship.shp_rflags & RET_INJURED))
            retreat_ship(&target_ship, target_ship.shp_own, 'i');
-       putship(target_ship.shp_uid, &target_ship);
     }
     return RET_OK;
 }
index a7e02db93a192f878b491284f3531926cd452831..788ad2ebcef5b9a6aeaf307c264a9dbda47939b3 100644 (file)
@@ -426,13 +426,13 @@ multifire(void)
            shipdamage(&vship, dam);
            if (vship.shp_effic < SHIP_MINEFF)
                pr("%s sunk!\n", prsub(&vship));
+           putship(vship.shp_uid, &vship);
            if (dam && (vship.shp_rflags & RET_INJURED))
                retreat_ship(&vship, vict, 'i');
            else if (target == targ_sub && (vship.shp_rflags & RET_DCHRGED))
                retreat_ship(&vship, vict, 'd');
            else if (totaldefdam == 0 && (vship.shp_rflags & RET_HELPLESS))
                retreat_ship(&vship, vict, 'h');
-           putship(vship.shp_uid, &vship);
            break;
        }
        switch (attgp->ef_type) {
index d945d180860f60d8c68352e2275d7123a7a241c0..79ca3eb47d6a9aec94741c1134d4e0851abd14d3 100644 (file)
@@ -188,9 +188,9 @@ torp(void)
            shipdamage(&vship, dam);
            if (vship.shp_effic < SHIP_MINEFF)
                pr("%s sunk!\n", prsub(&vship));
+           putship(vship.shp_uid, &vship);
            if (vship.shp_rflags & RET_TORPED)
                retreat_ship(&vship, vshipown, 't');
-           putship(vship.shp_uid, &vship);
        } else {
            pr("Missed\n");
            if (vshipown != 0)