Replace pln_oneway_to_carrier_ok() by pln_can_land_on_carrier()
Avoids reading the target ship again.
This commit is contained in:
parent
d9a915a05b
commit
b4acb73fd1
4 changed files with 13 additions and 12 deletions
|
@ -505,8 +505,8 @@ extern int get_planes(struct nstr_item *, struct nstr_item *,
|
||||||
char *, char *);
|
char *, char *);
|
||||||
extern struct sctstr *get_assembly_point(char *, struct sctstr *, 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_where_to_land(coord, coord, union empobj_storage *, int *);
|
||||||
extern int pln_oneway_to_carrier_ok(struct emp_qelem *,
|
extern int pln_can_land_on_carrier(struct emp_qelem *, struct emp_qelem *,
|
||||||
struct emp_qelem *, int);
|
struct shpstr *);
|
||||||
extern void pln_newlanding(struct emp_qelem *, coord, coord, int);
|
extern void pln_newlanding(struct emp_qelem *, coord, coord, int);
|
||||||
extern int could_be_on_ship(struct plnstr *, struct shpstr *);
|
extern int could_be_on_ship(struct plnstr *, struct shpstr *);
|
||||||
extern int put_plane_on_ship(struct plnstr *, struct shpstr *);
|
extern int put_plane_on_ship(struct plnstr *, struct shpstr *);
|
||||||
|
|
|
@ -98,7 +98,8 @@ fly(void)
|
||||||
wantflags, P_M | P_O);
|
wantflags, P_M | P_O);
|
||||||
pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 1,
|
pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 1,
|
||||||
wantflags | P_ESC | P_F, P_M | P_O);
|
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);
|
pr("Not enough room on ship #%d!\n", cno);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,8 @@ reco(void)
|
||||||
P_M | P_O);
|
P_M | P_O);
|
||||||
pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 1,
|
pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 1,
|
||||||
wantflags | P_ESC | P_F, P_M | P_O);
|
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);
|
pr("Not enough room on ship #%d!\n", cno);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,17 +184,16 @@ pln_where_to_land(coord x, coord y,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pln_oneway_to_carrier_ok(struct emp_qelem *bomb_list,
|
pln_can_land_on_carrier(struct emp_qelem *bomb_list,
|
||||||
struct emp_qelem *esc_list, int cno)
|
struct emp_qelem *esc_list,
|
||||||
|
struct shpstr *sp)
|
||||||
|
|
||||||
{
|
{
|
||||||
int n, nch, nxl, nmsl;
|
int n, nch, nxl, nmsl;
|
||||||
struct emp_qelem *list, *qp;
|
struct emp_qelem *list, *qp;
|
||||||
struct plist *plp;
|
struct plist *plp;
|
||||||
struct shpstr ship;
|
|
||||||
|
|
||||||
if (cno < 0 || !getship(cno, &ship))
|
n = shp_nplane(sp, &nch, &nxl, &nmsl);
|
||||||
return 0;
|
|
||||||
n = shp_nplane(&ship, &nch, &nxl, &nmsl);
|
|
||||||
|
|
||||||
/* for both lists */
|
/* for both lists */
|
||||||
for (list = bomb_list;
|
for (list = bomb_list;
|
||||||
|
@ -202,14 +201,14 @@ pln_oneway_to_carrier_ok(struct emp_qelem *bomb_list,
|
||||||
list = list == bomb_list ? esc_list : NULL) {
|
list = list == bomb_list ? esc_list : NULL) {
|
||||||
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
|
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
|
||||||
plp = (struct plist *)qp;
|
plp = (struct plist *)qp;
|
||||||
if (plp->plane.pln_ship == ship.shp_uid)
|
if (plp->plane.pln_ship == sp->shp_uid)
|
||||||
continue;
|
continue;
|
||||||
n++;
|
n++;
|
||||||
if (!inc_shp_nplane(&plp->plane, &nch, &nxl, &nmsl))
|
if (!inc_shp_nplane(&plp->plane, &nch, &nxl, &nmsl))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ship_can_carry(&ship, n, nch, nxl, nmsl);
|
return ship_can_carry(sp, n, nch, nxl, nmsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue