From fff177be2f7b81fa3db9d47ca8489fc7e05b6799 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 17 May 2015 18:11:20 +0200 Subject: [PATCH] Revert "commands: Always put ship or land unit before retreating it" This reverts commit f4d8d64bb34dee75cb2485c130e125fdd3980c18. Breaks retreat after ship got sunk by bombs or missile. ship_bomb() and launch_missile() pass .shp_own to retreat_ship(). Wrong after putship(), because putship() resets the owner when the ship got sunk. retreat_ship() then oopses and fails to retreat the surviving members of the group. Other callers save the owner before putting the ship, and pass that. We could change these two to do the same. But since we're trying to get a release out, simply revert the broken commit instead. --- src/lib/commands/bomb.c | 4 ++-- src/lib/commands/laun.c | 2 +- src/lib/commands/mfir.c | 2 +- src/lib/commands/torp.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/commands/bomb.c b/src/lib/commands/bomb.c index d44d7d7d..39f1aa17 100644 --- a/src/lib/commands/bomb.c +++ b/src/lib/commands/bomb.c @@ -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); } } diff --git a/src/lib/commands/laun.c b/src/lib/commands/laun.c index 21f4c244..04900bac 100644 --- a/src/lib/commands/laun.c +++ b/src/lib/commands/laun.c @@ -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; } diff --git a/src/lib/commands/mfir.c b/src/lib/commands/mfir.c index 57c41623..69646fc8 100644 --- a/src/lib/commands/mfir.c +++ b/src/lib/commands/mfir.c @@ -397,13 +397,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) { diff --git a/src/lib/commands/torp.c b/src/lib/commands/torp.c index f042f92b..fc6b99ab 100644 --- a/src/lib/commands/torp.c +++ b/src/lib/commands/torp.c @@ -190,9 +190,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 && vshipown != player->cnum)