Fix bomb not to wipe out plane updates while asking for targets
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.
This commit is contained in:
parent
f10af4dea0
commit
f07e6901cb
1 changed files with 51 additions and 19 deletions
|
@ -49,15 +49,16 @@
|
|||
#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,
|
||||
|
@ -325,13 +326,16 @@ static void
|
|||
eff_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||
{
|
||||
struct plist *plp;
|
||||
struct emp_qelem *qp;
|
||||
struct emp_qelem *qp, *next;
|
||||
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;
|
||||
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)
|
||||
|
@ -369,7 +373,7 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
int i;
|
||||
int amt, before;
|
||||
struct ichrstr *ip;
|
||||
struct emp_qelem *qp;
|
||||
struct emp_qelem *qp, *next;
|
||||
struct sctstr sect;
|
||||
int dam = 0;
|
||||
int nukedam;
|
||||
|
@ -407,8 +411,11 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
} else
|
||||
break;
|
||||
}
|
||||
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;
|
||||
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)
|
||||
|
@ -445,7 +452,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
int dam;
|
||||
char *q;
|
||||
int n;
|
||||
struct emp_qelem *qp;
|
||||
struct emp_qelem *qp, *next;
|
||||
int shipno;
|
||||
struct shpstr ship;
|
||||
int nships = 0;
|
||||
|
@ -457,9 +464,12 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
int flak;
|
||||
int gun;
|
||||
|
||||
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;
|
||||
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)
|
||||
|
@ -502,6 +512,8 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
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];
|
||||
|
@ -571,7 +583,7 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
int n;
|
||||
natid own;
|
||||
struct plnstr plane;
|
||||
struct emp_qelem *qp;
|
||||
struct emp_qelem *qp, *next;
|
||||
int planeno;
|
||||
struct plist *plp;
|
||||
char prompt[128];
|
||||
|
@ -580,8 +592,11 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
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;
|
||||
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);
|
||||
|
@ -617,6 +632,8 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
}
|
||||
if (planeno < 0)
|
||||
continue;
|
||||
if (changed_plane_aborts(plp))
|
||||
continue;
|
||||
dam = 0;
|
||||
if (nuk_on_plane(&plp->plane) >= 0)
|
||||
hitchance = 100;
|
||||
|
@ -674,15 +691,18 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
char prompt[128];
|
||||
char buf[1024];
|
||||
struct lndstr land;
|
||||
struct emp_qelem *qp;
|
||||
struct emp_qelem *qp, *next;
|
||||
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;
|
||||
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);
|
||||
|
@ -716,6 +736,8 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
}
|
||||
if (unitno < 0)
|
||||
continue;
|
||||
if (changed_plane_aborts(plp))
|
||||
continue;
|
||||
|
||||
aaf = lnd_aaf(&land);
|
||||
if (aaf) {
|
||||
|
@ -798,6 +820,16 @@ strat_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
putsect(§);
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue