Planes normally sit in their base (sector or carrier), where they can
be spied, damaged, captured, loaded, unloaded, upgraded and so forth.
All this must not be possible while they fly. There are two kinds of
flying planes: satellites in orbit, and planes flying a sortie.
Satellites in orbit have always been marked with flag PLN_LAUNCHED.
Works. What didn't work was tracking planes flying a sortie.
If you look at one sortie in isolation, up to three groups of planes
can be flying at any point of time: the primary group, which carries
out the sortie's mission (bomb, transport, ...), their escorts, and a
group of hostile planes flying interception or air defense.
The old code attempted to track these planes by passing those groups
to the places that need to know whether a plane is flying. This was
complex and incomplete, and broke down completely for the pin-bombing
command.
It was complex, because the plane code needs to keep track of all the
call chains that can lead to a place that needs to know whether a
plane flies, and pass the groups down the call chains. This leads to
a rather ugly passing of plane groups all over the place.
It was incomplete, because it generally failed to pass the escorts.
And the whole scheme broke down for the pin-bombing command. That's
because pin-bombing asks the player for targets while his planes are
loitering above the target sector. This yields the processor and lets
other code run. Which does not get the flying planes passed.
The new code marks planes and SAMs (but not other missiles) flying a
sortie with flag PLN_LAUNCHED (the previous commit laid the groundwork
for that), and does away with passing around groups of flying planes.
This fixes the following bugs:
* Many commands could interact with foreign planes flying for a
pin-bombing command as if they were sitting in their base. This
includes spying, damaging, capturing, loading, or upgrading them,
and even getting intercepted by them. Any changes to those planes
were wiped out when they landed. Abusable.
* The bomb command could bomb its own escorts, directly (pin-bomb
planes) or through collateral damage, strategic sector damage,
collapsing bridges or nuke damage. The damage to the escorts was
wiped out when they landed.
* If you asked for a plane to fly both in the primary group and the
escort group, you got charged fuel for two sorties instead of one.
* pln_put1() and pln_put() now recognize planes that didn't take off,
and refrain from making them land. Intercept (since commit
c64e2149) and air defense can do that. Making them land had no
ill-effects, but it was still wrong.
There's one new problem: if PLN_LAUNCHED doesn't get reset properly,
due to game crash during flight or some other bug, the plane gets
stuck in the air. Catch and fix that on game start in ef_verify().
float pln_theta; /* position in orbital sine wave */
};
-#define PLN_LAUNCHED bit(0) /* A satellite that's in orbit */
+#define PLN_LAUNCHED bit(0) /* Flying (satellite: in orbit) */
#define PLN_SYNCHRONOUS bit(1) /* A satellite in geo-synchronous orbit */
#define PLN_AIRBURST bit(2) /* Airburst the nuke we're armed with */
extern void ac_airtoair(struct emp_qelem *, struct emp_qelem *);
extern int ac_flak_dam(int, int, int);
extern void ac_encounter(struct emp_qelem *, struct emp_qelem *, coord,
- coord, char *, int, int,
- struct emp_qelem *, struct emp_qelem *);
-extern int ac_isflying(struct plnstr *, struct emp_qelem *);
+ coord, char *, int, int);
extern void sam_intercept(struct emp_qelem *, struct emp_qelem *,
natid, natid, coord, coord, int);
extern int confirm(char *);
extern int askyn(char *);
/* bridgefall.c */
-extern void bridge_damaged(struct sctstr *, struct emp_qelem *);
-extern void bridgefall(struct sctstr *, struct emp_qelem *);
+extern void bridge_damaged(struct sctstr *);
+extern void bridgefall(struct sctstr *);
/* bsanct.c */
extern void bsanct(void);
/* caploss.c */
extern int shipsatxy(coord, coord, int, int);
extern int carriersatxy(coord, coord, natid);
extern int unitsatxy(coord, coord, int, int);
-extern int planesatxy(coord, coord, int, int, struct emp_qelem *);
+extern int planesatxy(coord, coord, int, int);
extern int asw_shipsatxy(coord, coord, int, int, struct plnstr *,
struct shiplist **);
extern int num_shipsatxy(coord, coord, int, int);
extern int share_bmap(natid, natid, struct nstr_sect *, char, char *);
/* mission.c */
extern char *mission_name(short);
-extern int collateral_damage(coord, coord, int, struct emp_qelem *);
+extern int collateral_damage(coord, coord, int);
extern int mission_pln_equip(struct plist *, struct ichrstr *, int, char);
extern int ground_interdict(coord, coord, natid, char *);
extern int unit_interdict(coord, coord, natid, char *, int, int);
extern int pln_mobcost(int, struct plnstr *, int);
extern void pln_put(struct emp_qelem *);
extern void pln_put1(struct plist *);
-extern void pln_removedupes(struct emp_qelem *, struct emp_qelem *);
extern void take_plane_off_ship(struct plnstr *, struct shpstr *);
extern void take_plane_off_land(struct plnstr *, struct lndstr *);
extern void plane_sweep(struct emp_qelem *, coord, coord);
extern void item_prewrite(short *);
extern int issector(char *);
/* sectdamage.c */
-extern int sect_damage(struct sctstr *, int, struct emp_qelem *);
-extern int sectdamage(struct sctstr *, int, struct emp_qelem *);
+extern int sect_damage(struct sctstr *, int);
+extern int sectdamage(struct sctstr *, int);
/* ship.c */
extern char *prship(struct shpstr *);
extern int shp_postread(int, void *);
}
mission_flags = pln_arm(&esc_list, 2 * ap_to_target, mission,
ip, P_F | P_ESC, mission_flags);
- ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, mission_flags,
- 0, 0, 0);
+ ac_encounter(&bomb_list, &esc_list, ax, ay,
+ flightpath, mission_flags, 0);
if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n");
} else if (target.sct_type == SCT_SANCT) {
} else {
nships = shipsatxy(target->sct_x, target->sct_y, 0, M_SUB);
}
- nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0, list);
+ nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0);
retry:
p = getstring("Bomb what? (ship, plane, land unit, efficiency, commodities) ",
"%s bombing raid did %d%% damage in %s\n",
cname(player->cnum), oldeff - target->sct_effic,
xyas(target->sct_x, target->sct_y, target->sct_own));
- bridge_damaged(target, list);
+ bridge_damaged(target);
putsect(§);
- collateral_damage(target->sct_x, target->sct_y, dam, list);
+ collateral_damage(target->sct_x, target->sct_y, dam);
}
static void
cname(player->cnum), b, ip->i_name,
xyas(target->sct_x, target->sct_y, target->sct_own));
putsect(§);
- collateral_damage(target->sct_x, target->sct_y, dam, list);
+ collateral_damage(target->sct_x, target->sct_y, dam);
}
static void
/* Bombs that miss have to land somewhere! */
dam = pln_damage(&plp->plane, target->sct_x, target->sct_y,
'p', &nukedam, 0);
- collateral_damage(target->sct_x, target->sct_y, dam, list);
+ collateral_damage(target->sct_x, target->sct_y, dam);
dam = 0;
}
if (dam <= 0) /* dam == 0 if only nukes were delivered */
prship(&ship),
xyas(target->sct_x, target->sct_y, player->cnum));
}
- collateral_damage(target->sct_x, target->sct_y, dam / 2, list);
+ collateral_damage(target->sct_x, target->sct_y, dam / 2);
next:
;
}
plp = (struct plist *)qp;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
- nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0, list);
+ nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
if (nplanes == 0) {
pr("%s could not find any planes!\n", prplane(&plp->plane));
continue;
continue;
}
if (*q == '?') {
- planesatxy(target->sct_x, target->sct_y, 0, 0, list);
+ planesatxy(target->sct_x, target->sct_y, 0, 0);
continue;
}
if (*q == 'd')
if (getplane(n, &plane) &&
plane.pln_x == target->sct_x &&
plane.pln_y == target->sct_y &&
- ((plane.pln_flags & PLN_LAUNCHED) == 0) &&
- (!ac_isflying(&plane, list)))
+ !(plane.pln_flags & PLN_LAUNCHED))
planeno = n;
else
pr("Plane #%d not spotted\n", n);
/* Bombs that miss have to land somewhere! */
dam = pln_damage(&plp->plane, target->sct_x, target->sct_y,
'p', &nukedam, 0);
- collateral_damage(target->sct_x, target->sct_y, dam, list);
+ collateral_damage(target->sct_x, target->sct_y, dam);
dam = 0;
}
if (dam <= 0) /* dam == 0 if only nukes were delivered */
cname(player->cnum), dam, prplane(&plane),
xyas(target->sct_x, target->sct_y, own));
putplane(plane.pln_uid, &plane);
- collateral_damage(target->sct_x, target->sct_y, dam, list);
+ collateral_damage(target->sct_x, target->sct_y, dam);
next:
;
}
/* Bombs that miss have to land somewhere! */
dam = pln_damage(&plp->plane, target->sct_x, target->sct_y,
'p', &nukedam, 0);
- collateral_damage(target->sct_x, target->sct_y, dam, list);
+ collateral_damage(target->sct_x, target->sct_y, dam);
dam = 0;
}
if (dam <= 0) /* dam == 0 if only nukes were delivered */
retreat_land(&land, 'b');
nreport(player->cnum, N_UNIT_BOMB, own, 1);
putland(land.lnd_uid, &land);
- collateral_damage(target->sct_x, target->sct_y, dam, list);
+ collateral_damage(target->sct_x, target->sct_y, dam);
next:
;
}
cname(player->cnum), PERCENT_DAMAGE(dam),
xyas(target->sct_x, target->sct_y, target->sct_own));
- sectdamage(target, dam, list);
+ sectdamage(target, dam);
pr("did %d damage in %s\n", PERCENT_DAMAGE(dam),
xyas(target->sct_x, target->sct_y, player->cnum));
if (opt_EASY_BRIDGES == 0) { /* may cause a bridge fall */
if (n != SCT_BHEAD)
continue;
- bridgefall(§, 0);
+ bridgefall(§);
}
}
if (changed)
}
mission_flags = pln_arm(&esc_list, 2 * ap_to_target, 'd',
ip, P_ESC | P_F, mission_flags);
- ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, mission_flags,
- 0, 0, 0);
+ ac_encounter(&bomb_list, &esc_list, ax, ay,
+ flightpath, mission_flags, 0);
if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n");
} else {
}
mission_flags = pln_arm(&esc_list, ap_to_target, 't',
ip, P_ESC | P_F, mission_flags);
- ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, mission_flags,
- 0, 0, 0);
+ ac_encounter(&bomb_list, &esc_list, ax, ay,
+ flightpath, mission_flags, 0);
if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n");
} else {
cname(player->cnum), dam,
xyas(sx, sy, sect.sct_own));
}
- sectdamage(§, dam, 0);
+ sectdamage(§, dam);
putsect(§);
}
} /* end PINPOINTMISSILE conditional */
}
pp->pln_x = sx;
pp->pln_y = sy;
+ CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED);
pp->pln_flags |= PLN_LAUNCHED;
pp->pln_mobil = pp->pln_mobil > dist ? pp->pln_mobil - dist : 0;
putplane(pp->pln_uid, pp);
pr("Shells hit sector %s for %d damage.\n",
xyas(x, y, player->cnum), dam);
if (target != targ_bogus)
- sectdamage(&vsect, dam, 0);
+ sectdamage(&vsect, dam);
break;
case targ_ship:
nreport(player->cnum, N_SHP_SHELL, vict, 1);
vict = fp->victim;
pr("Return fire hit sector %s for %d damage.\n",
xyas(fp->x, fp->y, player->cnum), dam);
- sectdamage(§, dam, 0);
+ sectdamage(§, dam);
putsect(§);
if (vict)
wu(0, vict, "Return fire hit sector %s for %d damage.\n",
}
mission_flags = pln_arm(&esc_list, 2 * ap_to_target, 'a',
&ichr[I_MILIT], P_ESC | P_F, mission_flags);
- ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, mission_flags,
- 0, 0, 0);
+ ac_encounter(&bomb_list, &esc_list, ax, ay,
+ flightpath, mission_flags, 0);
if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n");
} else {
if (*player->argp[0] == 's')
mission_flags |= PM_S;
- ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, mission_flags,
- 0, 0, 0);
+ ac_encounter(&bomb_list, &esc_list, ax, ay,
+ flightpath, mission_flags, 0);
if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n");
} else {
land.lnd_own = 0;
putland(land.lnd_uid, &land);
- sectdamage(§, dam, 0);
+ sectdamage(§, dam);
putsect(§);
land.lnd_own = player->cnum;
#include "file.h"
#include "misc.h"
#include "nsc.h"
+#include "plane.h"
#include "product.h"
static void verify_fail(int, int, struct castr *, int, char *, ...)
return ret_val;
}
+static void
+pln_zap_transient_flags(void)
+{
+ int i;
+ struct plnstr *pp;
+
+ /* laziness: assumes plane file is EFF_MEM */
+ for (i = 0; (pp = getplanep(i)) != NULL; i++) {
+ if (pp->pln_flags & PLN_LAUNCHED
+ && (plchr[pp->pln_type].pl_flags & (P_M | P_O)) != P_O) {
+ pp->pln_flags &= ~PLN_LAUNCHED;
+ verify_fail(EF_PLANE, i, NULL, 0, "stuck in the air (patched)");
+ /*
+ * Can't putplane() here, because pln_prewrite() crashes
+ * without a valid player.
+ */
+ }
+ }
+}
+
int
ef_verify()
{
}
}
+ pln_zap_transient_flags();
return retval;
}
static void ac_landflak(struct emp_qelem *, coord, coord);
static void ac_shipflak(struct emp_qelem *, coord, coord);
static void ac_fireflak(struct emp_qelem *, natid, int);
-static void getilist(struct emp_qelem *, natid,
- struct emp_qelem *, struct emp_qelem *,
- struct emp_qelem *, struct emp_qelem *);
+static void getilist(struct emp_qelem *, natid);
static int do_evade(struct emp_qelem *, struct emp_qelem *);
void
ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
coord x, coord y, char *path, int mission_flags,
- int no_air_defense, struct emp_qelem *obomb,
- struct emp_qelem *oesc)
+ int no_air_defense)
{
int val, non_missiles;
int rel;
}
}
- pln_removedupes(bomb_list, esc_list);
while ((dir = mypath[myp++]) && !QEMPTY(bomb_list)) {
if ((val = diridx(dir)) == DIR_STOP)
break;
continue;
if (unfriendly[sect.sct_own] && !gotilist[sect.sct_own]) {
- getilist(&ilist[sect.sct_own], sect.sct_own,
- bomb_list, esc_list, obomb, oesc);
+ getilist(&ilist[sect.sct_own], sect.sct_own);
gotilist[sect.sct_own]++;
}
if (rel > HOSTILE)
if (unfriendly[cn]) {
/* They are unfriendly too */
if (!gotilist[cn]) {
- getilist(&ilist[cn], cn, bomb_list, esc_list, obomb,
- oesc);
+ getilist(&ilist[cn], cn);
gotilist[cn]++;
}
PR(plane_owner, "Flying over %s ships in %s\n",
if (unfriendly[cn]) {
/* They are unfriendly too */
if (!gotilist[cn]) {
- getilist(&ilist[cn], cn, bomb_list, esc_list, obomb,
- oesc);
+ getilist(&ilist[cn], cn);
gotilist[cn]++;
}
PR(plane_owner, "Flying over %s land units in %s\n",
free(dqp);
continue;
}
+ CANT_HAPPEN(dplp->plane.pln_flags & PLN_LAUNCHED);
+ dplp->plane.pln_flags |= PLN_LAUNCHED;
if (first) {
first = 0;
PR(plane_owner, "%s launches SAMs!\n", cname(def_own));
dist = mapdist(x, y, pp->pln_x, pp->pln_y) * 2;
if (pp->pln_range < dist)
continue;
- if (mission_pln_equip(plp, 0, P_F, 0) < 0) {
+ if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
+ || mission_pln_equip(plp, 0, P_F, 0) < 0) {
emp_remque(qp);
free(qp);
continue;
/* got one; delete from def_list, add to int_list */
emp_remque(qp);
emp_insque(qp, &int_list);
+ pp->pln_flags |= PLN_LAUNCHED;
pp->pln_mobil -= pln_mobcost(dist, pp, P_F);
putplane(pp->pln_uid, pp);
icount++;
return dam;
}
-/*
- * See if this plane is flying in this list
- */
-int
-ac_isflying(struct plnstr *plane, struct emp_qelem *list)
-{
- struct emp_qelem *qp;
- struct emp_qelem *next;
- struct plnstr *pp;
- struct plist *plp;
-
- if (!list)
- return 0;
- for (qp = list->q_forw; qp != list; qp = next) {
- next = qp->q_forw;
- plp = (struct plist *)qp;
- pp = &plp->plane;
- if (plane->pln_uid == pp->pln_uid)
- return 1;
- }
- return 0;
-}
-
-
/*
* Get a list of planes available for interception duties.
*/
static void
-getilist(struct emp_qelem *list, natid own, struct emp_qelem *a,
- struct emp_qelem *b, struct emp_qelem *c, struct emp_qelem *d)
+getilist(struct emp_qelem *list, natid own)
{
struct plchrstr *pcp;
struct plnstr plane;
pcp = &plchr[(int)plane.pln_type];
if ((pcp->pl_flags & P_F) == 0)
continue;
+ if (plane.pln_flags & PLN_LAUNCHED)
+ continue;
if (plane.pln_mission != 0)
continue;
if (plane.pln_mobil <= 0)
continue;
if (!pln_airbase_ok(&plane, 0, 0))
continue;
- /* Finally, is it in the list of planes already in
- flight? */
- if (ac_isflying(&plane, a))
- continue;
- if (ac_isflying(&plane, b))
- continue;
- if (ac_isflying(&plane, c))
- continue;
- if (ac_isflying(&plane, d))
- continue;
/* got one! */
ip = malloc(sizeof(*ip));
ip->bombs = 0;
}
if (off->type == EF_SECTOR) {
getsect(off->x, off->y, §);
- sectdamage(§, dam, 0);
+ sectdamage(§, dam);
putsect(§);
pr("Enemy fleet at %s does %d damage to %s\n",
xyas(def->x, def->y, player->cnum), dam, prcom(0, off));
#include "sect.h"
#include "xy.h"
-static void knockdown(struct sctstr *, struct emp_qelem *);
+static void knockdown(struct sctstr *);
/*
* Check bridges at and around SP after damage to SP.
* left to the caller.
*/
void
-bridge_damaged(struct sctstr *sp, struct emp_qelem *list)
+bridge_damaged(struct sctstr *sp)
{
int des;
des = sp->sct_type;
if (des == SCT_BSPAN || des == SCT_BTOWER)
- knockdown(sp, list);
+ knockdown(sp);
if ((des == SCT_BHEAD || des == SCT_BTOWER) && !opt_EASY_BRIDGES)
- bridgefall(sp, list);
+ bridgefall(sp);
}
void
-bridgefall(struct sctstr *sp, struct emp_qelem *list)
+bridgefall(struct sctstr *sp)
{
int i;
int j;
}
}
if (j > 6) {
- knockdown(§, list);
+ knockdown(§);
putsect(§);
}
}
/* Knock down a bridge span. Note that this does NOT write the
* sector out to the database, it's up to the caller to do that. */
static void
-knockdown(struct sctstr *sp, struct emp_qelem *list)
+knockdown(struct sctstr *sp)
{
struct lndstr land;
struct plnstr plane;
continue;
if (plane.pln_ship >= 0)
continue;
- /* Is this plane flying in this list? */
- if (ac_isflying(&plane, list))
- continue;
np = getnatp(plane.pln_own);
if (np->nat_flags & NF_BEEP)
mpr(plane.pln_own, "\07");
}
if (opt_FALLOUT)
fallout = sect.sct_fallout;
- sect_damage(§, damage, 0);
+ sect_damage(§, damage);
if (sect.sct_x == x && sect.sct_y == y)
retval = damage;
if (opt_FALLOUT) {
}
int
-planesatxy(coord x, coord y, int wantflags, int nowantflags,
- struct emp_qelem *list)
+planesatxy(coord x, coord y, int wantflags, int nowantflags)
{
int first;
int planes;
continue;
if (plane.pln_flags & PLN_LAUNCHED)
continue;
- /* Is this plane one of the ones flying somewhere? */
- if (ac_isflying(&plane, list))
- continue;
plp = &plchr[(int)plane.pln_type];
if (first) {
pr(" # owner eff type\n");
MI_INTERDICT);
if (dam) {
mpr(victim, "missile interdiction mission does %d damage!\n", dam);
- collateral_damage(newx, newy, dam, 0);
+ collateral_damage(newx, newy, dam);
}
qp = msl_list.q_forw;
while (qp != msl_list.q_forw) {
cname(cn), newdam);
}
if (dam) {
- collateral_damage(x, y, dam, 0);
+ collateral_damage(x, y, dam);
}
return dam;
}
int
-collateral_damage(coord x, coord y, int dam, struct emp_qelem *list)
+collateral_damage(coord x, coord y, int dam)
{
int coll;
struct sctstr sect;
return 0;
mpr(sect.sct_own, "%s takes %d%% collateral damage\n",
xyas(x, y, sect.sct_own), coll);
- sectdamage(§, coll, list);
+ sectdamage(§, coll);
putsect(§);
return coll;
}
}
}
if (dam) {
- collateral_damage(x, y, dam, 0);
+ collateral_damage(x, y, dam);
}
return dam;
}
xyas(air->x, air->y, air->own));
}
- ac_encounter(&b, &e, air->x, air->y, pp, mission_flags, 0, 0, 0);
+ ac_encounter(&b, &e, air->x, air->y, pp, mission_flags, 0);
if (!QEMPTY(&b))
air_dam +=
struct emp_qelem *qp;
struct emp_qelem *next;
struct plist *plp;
+ struct plnstr *pp;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
plp = (struct plist *)qp;
+ pp = &plp->plane;
- if (plp->plane.pln_x != x)
+ if (pp->pln_x != x)
continue;
- if (plp->plane.pln_y != y)
+ if (pp->pln_y != y)
continue;
- if (mission_pln_equip(plp, ip, flags, mission) < 0) {
+ if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
+ || mission_pln_equip(plp, ip, flags, mission) < 0) {
emp_remque(qp);
free(qp);
continue;
mission_flags &= ~P_MINE;
}
- /*
- * Mob costs for missions are 1/2 normal
- * Not anymore. :)
- */
-/* plp->plane.pln_mobil -= pln_mobcost(dist,&plp->plane,flags)/2;*/
- plp->plane.pln_mobil -= pln_mobcost(dist, &plp->plane, flags);
-
+ CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED);
+ pp->pln_flags |= PLN_LAUNCHED;
+ pp->pln_mobil -= pln_mobcost(dist, pp, flags);
}
return mission_flags;
}
}
/* Now, even though we missed, the bombs
land somewhere. */
- collateral_damage(x, y, newdam, bombers);
+ collateral_damage(x, y, newdam);
}
/* use up missiles */
/* Now, fly the planes to the sector */
emp_initque(&empty);
ac_encounter(&i, &empty, air->x, air->y,
- path, mission_flags, 1, bomb_list, esc_list);
+ path, mission_flags, 1);
/* If none made it, continue */
if (QEMPTY(&i))
pr("Explosion damages %s %d%%",
xyas(pp->pln_x, pp->pln_y, pp->pln_own), dam);
getsect(pp->pln_x, pp->pln_y, §);
- sectdamage(§, dam, 0);
+ sectdamage(§, dam);
putsect(§);
}
}
} else {
/* Missiles that miss have to hit somewhere! */
newdam = pln_damage(&plp->plane, x, y, 'p', &nukedam, 0);
- collateral_damage(x, y, newdam, 0);
+ collateral_damage(x, y, newdam);
}
plp->plane.pln_effic = 0;
putplane(plp->plane.pln_uid, &plp->plane);
struct emp_qelem *qp;
struct emp_qelem *next;
struct plist *plp;
+ struct plnstr *pp;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
plp = (struct plist *)qp;
- if (pln_equip(plp, ip, flags, mission) < 0) {
+ pp = &plp->plane;
+ if ((pp->pln_flags & PLN_LAUNCHED)
+ || pln_equip(plp, ip, flags, mission) < 0) {
emp_remque(qp);
free(qp);
continue;
mission_flags &= ~P_MINE;
/* FIXME no effect */
}
- plp->plane.pln_mobil -= pln_mobcost(dist, &plp->plane, flags);
- pr("%s equipped\n", prplane(&plp->plane));
+ 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);
+ pr("%s equipped\n", prplane(pp));
}
return mission_flags;
}
struct sctstr sect;
pp = &plp->plane;
- if (!pp->pln_own) {
- /* crashed */
+
+ if (CANT_HAPPEN((pp->pln_flags & PLN_LAUNCHED)
+ && (plchr[pp->pln_type].pl_flags & P_M)
+ && pp->pln_effic >= PLANE_MINEFF))
+ pp->pln_effic = 0; /* bug: missile launched but not used up */
+
+ if (!(pp->pln_flags & PLN_LAUNCHED))
+ ; /* never took off */
+ else if (pp->pln_effic < PLANE_MINEFF) {
+ /* destroyed */
if (pp->pln_ship >= 0) {
getship(pp->pln_ship, &ship);
take_plane_off_ship(pp, &ship);
pp->pln_effic = 0;
}
}
+ pp->pln_flags &= ~PLN_LAUNCHED;
putplane(pp->pln_uid, pp);
emp_remque(&plp->queue);
free(plp);
}
-void
-pln_removedupes(struct emp_qelem *bomb_list, struct emp_qelem *esc_list)
-{
- struct emp_qelem *bomb;
- struct emp_qelem *esc;
- struct plist *bombp;
- struct plist *escp;
-
- if (QEMPTY(bomb_list) || QEMPTY(esc_list))
- return;
- bomb = bomb_list->q_forw;
- while (bomb != bomb_list) {
- if (QEMPTY(esc_list)) {
- bomb = bomb_list;
- continue;
- }
- esc = esc_list->q_forw;
- bombp = (struct plist *)bomb;
- while (esc != esc_list) {
- escp = (struct plist *)esc;
- if (escp->plane.pln_uid == bombp->plane.pln_uid) {
- emp_remque(esc);
- free(esc);
- esc = esc_list;
- } else
- esc = esc->q_forw;
- }
- bomb = bomb->q_forw;
- }
-}
-
/*
* Fit a plane of PP's type on ship SP.
* Adjust SP's plane counters.
struct sctstr *sp = ptr;
struct sctstr sect;
- bridge_damaged(sp, NULL);
+ bridge_damaged(sp);
checksect(sp);
getsect(sp->sct_x, sp->sct_y, §);
return 1;
#include "xy.h"
int
-sect_damage(struct sctstr *sp, int dam, struct emp_qelem *list)
+sect_damage(struct sctstr *sp, int dam)
{
int eff;
if (sp->sct_mobil > 0)
sp->sct_mobil = damage(sp->sct_mobil, dam);
item_damage(dam, sp->sct_item);
- bridge_damaged(sp, list);
+ bridge_damaged(sp);
putsect(sp);
return eff;
}
int
-sectdamage(struct sctstr *sp, int dam, struct emp_qelem *list)
+sectdamage(struct sctstr *sp, int dam)
{
struct nstr_item ni;
struct lndstr land;
/* the damage accordingly. Makes forts a pain */
dam = ldround(dam / sector_strength(sp), 1);
- eff = sect_damage(sp, PERCENT_DAMAGE(dam), list);
+ eff = sect_damage(sp, PERCENT_DAMAGE(dam));
/* Damage all the land units in the sector */
/* Units don't take full damage */
continue;
if (plane.pln_ship >= 0)
continue;
- /* Is this plane flying in this list? */
- if (ac_isflying(&plane, list))
- continue;
planedamage(&plane, dam);
putplane(plane.pln_uid, &plane);
}
wu(0, sp->sct_own,
"Production %s disrupted by terrorists in %s\n",
effadv(n), ownxy(sp));
- sect_damage(sp, n / 10, 0);
+ sect_damage(sp, n / 10);
/*logerror("(#%d) che blew up %s for %d", sp->sct_own, */
/*ownxy(sp), n); */
recruit++;