(march): Reorganize, use parse() to split arguments.
These changes are based on improvements made in navi().
This commit is contained in:
parent
6a07beb3cb
commit
fa90c1921f
1 changed files with 60 additions and 52 deletions
|
@ -54,8 +54,8 @@ march(void)
|
||||||
struct emp_qelem land_list;
|
struct emp_qelem land_list;
|
||||||
double minmob, maxmob;
|
double minmob, maxmob;
|
||||||
int together;
|
int together;
|
||||||
char *cp = 0;
|
char *cp = NULL;
|
||||||
struct lndstr *lnd = 0; /* leader */
|
struct lndstr *lnd = NULL; /* leader */
|
||||||
struct nstr_sect ns;
|
struct nstr_sect ns;
|
||||||
char origin;
|
char origin;
|
||||||
int dir;
|
int dir;
|
||||||
|
@ -63,6 +63,9 @@ march(void)
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char prompt[128];
|
char prompt[128];
|
||||||
|
char scanspace[1024];
|
||||||
|
char bmap_flag;
|
||||||
|
int ac;
|
||||||
|
|
||||||
if (!snxtitem(&ni_land, EF_LAND, player->argp[1]))
|
if (!snxtitem(&ni_land, EF_LAND, player->argp[1]))
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
@ -80,9 +83,9 @@ march(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!QEMPTY(&land_list)) {
|
while (!QEMPTY(&land_list)) {
|
||||||
char *bp, dp[80];
|
char dp[80];
|
||||||
|
|
||||||
if (cp == 0 || *cp == '\0' || stopping) {
|
if (cp == NULL || *cp == '\0' || stopping) {
|
||||||
stopping = 0;
|
stopping = 0;
|
||||||
lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
|
lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
|
||||||
if (QEMPTY(&land_list)) {
|
if (QEMPTY(&land_list)) {
|
||||||
|
@ -115,63 +118,68 @@ march(void)
|
||||||
if (cp && !(cp = lnd_path(together, lnd, buf)))
|
if (cp && !(cp = lnd_path(together, lnd, buf)))
|
||||||
cp = buf;
|
cp = buf;
|
||||||
}
|
}
|
||||||
if (cp == 0 || *cp == '\0')
|
if (cp == NULL || *cp == '\0')
|
||||||
cp = &dirch[DIR_STOP];
|
cp = &dirch[DIR_STOP];
|
||||||
if (*cp == 'M' ||
|
dir = chkdir(*cp, DIR_STOP, DIR_LAST);
|
||||||
*cp == 'B' || *cp == 'f' || *cp == 'i' || *cp == 'm') {
|
if (dir >= 0) {
|
||||||
++cp;
|
stopping |=
|
||||||
if (cp[-1] == 'M') {
|
lnd_mar_one_sector(&land_list, dir, player->cnum, together);
|
||||||
unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
|
cp++;
|
||||||
draw_map(0, origin, 0, &ns);
|
continue;
|
||||||
skip = 1;
|
}
|
||||||
} else if (cp[-1] == 'B') {
|
ac = parse(cp, player->argp, NULL, scanspace, NULL);
|
||||||
unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
|
if (ac <= 1) {
|
||||||
draw_map('b', origin, 0, &ns);
|
sprintf(dp, "%d", lnd->lnd_uid);
|
||||||
skip = 1;
|
player->argp[1] = dp;
|
||||||
} else if (cp[-1] == 'f') {
|
cp++;
|
||||||
|
} else
|
||||||
|
cp = NULL;
|
||||||
|
bmap_flag = 0;
|
||||||
|
switch (*player->argp[0]) {
|
||||||
|
case 'B':
|
||||||
|
bmap_flag = 'b';
|
||||||
|
/*
|
||||||
|
* fall through
|
||||||
|
*/
|
||||||
|
case 'M':
|
||||||
|
unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
|
||||||
|
draw_map(bmap_flag, origin, 0, &ns);
|
||||||
|
skip = 1;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
{
|
||||||
struct emp_qelem *qp;
|
struct emp_qelem *qp;
|
||||||
|
|
||||||
qp = land_list.q_back;
|
qp = land_list.q_back;
|
||||||
emp_remque(land_list.q_back);
|
emp_remque(land_list.q_back);
|
||||||
emp_insque(qp, &land_list);
|
emp_insque(qp, &land_list);
|
||||||
set_leader(&land_list, &lnd);
|
set_leader(&land_list, &lnd);
|
||||||
} else if (cp[-1] == 'i') {
|
|
||||||
lnd_list(&land_list);
|
|
||||||
} else {
|
|
||||||
lnd_sweep(&land_list, 1, 1, player->cnum);
|
|
||||||
stopping |= lnd_check_mines(&land_list);
|
|
||||||
}
|
}
|
||||||
continue;
|
break;
|
||||||
} else if (*cp == 'r' || *cp == 'l') {
|
case 'i':
|
||||||
for (bp = cp + 1; *bp && !isspace(*bp); bp++) ;
|
lnd_list(&land_list);
|
||||||
for (; *bp && isspace(*bp); bp++) ;
|
break;
|
||||||
if (*bp)
|
case 'm':
|
||||||
player->argp[1] = bp;
|
lnd_sweep(&land_list, 1, 1, player->cnum);
|
||||||
else {
|
stopping |= lnd_check_mines(&land_list);
|
||||||
sprintf(dp, "%d", lnd->lnd_uid);
|
break;
|
||||||
player->argp[1] = dp;
|
case 'r':
|
||||||
}
|
player->argp[0] = "lradar";
|
||||||
if (*cp++ == 'r') {
|
rada();
|
||||||
player->argp[0] = "lradar";
|
skip = 1;
|
||||||
rada();
|
|
||||||
skip = 1;
|
|
||||||
} else
|
|
||||||
llook();
|
|
||||||
*cp = 0;
|
|
||||||
player->btused++;
|
player->btused++;
|
||||||
continue;
|
break;
|
||||||
} else {
|
case 'l':
|
||||||
dir = chkdir(*cp++, DIR_STOP, DIR_LAST);
|
llook();
|
||||||
if (dir < 0) {
|
player->btused++;
|
||||||
direrr("`%c' to stop", 0, 0);
|
break;
|
||||||
pr(", `i' to list units, `f' to change leader,\n");
|
default:
|
||||||
pr("`r' to radar, `l' to look, `M' to map, `B' to bmap,\n");
|
direrr("`%c' to stop", 0, 0);
|
||||||
pr("and `m' to minesweep\n");
|
pr(", `i' to list units, `f' to change leader,\n");
|
||||||
stopping = 1;
|
pr("`r' to radar, `l' to look, `M' to map, `B' to bmap,\n");
|
||||||
continue;
|
pr("and `m' to minesweep\n");
|
||||||
}
|
stopping = 1;
|
||||||
}
|
}
|
||||||
stopping |=
|
|
||||||
lnd_mar_one_sector(&land_list, dir, player->cnum, together);
|
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue