No functional change.
extern int pln_prewrite(int, void *);
/* plnsub.c */
extern void count_planes(struct shpstr *);
+extern int get_planes(struct nstr_item *, struct nstr_item *,
+ char *, char *);
extern struct sctstr *get_assembly_point(char *, struct sctstr *, char *);
extern int pln_onewaymission(struct sctstr *, int *, int *);
extern int pln_oneway_to_carrier_ok(struct emp_qelem *,
char buf[1024];
wantflags = 0;
- if (!snxtitem(&ni_bomb, EF_PLANE, player->argp[1]))
+ if (get_planes(&ni_bomb, &ni_esc, player->argp[1], player->argp[2]) < 0)
return RET_SYN;
- if (!snxtitem(&ni_esc, EF_PLANE,
- getstarg(player->argp[2], "escort(s)? ", buf)))
- pr("No escorts...\n");
p = getstarg(player->argp[3], "pinpoint, or strategic? ", buf);
if (!p || !*p)
return RET_SYN;
char buf[1024];
wantflags = 0;
- if (!snxtitem(&ni_bomb, EF_PLANE, player->argp[1]))
+ if (get_planes(&ni_bomb, &ni_esc, player->argp[1], player->argp[2]) < 0)
return RET_SYN;
- if (!snxtitem(&ni_esc, EF_PLANE,
- getstarg(player->argp[2], "escort(s)? ", buf)))
- pr("No escorts...\n");
if (!get_assembly_point(player->argp[3], &ap_sect, buf))
return RET_SYN;
ax = ap_sect.sct_x;
char buf[1024];
wantflags = 0;
- if (!snxtitem(&ni_bomb, EF_PLANE, player->argp[1]))
+ if (get_planes(&ni_bomb, &ni_esc, player->argp[1], player->argp[2]) < 0)
return RET_SYN;
- if (!snxtitem(&ni_esc, EF_PLANE,
- getstarg(player->argp[2], "escort(s)? ", buf)))
- pr("No escorts...\n");
if (!get_assembly_point(player->argp[3], &ap_sect, buf))
return RET_SYN;
ax = ap_sect.sct_x;
char buf[1024];
wantflags = P_P;
- if (!snxtitem(&ni_bomb, EF_PLANE, player->argp[1]))
+ if (get_planes(&ni_bomb, &ni_esc, player->argp[1], player->argp[2]) < 0)
return RET_SYN;
- if (!snxtitem(&ni_esc, EF_PLANE,
- getstarg(player->argp[2], "escort(s)? ", buf)))
- pr("No escorts...\n");
if (!get_assembly_point(player->argp[3], &ap_sect, buf))
return RET_SYN;
ax = ap_sect.sct_x;
char buf[1024];
wantflags = 0;
- if (!snxtitem(&ni_bomb, EF_PLANE, player->argp[1]))
+ if (get_planes(&ni_bomb, &ni_esc, player->argp[1], player->argp[2]) < 0)
return RET_SYN;
- if (!snxtitem(&ni_esc, EF_PLANE,
- getstarg(player->argp[2], "escort(s)? ", buf)))
- pr("No escorts...\n");
if (!get_assembly_point(player->argp[3], &ap_sect, buf))
return RET_SYN;
ax = ap_sect.sct_x;
static int pln_equip(struct plist *, struct ichrstr *, int, char);
static int fit_plane_on_ship(struct plnstr *, struct shpstr *);
+/*
+ * Get planes and escorts argument.
+ * Read planes into *NI_BOMB, and (optional) escorts into *NI_ESC.
+ * If INPUT_BOMB is not empty, use it, else prompt for more input.
+ * Same for INPUT_ESC.
+ * If we got a plane argument, initialize *NI_BOMB and *NI_ESC, and
+ * return 0.
+ * Else return -1 (*NI_BOMB and *NI_ESC may be modified).
+ */
+int
+get_planes(struct nstr_item *ni_bomb, struct nstr_item *ni_esc,
+ char *input_bomb, char *input_esc)
+{
+ char buf[1024];
+
+ if (!snxtitem(ni_bomb, EF_PLANE, input_bomb))
+ return -1;
+ if (!snxtitem(ni_esc, EF_PLANE,
+ getstarg(input_esc, "escort(s)? ", buf)))
+ pr("No escorts...\n");
+ return 0;
+}
+
/*
* Get assembly point argument.
* If INPUT is not empty, use it, else prompt for more input using PROMPT.