]> git.pond.sub.org Git - empserver/commitdiff
bomb fire launch torpedo: Don't disclose ship sinking in retreat
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 Jan 2015 12:49:38 +0000 (13:49 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 28 Feb 2015 15:21:35 +0000 (16:21 +0100)
These commands report "sunk!" even when the ship survives the attack
but sinks during retreat.  bomb even reports where on the retreat the
ship sinks.  Has been that way since retreat was added in Chainsaw.

Report "sunk!" only when the attack sinks the ship directly.

Similar code exists for land units, but it doesn't report killings.
Change it anyway, to keep it consistent with the ship code.

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

index f5c86ba291c1ffd47cf0cd087cd7cf882658868b..29adaaabee0ab27d90354a459dcaea7eb7aba4a0 100644 (file)
@@ -50,7 +50,5 @@
 
 extern void retreat_ship(struct shpstr *, char);
 extern void retreat_land(struct lndstr *, char);
-extern int check_retreat_and_do_shipdamage(struct shpstr *, int);
-extern int check_retreat_and_do_landdamage(struct lndstr *, int);
 
 #endif
index 9764e96d9e5f9898f1457cab7c0bc66b735bdf38..b90f3acf6bae672f79f97c5e6d269b328bc04868 100644 (file)
@@ -30,7 +30,7 @@
  *     Dave Pare, 1986
  *     Ken Stevens, 1995
  *     Steve McClure, 1998-2000
- *     Markus Armbruster, 2004-2012
+ *     Markus Armbruster, 2004-2015
  */
 
 #include <config.h>
@@ -476,17 +476,16 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
               xyas(target->sct_x, target->sct_y, ship.shp_own));
        }
        pr("\n");
-       check_retreat_and_do_shipdamage(&ship, dam);
-       if (ship.shp_rflags & RET_BOMBED)
-           if (((ship.shp_rflags & RET_INJURED) == 0) || !dam)
-               retreat_ship(&ship, 'b');
-       putship(ship.shp_uid, &ship);
-       getship(ship.shp_uid, &ship);
-       if (!ship.shp_own) {
+       shipdamage(&ship, dam);
+       if (ship.shp_effic < SHIP_MINEFF)
            pr("%s at %s sunk!\n",
               prship(&ship),
               xyas(target->sct_x, target->sct_y, player->cnum));
-       }
+       if (dam && (ship.shp_rflags & RET_INJURED))
+           retreat_ship(&ship, 'i');
+       else if (ship.shp_rflags & RET_BOMBED)
+           retreat_ship(&ship, 'b');
+       putship(ship.shp_uid, &ship);
        collateral_damage(target->sct_x, target->sct_y, dam / 2);
     }
 out:
@@ -678,11 +677,11 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
        own = land.lnd_own;
        mpr(own, "%s pinpoint bombing raid did %d damage to %s\n",
            cname(player->cnum), dam, prland(&land));
-       check_retreat_and_do_landdamage(&land, dam);
-
-       if (land.lnd_rflags & RET_BOMBED)
-           if (((land.lnd_rflags & RET_INJURED) == 0) || !dam)
-               retreat_land(&land, 'b');
+       landdamage(&land, dam);
+       if (dam && (land.lnd_rflags & RET_INJURED))
+           retreat_land(&land, 'i');
+       else if (land.lnd_rflags & RET_BOMBED)
+           retreat_land(&land, 'b');
        nreport(player->cnum, N_UNIT_BOMB, own, 1);
        putland(land.lnd_uid, &land);
        collateral_damage(target->sct_x, target->sct_y, dam);
index 840a2905b18246df5247e2cc470890e171ca98e0..4f1f1f8a0fab389d02b02d533cb2d5d69cdd0aab 100644 (file)
@@ -30,7 +30,7 @@
  *     Dave Pare, 1986
  *     Ken Stevens, 1995
  *     Steve McClure, 1998-2000
- *     Markus Armbruster, 2005-2012
+ *     Markus Armbruster, 2005-2015
  */
 
 #include <config.h>
