Fail commands properly when they get aborted

The old code didn't return RET_SYN when aborting at the following
prompts:

* designate second argument

* morale second argument

* route second argument

* set third argument

* tend fourth argument

* zdone last argument
This commit is contained in:
Markus Armbruster 2008-07-19 10:00:23 -04:00
parent a7cf69af50
commit be41e70fa8
6 changed files with 14 additions and 12 deletions

View file

@ -60,7 +60,7 @@ desi(void)
natp = getnatp(player->cnum); natp = getnatp(player->cnum);
cap_x = natp->nat_xcap; cap_x = natp->nat_xcap;
cap_y = natp->nat_ycap; cap_y = natp->nat_ycap;
while (!player->aborted && nxtsct(&nstr, &sect)) { while (nxtsct(&nstr, &sect)) {
if (!player->owner) if (!player->owner)
continue; continue;
if (!player->god && dchr[sect.sct_type].d_cost < 0) if (!player->god && dchr[sect.sct_type].d_cost < 0)
@ -68,8 +68,10 @@ desi(void)
sprintf(prompt, "%s %d%% %s desig? ", sprintf(prompt, "%s %d%% %s desig? ",
xyas(sect.sct_x, sect.sct_y, player->cnum), xyas(sect.sct_x, sect.sct_y, player->cnum),
sect.sct_effic, dchr[sect.sct_type].d_name); sect.sct_effic, dchr[sect.sct_type].d_name);
if ((p = getstarg(player->argp[2], prompt, buf)) == 0) if ((p = getstarg(player->argp[2], prompt, buf)) == 0) {
continue; rc = RET_SYN;
break;
}
if (!check_sect_ok(&sect)) if (!check_sect_ok(&sect))
continue; continue;

View file

@ -50,7 +50,7 @@ morale(void)
if (!snxtitem(&np, EF_LAND, player->argp[1])) if (!snxtitem(&np, EF_LAND, player->argp[1]))
return RET_SYN; return RET_SYN;
while (!player->aborted && nxtitem(&np, &land)) { while (nxtitem(&np, &land)) {
if (!player->owner || land.lnd_own == 0) if (!player->owner || land.lnd_own == 0)
continue; continue;
natp = getnatp(land.lnd_own); natp = getnatp(land.lnd_own);
@ -58,11 +58,11 @@ morale(void)
sprintf(mess, "New retreat percentage for %s (min %d%%)? ", sprintf(mess, "New retreat percentage for %s (min %d%%)? ",
prland(&land), min); prland(&land), min);
p = getstarg(player->argp[2], mess, buf); p = getstarg(player->argp[2], mess, buf);
if (!p)
return RET_SYN;
if (!check_land_ok(&land)) if (!check_land_ok(&land))
continue; continue;
if (player->aborted) if ((i = atoi(p)) < 0)
continue;
if (!p || (i = atoi(p)) < 0)
continue; continue;
land.lnd_retreat = ((i < min) ? min : i); land.lnd_retreat = ((i < min) ? min : i);
if (land.lnd_retreat > 100) if (land.lnd_retreat > 100)

View file

@ -66,7 +66,7 @@ rout(void)
return RET_SYN; return RET_SYN;
i_del = ip->i_uid;; i_del = ip->i_uid;;
if (!snxtsct(&ns, player->argp[2])) if (!snxtsct(&ns, player->argp[2]))
return RET_FAIL; return RET_SYN;
if (!mapbuf) if (!mapbuf)
mapbuf = malloc(WORLD_Y * MAPWIDTH(3)); mapbuf = malloc(WORLD_Y * MAPWIDTH(3));
if (!map) { if (!map) {

View file

@ -93,7 +93,7 @@ set(void)
sprintf(prompt, "%s #%d; Price? ", sprintf(prompt, "%s #%d; Price? ",
trade_nameof(&trade, &item), ni.cur); trade_nameof(&trade, &item), ni.cur);
if ((p = getstarg(player->argp[3], prompt, buf)) == 0) if ((p = getstarg(player->argp[3], prompt, buf)) == 0)
break; return RET_SYN;
if (!trade_check_item_ok(&item)) if (!trade_check_item_ok(&item))
return RET_FAIL; return RET_FAIL;
if ((price = atoi(p)) < 0) if ((price = atoi(p)) < 0)

View file

@ -129,7 +129,7 @@ tend(void)
if (!snxtitem(&targets, EF_SHIP, if (!snxtitem(&targets, EF_SHIP,
getstarg(player->argp[4], "Ships to be tended? ", getstarg(player->argp[4], "Ships to be tended? ",
buf))) buf)))
break; return RET_SYN;
if (!check_ship_ok(&tender)) if (!check_ship_ok(&tender))
return RET_SYN; return RET_SYN;
total = 0; total = 0;
@ -231,7 +231,7 @@ tend_land(struct shpstr *tenderp, char *units)
if (!snxtitem(&targets, EF_SHIP, if (!snxtitem(&targets, EF_SHIP,
getstarg(player->argp[4], "Ship to be tended? ", getstarg(player->argp[4], "Ship to be tended? ",
buf))) buf)))
break; return RET_SYN;
if (!check_land_ok(&land)) if (!check_land_ok(&land))
return RET_SYN; return RET_SYN;
while (nxtitem(&targets, &target)) { while (nxtitem(&targets, &target)) {

View file

@ -87,7 +87,7 @@ zdon(void)
p = getstarg(player->argp[1], "Want update? [Yes|No|Check] ", buf); p = getstarg(player->argp[1], "Want update? [Yes|No|Check] ", buf);
} }
if (player->aborted) if (player->aborted)
return RET_FAIL; return RET_SYN;
checking = 1; checking = 1;
wantupd = 0; wantupd = 0;