(get_assembly_point): New.
(bomb, drop, fly, para, reco): Use it.
This commit is contained in:
parent
267a9ef424
commit
caac6e41ca
7 changed files with 43 additions and 64 deletions
|
@ -560,6 +560,7 @@ extern int pln_prewrite(int, s_char *);
|
||||||
extern void pln_init(int, s_char *);
|
extern void pln_init(int, s_char *);
|
||||||
/* plnsub.c */
|
/* plnsub.c */
|
||||||
extern void count_planes(struct shpstr *);
|
extern void count_planes(struct shpstr *);
|
||||||
|
extern struct sctstr *get_assembly_point(char *, struct sctstr *, char *);
|
||||||
extern int pln_onewaymission(struct sctstr *, int *, int *);
|
extern int pln_onewaymission(struct sctstr *, int *, int *);
|
||||||
extern int pln_oneway_to_carrier_ok(struct emp_qelem *,
|
extern int pln_oneway_to_carrier_ok(struct emp_qelem *,
|
||||||
struct emp_qelem *, int);
|
struct emp_qelem *, int);
|
||||||
|
|
|
@ -93,7 +93,6 @@ bomb(void)
|
||||||
s_char flightpath[MAX_PATH_LEN];
|
s_char flightpath[MAX_PATH_LEN];
|
||||||
struct nstr_item ni_bomb;
|
struct nstr_item ni_bomb;
|
||||||
struct nstr_item ni_esc;
|
struct nstr_item ni_esc;
|
||||||
coord x, y;
|
|
||||||
struct sctstr target;
|
struct sctstr target;
|
||||||
struct emp_qelem bomb_list;
|
struct emp_qelem bomb_list;
|
||||||
struct emp_qelem esc_list;
|
struct emp_qelem esc_list;
|
||||||
|
@ -116,18 +115,10 @@ bomb(void)
|
||||||
mission = *p;
|
mission = *p;
|
||||||
if (strchr("ps", mission) == 0)
|
if (strchr("ps", mission) == 0)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if ((p = getstarg(player->argp[4], "assembly point? ", buf)) == 0
|
if (!get_assembly_point(player->argp[4], &ap_sect, buf))
|
||||||
|| *p == 0)
|
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if (!sarg_xy(p, &x, &y) || !getsect(x, y, &ap_sect))
|
ax = ap_sect.sct_x;
|
||||||
return RET_SYN;
|
ay = ap_sect.sct_y;
|
||||||
if (ap_sect.sct_own && ap_sect.sct_own != player->cnum &&
|
|
||||||
getrel(getnatp(ap_sect.sct_own), player->cnum) != ALLIED) {
|
|
||||||
pr("Assembly point not owned by you or an ally!\n");
|
|
||||||
return RET_SYN;
|
|
||||||
}
|
|
||||||
ax = x;
|
|
||||||
ay = y;
|
|
||||||
if (getpath(flightpath, player->argp[5], ax, ay, 0, 0, P_FLYING) == 0
|
if (getpath(flightpath, player->argp[5], ax, ay, 0, 0, P_FLYING) == 0
|
||||||
|| *flightpath == 0)
|
|| *flightpath == 0)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
int
|
int
|
||||||
drop(void)
|
drop(void)
|
||||||
{
|
{
|
||||||
s_char *p;
|
|
||||||
int mission_flags;
|
int mission_flags;
|
||||||
coord tx, ty;
|
coord tx, ty;
|
||||||
coord ax, ay;
|
coord ax, ay;
|
||||||
|
@ -56,7 +55,6 @@ drop(void)
|
||||||
s_char flightpath[MAX_PATH_LEN];
|
s_char flightpath[MAX_PATH_LEN];
|
||||||
struct nstr_item ni_bomb;
|
struct nstr_item ni_bomb;
|
||||||
struct nstr_item ni_esc;
|
struct nstr_item ni_esc;
|
||||||
coord x, y;
|
|
||||||
struct sctstr target;
|
struct sctstr target;
|
||||||
struct emp_qelem bomb_list;
|
struct emp_qelem bomb_list;
|
||||||
struct emp_qelem esc_list;
|
struct emp_qelem esc_list;
|
||||||
|
@ -70,18 +68,10 @@ drop(void)
|
||||||
if (!snxtitem(&ni_esc, EF_PLANE,
|
if (!snxtitem(&ni_esc, EF_PLANE,
|
||||||
getstarg(player->argp[2], "escort(s)? ", buf)))
|
getstarg(player->argp[2], "escort(s)? ", buf)))
|
||||||
pr("No escorts...\n");
|
pr("No escorts...\n");
|
||||||
if ((p = getstarg(player->argp[3], "assembly point? ", buf)) == 0
|
if (!get_assembly_point(player->argp[3], &ap_sect, buf))
|
||||||
|| *p == 0)
|
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if (!sarg_xy(p, &x, &y) || !getsect(x, y, &ap_sect))
|
ax = ap_sect.sct_x;
|
||||||
return RET_SYN;
|
ay = ap_sect.sct_y;
|
||||||
if (ap_sect.sct_own && ap_sect.sct_own != player->cnum &&
|
|
||||||
getrel(getnatp(ap_sect.sct_own), player->cnum) != ALLIED) {
|
|
||||||
pr("Assembly point not owned by you or an ally!\n");
|
|
||||||
return RET_SYN;
|
|
||||||
}
|
|
||||||
ax = x;
|
|
||||||
ay = y;
|
|
||||||
if (getpath(flightpath, player->argp[4], ax, ay, 0, 0, P_FLYING) == 0
|
if (getpath(flightpath, player->argp[4], ax, ay, 0, 0, P_FLYING) == 0
|
||||||
|| *flightpath == 0)
|
|| *flightpath == 0)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
int
|
int
|
||||||
fly(void)
|
fly(void)
|
||||||
{
|
{
|
||||||
s_char *p;
|
|
||||||
int mission_flags;
|
int mission_flags;
|
||||||
coord tx, ty;
|
coord tx, ty;
|
||||||
coord ax, ay;
|
coord ax, ay;
|
||||||
|
@ -59,7 +58,6 @@ fly(void)
|
||||||
int cno;
|
int cno;
|
||||||
struct nstr_item ni_bomb;
|
struct nstr_item ni_bomb;
|
||||||
struct nstr_item ni_esc;
|
struct nstr_item ni_esc;
|
||||||
coord x, y;
|
|
||||||
struct sctstr target;
|
struct sctstr target;
|
||||||
struct emp_qelem bomb_list;
|
struct emp_qelem bomb_list;
|
||||||
struct emp_qelem esc_list;
|
struct emp_qelem esc_list;
|
||||||
|
@ -75,18 +73,10 @@ fly(void)
|
||||||
if (!snxtitem(&ni_esc, EF_PLANE,
|
if (!snxtitem(&ni_esc, EF_PLANE,
|
||||||
getstarg(player->argp[2], "escort(s)? ", buf)))
|
getstarg(player->argp[2], "escort(s)? ", buf)))
|
||||||
pr("No escorts...\n");
|
pr("No escorts...\n");
|
||||||
if ((p = getstarg(player->argp[3], "assembly point? ", buf)) == 0
|
if (!get_assembly_point(player->argp[3], &ap_sect, buf))
|
||||||
|| *p == 0)
|
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if (!sarg_xy(p, &x, &y) || !getsect(x, y, &ap_sect))
|
ax = ap_sect.sct_x;
|
||||||
return RET_SYN;
|
ay = ap_sect.sct_y;
|
||||||
if (ap_sect.sct_own && ap_sect.sct_own != player->cnum &&
|
|
||||||
getrel(getnatp(ap_sect.sct_own), player->cnum) != ALLIED) {
|
|
||||||
pr("Assembly point not owned by you or an ally!\n");
|
|
||||||
return RET_SYN;
|
|
||||||
}
|
|
||||||
ax = x;
|
|
||||||
ay = y;
|
|
||||||
if (getpath(flightpath, player->argp[4], ax, ay, 0, 0, P_FLYING) == 0
|
if (getpath(flightpath, player->argp[4], ax, ay, 0, 0, P_FLYING) == 0
|
||||||
|| *flightpath == 0)
|
|| *flightpath == 0)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
|
|
@ -53,7 +53,6 @@ static int paradrop(struct emp_qelem *list, coord x, coord y);
|
||||||
int
|
int
|
||||||
para(void)
|
para(void)
|
||||||
{
|
{
|
||||||
s_char *p;
|
|
||||||
int mission_flags;
|
int mission_flags;
|
||||||
coord tx, ty;
|
coord tx, ty;
|
||||||
coord ax, ay;
|
coord ax, ay;
|
||||||
|
@ -61,7 +60,6 @@ para(void)
|
||||||
s_char flightpath[MAX_PATH_LEN];
|
s_char flightpath[MAX_PATH_LEN];
|
||||||
struct nstr_item ni_bomb;
|
struct nstr_item ni_bomb;
|
||||||
struct nstr_item ni_esc;
|
struct nstr_item ni_esc;
|
||||||
coord x, y;
|
|
||||||
struct sctstr target;
|
struct sctstr target;
|
||||||
struct emp_qelem bomb_list;
|
struct emp_qelem bomb_list;
|
||||||
struct emp_qelem esc_list;
|
struct emp_qelem esc_list;
|
||||||
|
@ -75,18 +73,10 @@ para(void)
|
||||||
if (!snxtitem(&ni_esc, EF_PLANE,
|
if (!snxtitem(&ni_esc, EF_PLANE,
|
||||||
getstarg(player->argp[2], "escort(s)? ", buf)))
|
getstarg(player->argp[2], "escort(s)? ", buf)))
|
||||||
pr("No escorts...\n");
|
pr("No escorts...\n");
|
||||||
if ((p = getstarg(player->argp[3], "assembly point? ", buf)) == 0
|
if (!get_assembly_point(player->argp[3], &ap_sect, buf))
|
||||||
|| *p == 0)
|
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if (!sarg_xy(p, &x, &y) || !getsect(x, y, &ap_sect))
|
ax = ap_sect.sct_x;
|
||||||
return RET_SYN;
|
ay = ap_sect.sct_y;
|
||||||
if (ap_sect.sct_own && ap_sect.sct_own != player->cnum &&
|
|
||||||
getrel(getnatp(ap_sect.sct_own), player->cnum) != ALLIED) {
|
|
||||||
pr("Assembly point not owned by you or an ally!\n");
|
|
||||||
return RET_SYN;
|
|
||||||
}
|
|
||||||
ax = x;
|
|
||||||
ay = y;
|
|
||||||
if (getpath(flightpath, player->argp[4], ax, ay, 0, 0, P_FLYING) == 0
|
if (getpath(flightpath, player->argp[4], ax, ay, 0, 0, P_FLYING) == 0
|
||||||
|| *flightpath == 0)
|
|| *flightpath == 0)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
int
|
int
|
||||||
reco(void)
|
reco(void)
|
||||||
{
|
{
|
||||||
s_char *p;
|
|
||||||
int mission_flags;
|
int mission_flags;
|
||||||
coord tx, ty;
|
coord tx, ty;
|
||||||
coord ax, ay;
|
coord ax, ay;
|
||||||
|
@ -55,7 +54,6 @@ reco(void)
|
||||||
int cno;
|
int cno;
|
||||||
struct nstr_item ni_bomb;
|
struct nstr_item ni_bomb;
|
||||||
struct nstr_item ni_esc;
|
struct nstr_item ni_esc;
|
||||||
coord x, y;
|
|
||||||
struct sctstr target;
|
struct sctstr target;
|
||||||
struct emp_qelem bomb_list;
|
struct emp_qelem bomb_list;
|
||||||
struct emp_qelem esc_list;
|
struct emp_qelem esc_list;
|
||||||
|
@ -69,18 +67,10 @@ reco(void)
|
||||||
if (!snxtitem(&ni_esc, EF_PLANE,
|
if (!snxtitem(&ni_esc, EF_PLANE,
|
||||||
getstarg(player->argp[2], "escort(s)? ", buf)))
|
getstarg(player->argp[2], "escort(s)? ", buf)))
|
||||||
pr("No escorts...\n");
|
pr("No escorts...\n");
|
||||||
if ((p = getstarg(player->argp[3], "assembly point? ", buf)) == 0
|
if (!get_assembly_point(player->argp[3], &ap_sect, buf))
|
||||||
|| *p == 0)
|
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if (!sarg_xy(p, &x, &y) || !getsect(x, y, &ap_sect))
|
ax = ap_sect.sct_x;
|
||||||
return RET_SYN;
|
ay = ap_sect.sct_y;
|
||||||
if (ap_sect.sct_own && ap_sect.sct_own != player->cnum &&
|
|
||||||
getrel(getnatp(ap_sect.sct_own), player->cnum) != ALLIED) {
|
|
||||||
pr("Assembly point not owned by you or an ally!\n");
|
|
||||||
return RET_SYN;
|
|
||||||
}
|
|
||||||
ax = x;
|
|
||||||
ay = y;
|
|
||||||
if (getpath(flightpath, player->argp[4], ax, ay, 0, 0, P_FLYING) == 0
|
if (getpath(flightpath, player->argp[4], ax, ay, 0, 0, P_FLYING) == 0
|
||||||
|| *flightpath == 0)
|
|| *flightpath == 0)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
|
|
@ -51,6 +51,33 @@
|
||||||
|
|
||||||
static int pln_equip(struct plist *, struct ichrstr *, int, s_char);
|
static int pln_equip(struct plist *, struct ichrstr *, int, s_char);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get assembly point argument.
|
||||||
|
* If INPUT is not empty, use it, else prompt for more input using PROMPT.
|
||||||
|
* If this yields a valid assembly point, read it into *AP_SECT and
|
||||||
|
* return AP_SECT.
|
||||||
|
* Else complain and return NULL.
|
||||||
|
* *AP_SECT and BUF[1024] may be modified in either case.
|
||||||
|
*/
|
||||||
|
struct sctstr *
|
||||||
|
get_assembly_point(char *input, struct sctstr *ap_sect, char *buf)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
coord x, y;
|
||||||
|
|
||||||
|
p = getstarg(input, "assembly point? ", buf);
|
||||||
|
if (!p || *p == 0)
|
||||||
|
return NULL;
|
||||||
|
if (!sarg_xy(p, &x, &y) || !getsect(x, y, ap_sect))
|
||||||
|
return NULL;
|
||||||
|
if (ap_sect->sct_own && ap_sect->sct_own != player->cnum &&
|
||||||
|
getrel(getnatp(ap_sect->sct_own), player->cnum) != ALLIED) {
|
||||||
|
pr("Assembly point not owned by you or an ally!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return ap_sect;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
|
pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue