]> git.pond.sub.org Git - empserver/commitdiff
Fix ship interdiction targeting ships not at sea hvy-metal-2.4
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 8 Jun 2008 09:35:04 +0000 (11:35 +0200)
committerMarkus Armbruster <armbru@pike.pond.sub.org>
Tue, 10 Jun 2008 08:25:05 +0000 (10:25 +0200)
perform_mission() needs to know whether it is targeting ships or
something else, because the rules differ: submarines interdict only
ships, land units get their damage reduced when interdicting ships,
and different news are generated.

The old code assumed it was targeting ships when the target sector was
sea.  Wrong when interdicting ships in harbors, bridges and such.
This has always been broken.  Except when checking a submarine's
target: there it tested argument s, which is gross, but at least it
works.  That code was added in v4.0.8.

Replace the broken test by the gross hack everywhere.  This fixes news
and damage from land units when ships get interdicted in non-sea
sectors.
(cherry picked from commit 3e251b474fb90089c15ea8b5ece4c4f74962d0c0)

src/lib/subs/mission.c

index 129448c10853a0fda6ecbf118b8940fd678141a4..f4d1bf13e6b79488951ba0869399bf4a74877d2e 100644 (file)
@@ -344,10 +344,10 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
                if (getrel(getnatp(gp->own), sect.sct_own) > AT_WAR) {
 
                    /*
                if (getrel(getnatp(gp->own), sect.sct_own) > AT_WAR) {
 
                    /*
-                    * If the player->owner of the unit isn't at war
+                    * If the owner of the unit isn't at war
                     * with the victim, and doesn't own the
                     * sect being acted upon, and isn't the
                     * with the victim, and doesn't own the
                     * sect being acted upon, and isn't the
-                    * old player->owner of that sect, bounce them.
+                    * old owner of that sect, bounce them.
                     */
                    if (sect.sct_type != SCT_WATER &&
                        sect.sct_own != gp->own &&
                     */
                    if (sect.sct_type != SCT_WATER &&
                        sect.sct_own != gp->own &&
@@ -412,6 +412,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
     natid plane_owner = 0;
     int md, range, air_dam = 0;
     double prb, hitchance, vrange;
     natid plane_owner = 0;
     int md, range, air_dam = 0;
     double prb, hitchance, vrange;
+    int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
 
     getsect(x, y, &sect);
 
 
     getsect(x, y, &sect);
 
@@ -450,12 +451,12 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
            if (dam2 < 0)
                continue;
 
            if (dam2 < 0)
                continue;
 
-           if (sect.sct_type == SCT_WATER) {
+           if (targeting_ships) {
                if (chance(lnd_acc(lp) / 100.0))
                    dam2 = ldround(dam2 / 2.0, 1);
            }
            dam += dam2;
                if (chance(lnd_acc(lp) / 100.0))
                    dam2 = ldround(dam2 / 2.0, 1);
            }
            dam += dam2;
-           if (sect.sct_type == SCT_WATER)
+           if (targeting_ships)
                nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
            else
                nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
                nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
            else
                nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
@@ -492,10 +493,8 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
                    continue;
            }
            if (mcp->m_flags & M_SUB) {
                    continue;
            }
            if (mcp->m_flags & M_SUB) {
-/* If we aren't shooting at "subs" or "ships" don't fire at all from
-   a sub. */
-               if (*s != 's')
-                   continue;
+               if (!targeting_ships)
+                   continue;   /* subs interdict only ships */
                range = roundrange(torprange(sp));
                if (md > range)
                    continue;
                range = roundrange(torprange(sp));
                if (md > range)
                    continue;
@@ -552,7 +551,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
                if (chance(prb))
                    dam2 /= 2;
                dam += dam2;
                if (chance(prb))
                    dam2 /= 2;
                dam += dam2;
-               if (sect.sct_type == SCT_WATER)
+               if (targeting_ships)
                    nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
                else
                    nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
                    nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
                else
                    nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
@@ -685,7 +684,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
 
     if (air_dam > 0) {
        dam += air_dam;
 
     if (air_dam > 0) {
        dam += air_dam;
-       if (sect.sct_type == SCT_WATER)
+       if (targeting_ships)
            nreport(plane_owner, N_SHP_BOMB, victim, 1);
        else
            nreport(plane_owner, N_SCT_BOMB, victim, 1);
            nreport(plane_owner, N_SHP_BOMB, victim, 1);
        else
            nreport(plane_owner, N_SCT_BOMB, victim, 1);