The commands to fly planes read the planes into a plane list, and
write them back when they land. If a plane changes in the file while
it is in that plane list, the changes get wiped out when the plane
lands, triggering a seqno oops.
This is not an issue as long as the complete sortie runs
uninterrupted, because that code takes care to update flying planes
only through the appropriate plane list.
However, the bomb command suspends the planes on a pinpoint bombing
run mid-air over the target sector to let the player choose targets.
This lets code run that *can* update flying planes, for instance the
edit command.
Fix by aborting changed planes, taking care not to clobber the
changes.
#include "retreat.h"
#include "ship.h"
#include "retreat.h"
#include "ship.h"
-static void pin_bomb(struct emp_qelem *list, struct sctstr *target);
-static void strat_bomb(struct emp_qelem *list, struct sctstr *target);
-static void comm_bomb(struct emp_qelem *list, struct sctstr *target);
-static void eff_bomb(struct emp_qelem *list, struct sctstr *target);
-static int pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp,
- natid from, int flak);
-static void plane_bomb(struct emp_qelem *list, struct sctstr *target);
-static void land_bomb(struct emp_qelem *list, struct sctstr *target);
-static void ship_bomb(struct emp_qelem *list, struct sctstr *target);
+static void pin_bomb(struct emp_qelem *, struct sctstr *);
+static void eff_bomb(struct emp_qelem *, struct sctstr *);
+static void comm_bomb(struct emp_qelem *, struct sctstr *);
+static void ship_bomb(struct emp_qelem *, struct sctstr *);
+static void plane_bomb(struct emp_qelem *, struct sctstr *);
+static void land_bomb(struct emp_qelem *, struct sctstr *);
+static void strat_bomb(struct emp_qelem *, struct sctstr *);
+static int changed_plane_aborts(struct plist *);
+static int pinflak_planedamage(struct plnstr *, struct plchrstr *,
+ natid, int);
static i_type bombcomm[] = {
I_CIVIL,
static i_type bombcomm[] = {
I_CIVIL,
eff_bomb(struct emp_qelem *list, struct sctstr *target)
{
struct plist *plp;
eff_bomb(struct emp_qelem *list, struct sctstr *target)
{
struct plist *plp;
+ struct emp_qelem *qp, *next;
struct sctstr sect;
int oldeff, dam = 0;
int nukedam;
struct sctstr sect;
int oldeff, dam = 0;
int nukedam;
- for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
+ for (qp = list->q_forw; qp != list; qp = next) {
+ next = qp->q_forw;
plp = (struct plist *)qp;
plp = (struct plist *)qp;
+ if (changed_plane_aborts(plp))
+ continue;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
int i;
int amt, before;
struct ichrstr *ip;
int i;
int amt, before;
struct ichrstr *ip;
+ struct emp_qelem *qp, *next;
struct sctstr sect;
int dam = 0;
int nukedam;
struct sctstr sect;
int dam = 0;
int nukedam;
- for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
+ for (qp = list->q_forw; qp != list; qp = next) {
+ next = qp->q_forw;
plp = (struct plist *)qp;
plp = (struct plist *)qp;
+ if (changed_plane_aborts(plp))
+ continue;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
+ struct emp_qelem *qp, *next;
int shipno;
struct shpstr ship;
int nships = 0;
int shipno;
struct shpstr ship;
int nships = 0;
- for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
+ for (qp = list->q_forw; qp != list; qp = next) {
+ next = qp->q_forw;
free_shiplist(&head);
plp = (struct plist *)qp;
free_shiplist(&head);
plp = (struct plist *)qp;
+ if (changed_plane_aborts(plp))
+ continue;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
if (plp->pcp->pl_flags & P_A)
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
if (plp->pcp->pl_flags & P_A)
continue;
if ((plp->pcp->pl_flags & P_A) && !on_shiplist(shipno, head))
continue;
continue;
if ((plp->pcp->pl_flags & P_A) && !on_shiplist(shipno, head))
continue;
+ if (changed_plane_aborts(plp))
+ continue;
gun = shp_usable_guns(&ship);
mcp = &mchr[(int)ship.shp_type];
gun = shp_usable_guns(&ship);
mcp = &mchr[(int)ship.shp_type];
int n;
natid own;
struct plnstr plane;
int n;
natid own;
struct plnstr plane;
+ struct emp_qelem *qp, *next;
int planeno;
struct plist *plp;
char prompt[128];
int planeno;
struct plist *plp;
char prompt[128];
int nukedam;
int nplanes;
int nukedam;
int nplanes;
- for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
+ for (qp = list->q_forw; qp != list; qp = next) {
+ next = qp->q_forw;
plp = (struct plist *)qp;
plp = (struct plist *)qp;
+ if (changed_plane_aborts(plp))
+ continue;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
}
if (planeno < 0)
continue;
}
if (planeno < 0)
continue;
+ if (changed_plane_aborts(plp))
+ continue;
dam = 0;
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
dam = 0;
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
char prompt[128];
char buf[1024];
struct lndstr land;
char prompt[128];
char buf[1024];
struct lndstr land;
+ struct emp_qelem *qp, *next;
int unitno;
int aaf, flak, hitchance;
struct plist *plp;
int nukedam;
int nunits;
int unitno;
int aaf, flak, hitchance;
struct plist *plp;
int nukedam;
int nunits;
- for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
+ for (qp = list->q_forw; qp != list; qp = next) {
+ next = qp->q_forw;
plp = (struct plist *)qp;
plp = (struct plist *)qp;
+ if (changed_plane_aborts(plp))
+ continue;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0);
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0);
}
if (unitno < 0)
continue;
}
if (unitno < 0)
continue;
+ if (changed_plane_aborts(plp))
+ continue;
aaf = lnd_aaf(&land);
if (aaf) {
aaf = lnd_aaf(&land);
if (aaf) {
+static int
+changed_plane_aborts(struct plist *plp)
+{
+ if (check_plane_ok(&plp->plane))
+ return 0;
+ getplane(plp->plane.pln_uid, &plp->plane);
+ pln_put1(plp);
+ return 1;
+}
+
static int
pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
int flak)
static int
pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
int flak)