launch name trade: Check for getstarg() failure immediately

Rather than after post-yield sanity checking.  Just to make it obvious
that we are handling getstarg() failure.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2015-01-09 16:25:34 +01:00
parent 57fd96a7cf
commit 4ec6df865b
3 changed files with 10 additions and 12 deletions

View file

@ -135,10 +135,10 @@ launch_as(struct plnstr *pp)
struct plnstr plane;
cp = getstarg(player->argp[2], "Target satellite? ", buf);
if (!check_plane_ok(pp))
return RET_FAIL;
if (!cp || !*cp)
return RET_SYN;
if (!check_plane_ok(pp))
return RET_FAIL;
if (!getplane(atoi(cp), &plane) || !plane.pln_own
|| !pln_is_in_orbit(&plane)) {
pr("No such satellite exists!\n");
@ -301,10 +301,10 @@ launch_sat(struct plnstr *pp)
pr("\n");
cp = getstarg(player->argp[2], "Target sector? ", buf);
if (!check_plane_ok(pp))
return RET_FAIL;
if (!cp || !*cp)
return RET_SYN;
if (!check_plane_ok(pp))
return RET_FAIL;
if (!sarg_xy(cp, &sx, &sy)) {
pr("Bad sector designation!\n");
return RET_SYN;

View file

@ -52,10 +52,10 @@ name(void)
if (!player->owner)
continue;
p = getstarg(player->argp[2], "Name? ", buf);
if (!check_ship_ok(&ship))
return RET_FAIL;
if (!p || !*p)
return RET_SYN;
if (!check_ship_ok(&ship))
return RET_FAIL;
if (!strcmp(p, "~")) {
ship.shp_name[0] = 0;
} else {

View file

@ -182,11 +182,10 @@ trad(void)
|| (trade.trd_type == EF_NUKE)) {
while (1) {
p = getstring("Destination sector: ", buf);
if (!p)
return RET_FAIL;
if (!trade_check_ok(&trade, &tg.gen))
return RET_FAIL;
if (!p) {
return RET_FAIL;
}
if (!sarg_xy(p, &sx, &sy) || !getsect(sx, sy, &sect)) {
pr("Bad sector designation; try again!\n");
continue;
@ -210,11 +209,10 @@ trad(void)
} else if (trade.trd_type == EF_LAND) {
while (1) {
p = getstring("Destination sector: ", buf);
if (!p)
return RET_FAIL;
if (!trade_check_ok(&trade, &tg.gen))
return RET_FAIL;
if (!p) {
return RET_FAIL;
}
if (!sarg_xy(p, &sx, &sy) || !getsect(sx, sy, &sect)) {
pr("Bad sector designation; try again!\n");
continue;