Avoids reading the target ship again.
char *, char *);
extern struct sctstr *get_assembly_point(char *, struct sctstr *, char *);
extern int pln_where_to_land(coord, coord, union empobj_storage *, int *);
-extern int pln_oneway_to_carrier_ok(struct emp_qelem *,
- struct emp_qelem *, int);
+extern int pln_can_land_on_carrier(struct emp_qelem *, struct emp_qelem *,
+ struct shpstr *);
extern void pln_newlanding(struct emp_qelem *, coord, coord, int);
extern int could_be_on_ship(struct plnstr *, struct shpstr *);
extern int put_plane_on_ship(struct plnstr *, struct shpstr *);
wantflags, P_M | P_O);
pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 1,
wantflags | P_ESC | P_F, P_M | P_O);
- if (cno >= 0 && !pln_oneway_to_carrier_ok(&bomb_list, &esc_list, cno)) {
+ if (cno >= 0
+ && !pln_can_land_on_carrier(&bomb_list, &esc_list, &target.ship)) {
pr("Not enough room on ship #%d!\n", cno);
return RET_FAIL;
}
P_M | P_O);
pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 1,
wantflags | P_ESC | P_F, P_M | P_O);
- if (cno >= 0 && !pln_oneway_to_carrier_ok(&bomb_list, &esc_list, cno)) {
+ if (cno >= 0
+ && !pln_can_land_on_carrier(&bomb_list, &esc_list, &target.ship)) {
pr("Not enough room on ship #%d!\n", cno);
return RET_FAIL;
}
}
int
-pln_oneway_to_carrier_ok(struct emp_qelem *bomb_list,
- struct emp_qelem *esc_list, int cno)
+pln_can_land_on_carrier(struct emp_qelem *bomb_list,
+ struct emp_qelem *esc_list,
+ struct shpstr *sp)
+
{
int n, nch, nxl, nmsl;
struct emp_qelem *list, *qp;
struct plist *plp;
- struct shpstr ship;
- if (cno < 0 || !getship(cno, &ship))
- return 0;
- n = shp_nplane(&ship, &nch, &nxl, &nmsl);
+ n = shp_nplane(sp, &nch, &nxl, &nmsl);
/* for both lists */
for (list = bomb_list;
list = list == bomb_list ? esc_list : NULL) {
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
plp = (struct plist *)qp;
- if (plp->plane.pln_ship == ship.shp_uid)
+ if (plp->plane.pln_ship == sp->shp_uid)
continue;
n++;
if (!inc_shp_nplane(&plp->plane, &nch, &nxl, &nmsl))
return 0;
}
}
- return ship_can_carry(&ship, n, nch, nxl, nmsl);
+ return ship_can_carry(sp, n, nch, nxl, nmsl);
}
void