Fix command abortion after getting player input
The old code didn't honor command abortion at the following prompts:
* arm third argument
* deliver fourth argument (also simplify)
* fire third argument
* fly and recon prompt for carrier to land on: pln_onewaymission()
treated abort like empty input, which made planes attempt landing in
the sector.
* lmine second argument
* order d fourth argument
* power c nat(s) argument
* range second argument
* sail second argument
* shutdown both arguments (first one was broken in commit 84cfd670
,
v4.3.10, second one never worked).
* tend third argument
This commit is contained in:
parent
b3a7a8ee11
commit
9eda5f87b8
11 changed files with 51 additions and 32 deletions
|
@ -96,6 +96,8 @@ arm(void)
|
|||
return RET_FAIL;
|
||||
}
|
||||
p = getstarg(player->argp[3], "Airburst [n]? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
|
||||
if (!check_plane_ok(&pl) || !check_nuke_ok(&nuke))
|
||||
return RET_FAIL;
|
||||
|
@ -106,7 +108,7 @@ arm(void)
|
|||
return RET_FAIL;
|
||||
}
|
||||
|
||||
if (p && (*p == 'y' || *p == 'Y'))
|
||||
if (*p == 'y' || *p == 'Y')
|
||||
pl.pln_flags |= PLN_AIRBURST;
|
||||
else
|
||||
pl.pln_flags &= ~PLN_AIRBURST;
|
||||
|
|
|
@ -55,7 +55,7 @@ deli(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
|
||||
while (!player->aborted && nxtsct(&nstr, §) > 0) {
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
|
||||
|
@ -69,15 +69,17 @@ deli(void)
|
|||
if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
|
||||
return RET_SYN;
|
||||
if (*p != 'q') {
|
||||
sprintf(prompt, "%s %s %s direction? ",
|
||||
xyas(nstr.x, nstr.y, player->cnum),
|
||||
dchr[sect.sct_type].d_name, ich->i_name);
|
||||
if (((*p >= '0') && (*p <= '9')) || *p == '+') {
|
||||
thresh = atoi(p) & ~0x7;
|
||||
if (*p == '+')
|
||||
p = NULL;
|
||||
else {
|
||||
sprintf(prompt, "%s %s %s direction? ",
|
||||
xyas(nstr.x, nstr.y, player->cnum),
|
||||
dchr[sect.sct_type].d_name, ich->i_name);
|
||||
p = getstarg(player->argp[4], prompt, buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
}
|
||||
}
|
||||
if (p && *p) {
|
||||
|
|
|
@ -118,10 +118,6 @@ multifire(void)
|
|||
if (!snxtitem(&nbst, type, ptr))
|
||||
return RET_SYN;
|
||||
|
||||
if (player->aborted) {
|
||||
pr("Fire aborted.\n");
|
||||
return RET_OK;
|
||||
}
|
||||
while (nxtitem(&nbst, &item)) {
|
||||
if (type == EF_LAND) {
|
||||
if (!getland(item.land.lnd_uid, &fland))
|
||||
|
@ -220,13 +216,11 @@ multifire(void)
|
|||
fy = fsect.sct_y;
|
||||
}
|
||||
|
||||
if ((ptr = getstarg(player->argp[3], "Firing at? ", buf)) == 0
|
||||
|| *ptr == '\0')
|
||||
ptr = getstarg(player->argp[3], "Firing at? ", buf);
|
||||
if (!ptr)
|
||||
return RET_SYN;
|
||||
if (!*ptr)
|
||||
continue;
|
||||
if (player->aborted) {
|
||||
pr("Fire aborted.\n");
|
||||
continue;
|
||||
}
|
||||
if (!issector(ptr)) {
|
||||
vshipno = atoi(ptr);
|
||||
if (vshipno < 0 || !getship(vshipno, &vship) ||
|
||||
|
|
|
@ -128,9 +128,11 @@ landmine(void)
|
|||
sect.sct_mines, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
sprintf(prompt, "Drop how many mines from %s? ", prland(&land));
|
||||
mines_wanted = onearg(player->argp[2], prompt);
|
||||
if (!check_land_ok(&land))
|
||||
if (mines_wanted < 0)
|
||||
return RET_SYN;
|
||||
if (mines_wanted == 0)
|
||||
continue;
|
||||
if (mines_wanted <= 0)
|
||||
if (!check_land_ok(&land))
|
||||
continue;
|
||||
land.lnd_mission = 0;
|
||||
total_mines_laid = 0;
|
||||
|
|
|
@ -136,7 +136,9 @@ orde(void)
|
|||
|
||||
if (!orders) {
|
||||
p = getstarg(player->argp[4], "Second dest? ", buf);
|
||||
if (!p || !*p || !strcmp(p, "-")) {
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
if (!*p || !strcmp(p, "-")) {
|
||||
orders = 1;
|
||||
pr("A one-way order has been accepted.\n");
|
||||
} else if (!strncmp(p, "s", 1)) {
|
||||
|
|
|
@ -94,7 +94,8 @@ powe(void)
|
|||
|
||||
if (player->argp[i]) {
|
||||
if (player->argp[i][0] == 'c') {
|
||||
snxtitem(&ni, EF_NATION, player->argp[i + 1]);
|
||||
if (!snxtitem(&ni, EF_NATION, player->argp[i + 1]))
|
||||
return RET_SYN;
|
||||
while (nxtitem(&ni, &nat)) {
|
||||
if (nat.nat_stat == STAT_UNUSED)
|
||||
continue;
|
||||
|
|
|
@ -52,9 +52,11 @@ range(void)
|
|||
if (!player->owner || plane.pln_own == 0)
|
||||
continue;
|
||||
p = getstarg(player->argp[2], "New range? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
if (!check_plane_ok(&plane))
|
||||
return RET_SYN;
|
||||
if (!p || (i = atoi(p)) < 0)
|
||||
if ((i = atoi(p)) < 0)
|
||||
continue;
|
||||
rmax = pln_range_max(&plane);
|
||||
plane.pln_range = MIN(rmax, i);
|
||||
|
|
|
@ -110,7 +110,7 @@ cmd_sail_ship(struct nstr_item *nstr)
|
|||
struct shpstr ship;
|
||||
char navpath[MAX_PATH_LEN];
|
||||
|
||||
while (!player->aborted && nxtitem(nstr, &ship)) {
|
||||
while (nxtitem(nstr, &ship)) {
|
||||
if (!player->owner || ship.shp_own == 0)
|
||||
continue;
|
||||
if ((ship.shp_autonav & AN_AUTONAV) &&
|
||||
|
@ -123,13 +123,13 @@ cmd_sail_ship(struct nstr_item *nstr)
|
|||
xyas(ship.shp_x, ship.shp_y, ship.shp_own));
|
||||
cp = getpath(navpath, player->argp[2],
|
||||
ship.shp_x, ship.shp_y, 0, 0, P_SAILING);
|
||||
if (!cp)
|
||||
return RET_SYN;
|
||||
if (!check_ship_ok(&ship))
|
||||
continue;
|
||||
if (!player->aborted) {
|
||||
strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 2);
|
||||
ship.shp_mission = 0;
|
||||
putship(ship.shp_uid, &ship);
|
||||
}
|
||||
strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 2);
|
||||
ship.shp_mission = 0;
|
||||
putship(ship.shp_uid, &ship);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -50,10 +50,15 @@ shut(void)
|
|||
shutdown_minutes =
|
||||
onearg(player->argp[1],
|
||||
"Time until shutdown in minutes (-1 to abort shutdown sequence)? ");
|
||||
if (!updates_disabled())
|
||||
if (!(p = getstarg(player->argp[2], "Disable update [y]? ", buf))
|
||||
|| *p != 'n')
|
||||
if (player->aborted)
|
||||
return RET_SYN;
|
||||
if (!updates_disabled()) {
|
||||
p = getstarg(player->argp[2], "Disable update [y]? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
if (*p != 'n')
|
||||
disa();
|
||||
}
|
||||
|
||||
shutdown_was_pending = shutdown_initiate(shutdown_minutes);
|
||||
if (shutdown_was_pending < 0)
|
||||
|
|
|
@ -90,7 +90,10 @@ tend(void)
|
|||
if (type == EF_LAND) {
|
||||
sprintf(prompt, "Land unit(s) to tend from %s? ",
|
||||
prship(&tender));
|
||||
if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
|
||||
p = getstarg(player->argp[3], prompt, buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
if (!*p)
|
||||
continue;
|
||||
if (!check_ship_ok(&tender))
|
||||
return RET_SYN;
|
||||
|
@ -100,7 +103,10 @@ tend(void)
|
|||
}
|
||||
sprintf(prompt, "Number of %s to tend from %s? ",
|
||||
ip->i_name, prship(&tender));
|
||||
if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
|
||||
p = getstarg(player->argp[3], prompt, buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
if (!*p)
|
||||
continue;
|
||||
if (!check_ship_ok(&tender))
|
||||
return RET_SYN;
|
||||
|
|
|
@ -114,7 +114,10 @@ pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
|
|||
nships = carriersatxy(target->sct_x, target->sct_y, player->cnum);
|
||||
if (nships) {
|
||||
for (;;) {
|
||||
if (!(p = getstarg(0, "Carrier #? ", buf)) || !*p)
|
||||
p = getstring("Carrier #? ", buf);
|
||||
if (!p)
|
||||
return -1;
|
||||
if (!*p)
|
||||
break;
|
||||
cno = atoi(p);
|
||||
if (cno < 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue