]> git.pond.sub.org Git - empserver/commitdiff
Fix bugs in tracking of planes flying a sortie
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 29 Apr 2008 18:53:35 +0000 (20:53 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 29 Apr 2008 18:53:35 +0000 (20:53 +0200)
Commit 7ca4f412 fixed tracking of planes flying a sortie by marking
them with flag PLN_LAUNCHED.  It failed to write SAMs and planes
flying missions back to the plane file, in sam_intercept() and
mission_pln_arm().  The only known problem with that is fairly
harmless: when the mission damages planes on the ground, the planes
flying it get damaged as if they were still sitting in their bases,
but the damage gets wiped out when they land.

The same issue applies to missiles.  So they need to be tracked as
well.  Do that in msl_hit().

While there, remove a few redundant PLN_LAUNCHED sanity checks.

src/lib/subs/aircombat.c
src/lib/subs/mission.c
src/lib/subs/mslsub.c
src/lib/subs/plnsub.c

index 3b87878fa77ba4836f3d82fc63a97321d3c0742d..11616ee916fcc0ee0140783c7982045297710855 100644 (file)
@@ -404,13 +404,14 @@ sam_intercept(struct emp_qelem *att_list, struct emp_qelem *def_list,
                free(dqp);
                continue;
            }
-           if (mission_pln_equip(dplp, 0, P_F, 0) < 0) {
+           if (CANT_HAPPEN(dplp->plane.pln_flags & PLN_LAUNCHED)
+               || mission_pln_equip(dplp, 0, P_F, 0) < 0) {
                emp_remque(dqp);
                free(dqp);
                continue;
            }
-           CANT_HAPPEN(dplp->plane.pln_flags & PLN_LAUNCHED);
            dplp->plane.pln_flags |= PLN_LAUNCHED;
+           putplane(dplp->plane.pln_uid, &dplp->plane);
            if (first) {
                first = 0;
                PR(plane_owner, "%s launches SAMs!\n", cname(def_own));
index 3f812f2f408e9958048dfe092e9d2d8f6683d6be..e038c12c6207f3265d3bd7b63a7bd43744d8c91d 100644 (file)
@@ -969,9 +969,9 @@ mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
            mission_flags &= ~P_MINE;
        }
 
-       CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED);
        pp->pln_flags |= PLN_LAUNCHED;
        pp->pln_mobil -= pln_mobcost(dist, pp, flags);
+       putplane(pp->pln_uid, pp);
     }
     return mission_flags;
 }
index f5d42a2210319052dfb41c4d63bce94b3d3d3c3a..3345b2a5cc40bd6ef97b3645e439fe5b8f6752f9 100644 (file)
@@ -124,6 +124,9 @@ msl_hit(struct plnstr *pp, int hardtarget, int type, int news_item,
        return 0;
     }
 
+    CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED);
+    pp->pln_flags |= PLN_LAUNCHED;
+    putplane(pp->pln_uid, pp);
     mpr(pp->pln_own, "\tSHWOOOOOSH!  Missile launched!\n");
 
     if (pp->pln_nuketype != -1)
index e6f9768f4a6f3c0632b80332ead07b01cbb3500a..d2b811f5a41dea85dcd67bd6207c4783a6484e28 100644 (file)
@@ -587,7 +587,6 @@ pln_arm(struct emp_qelem *list, int dist, char mission, struct ichrstr *ip,
            mission_flags &= ~P_MINE;
            /* FIXME no effect */
        }
-       CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED);
        pp->pln_flags |= PLN_LAUNCHED;
        pp->pln_mobil -= pln_mobcost(dist, pp, flags);
        putplane(pp->pln_uid, pp);