@@ -273,11 +273,12 @@ launch_missile(struct plnstr *pp)
            return RET_OK;
        }
        dam = pln_damage(pp, 'p', 1);
-       check_retreat_and_do_shipdamage(&target_ship, dam);
-       putship(target_ship.shp_uid, &target_ship);
-       getship(target_ship.shp_uid, &target_ship);
-       if (!target_ship.shp_own)
+       shipdamage(&target_ship, dam);
+       if (target_ship.shp_effic < SHIP_MINEFF)
            pr("%s sunk!\n", prship(&target_ship));
+       if (dam && (target_ship.shp_rflags & RET_INJURED))
+           retreat_ship(&target_ship, 'i');
+       putship(target_ship.shp_uid, &target_ship);
     }
     return RET_OK;
 }
index e3bc0057a46c528b82ac6cd069ada655e88e9047..c997e7dd369d6c5853f80d6a4ab71b61f89b1ee8 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Steve McClure, 2000
- *     Markus Armbruster, 2004-2014
+ *     Markus Armbruster, 2004-2015
  */
 
 #include <config.h>
@@ -423,16 +423,14 @@ multifire(void)
            break;
        default:
            getship(vshipno, &vship);
-           check_retreat_and_do_shipdamage(&vship, dam);
+           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))
+           if (dam && (vship.shp_rflags & RET_INJURED))
+               retreat_ship(&vship, 'i');
+           else if (target == targ_sub && (vship.shp_rflags & RET_DCHRGED))
                retreat_ship(&vship, 'd');
-           else if (totaldefdam == 0
-                    && (vship.shp_rflags & RET_HELPLESS)
-                    && !(vship.shp_rflags & RET_INJURED))
+           else if (totaldefdam == 0 && (vship.shp_rflags & RET_HELPLESS))
                retreat_ship(&vship, 'h');
            putship(vship.shp_uid, &vship);
            break;
index b09faaf266ad6c4797c30d1b241b97cae0af91d2..d49dda553c6b02bbd55cfa6478e0879dc478b2e5 100644 (file)
@@ -178,13 +178,12 @@ torp(void)
                wu(0, vshipown, "%s in %s torpedoed %s for %d damage.\n",
                   prsub(&sub), xyas(sub.shp_x, sub.shp_y, vshipown),
                   prship(&vship), dam);
-           shipdamage(&vship, dam);
-           if (vship.shp_rflags & RET_TORPED)
-               retreat_ship(&vship, 't');
            pr("Torpedo hit %s for %d damage.\n", prship(&vship), dam);
-
+           shipdamage(&vship, dam);
            if (vship.shp_effic < SHIP_MINEFF)
                pr("%s sunk!\n", prship(&vship));
+           if (vship.shp_rflags & RET_TORPED)
+               retreat_ship(&vship, 't');
            putship(vship.shp_uid, &vship);
            if (mchr[(int)sub.shp_type].m_flags & M_SUB)
                nreport(vshipown, N_TORP_SHIP, 0, 1);
index f51137ba4fc0d0c33d5597056652d46bf46c5e2d..98b9a8e0f239aad14fe3b0aa66c3d21a86307101 100644 (file)
@@ -78,19 +78,6 @@ static struct ccode conditions[] = {
     { 0,   { "panicked", "panicked"} }
 };
 
-int
-check_retreat_and_do_shipdamage(struct shpstr *sp, int dam)
-{
-    if (dam <= 0)
-       return 0;
-
-    shipdamage(sp, dam);
-    if (sp->shp_rflags & RET_INJURED)
-       retreat_ship(sp, 'i');
-
-    return 1;
-}
-
 void
 retreat_ship(struct shpstr *sp, char code)
 {
@@ -281,19 +268,6 @@ findcondition(char code)
     return i;
 }
 
-int
-check_retreat_and_do_landdamage(struct lndstr *lp, int dam)
-{
-    if (dam <= 0)
-       return 0;
-
-    landdamage(lp, dam);
-    if (lp->lnd_rflags & RET_INJURED)
-       retreat_land(lp, 'i');
-
-    return 1;
-}
-
 void
 retreat_land(struct lndstr *lp, char code)
 {