]> git.pond.sub.org Git - empserver/commitdiff
torpedo: Don't disclose uid, type, owner of torpedoed subs
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 11 Jan 2015 16:50:09 +0000 (17:50 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 2 Mar 2015 07:20:50 +0000 (08:20 +0100)
torp() reports target uid and type to the player.  Hide for submarine
targets, just like we hide attacking submarine details in bulletins to
the target's owner.

torp() and fire_torp() leak submarine owners through the news.
Suppress news for submarine targets.  This is consistent with fire:
mfir() doesn't report depth-charging, and quiet_bigdef() doesn't
report return torpedoes.

Historical note: the code has always hidden submarine uid, type and
owner in places, and leaked them in others.  When capability sub-torp
was added in Chainsaw, no attention was paid to hiding.  When Empire 2
hid attacking submarines, it did nothing for submarine targets.

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

index 6b01b719565139709207a141cecc0e2013141da8..f6a7355b41826ba33253b39adedd190ee9681baa 100644 (file)
@@ -178,17 +178,19 @@ 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);
-           pr("Torpedo hit %s for %d damage.\n", prship(&vship), dam);
+           pr("Torpedo hit %s for %d damage.\n", prsub(&vship), dam);
            shipdamage(&vship, dam);
            if (vship.shp_effic < SHIP_MINEFF)
-               pr("%s sunk!\n", prship(&vship));
+               pr("%s sunk!\n", prsub(&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);
-           else
-               nreport(vshipown, N_SHIP_TORP, player->cnum, 1);
+           if (!(mchr[vship.shp_type].m_flags & M_SUB)) {
+               if (mchr[(int)sub.shp_type].m_flags & M_SUB)
+                   nreport(vshipown, N_TORP_SHIP, 0, 1);
+               else
+                   nreport(vshipown, N_SHIP_TORP, player->cnum, 1);
+           }
        } else {
            pr("Missed\n");
            if (vshipown != 0)
@@ -312,10 +314,12 @@ fire_torp(struct shpstr *sp, struct shpstr *targ, int ntargets)
        shipdamage(targ, dam);
        putship(targ->shp_uid, targ);
 
-       if (mchr[(int)sp->shp_type].m_flags & M_SUB)
-           nreport(targ->shp_own, N_TORP_SHIP, 0, 1);
-       else
-           nreport(targ->shp_own, N_SHIP_TORP, sp->shp_own, 1);
+       if (!(mchr[targ->shp_type].m_flags & M_SUB)) {
+           if (mchr[(int)sp->shp_type].m_flags & M_SUB)
+               nreport(targ->shp_own, N_TORP_SHIP, 0, 1);
+           else
+               nreport(targ->shp_own, N_SHIP_TORP, sp->shp_own, 1);
+       }
     } else {
        pr("Missed!\n");
        if (sp->shp_own != 0)