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:
parent
57fd96a7cf
commit
4ec6df865b
3 changed files with 10 additions and 12 deletions
|
@ -135,10 +135,10 @@ launch_as(struct plnstr *pp)
|
||||||
struct plnstr plane;
|
struct plnstr plane;
|
||||||
|
|
||||||
cp = getstarg(player->argp[2], "Target satellite? ", buf);
|
cp = getstarg(player->argp[2], "Target satellite? ", buf);
|
||||||
if (!check_plane_ok(pp))
|
|
||||||
return RET_FAIL;
|
|
||||||
if (!cp || !*cp)
|
if (!cp || !*cp)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
if (!check_plane_ok(pp))
|
||||||
|
return RET_FAIL;
|
||||||
if (!getplane(atoi(cp), &plane) || !plane.pln_own
|
if (!getplane(atoi(cp), &plane) || !plane.pln_own
|
||||||
|| !pln_is_in_orbit(&plane)) {
|
|| !pln_is_in_orbit(&plane)) {
|
||||||
pr("No such satellite exists!\n");
|
pr("No such satellite exists!\n");
|
||||||
|
@ -301,10 +301,10 @@ launch_sat(struct plnstr *pp)
|
||||||
|
|
||||||
pr("\n");
|
pr("\n");
|
||||||
cp = getstarg(player->argp[2], "Target sector? ", buf);
|
cp = getstarg(player->argp[2], "Target sector? ", buf);
|
||||||
if (!check_plane_ok(pp))
|
|
||||||
return RET_FAIL;
|
|
||||||
if (!cp || !*cp)
|
if (!cp || !*cp)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
if (!check_plane_ok(pp))
|
||||||
|
return RET_FAIL;
|
||||||
if (!sarg_xy(cp, &sx, &sy)) {
|
if (!sarg_xy(cp, &sx, &sy)) {
|
||||||
pr("Bad sector designation!\n");
|
pr("Bad sector designation!\n");
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
|
|
@ -52,10 +52,10 @@ name(void)
|
||||||
if (!player->owner)
|
if (!player->owner)
|
||||||
continue;
|
continue;
|
||||||
p = getstarg(player->argp[2], "Name? ", buf);
|
p = getstarg(player->argp[2], "Name? ", buf);
|
||||||
if (!check_ship_ok(&ship))
|
|
||||||
return RET_FAIL;
|
|
||||||
if (!p || !*p)
|
if (!p || !*p)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
if (!check_ship_ok(&ship))
|
||||||
|
return RET_FAIL;
|
||||||
if (!strcmp(p, "~")) {
|
if (!strcmp(p, "~")) {
|
||||||
ship.shp_name[0] = 0;
|
ship.shp_name[0] = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -182,11 +182,10 @@ trad(void)
|
||||||
|| (trade.trd_type == EF_NUKE)) {
|
|| (trade.trd_type == EF_NUKE)) {
|
||||||
while (1) {
|
while (1) {
|
||||||
p = getstring("Destination sector: ", buf);
|
p = getstring("Destination sector: ", buf);
|
||||||
|
if (!p)
|
||||||
|
return RET_FAIL;
|
||||||
if (!trade_check_ok(&trade, &tg.gen))
|
if (!trade_check_ok(&trade, &tg.gen))
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
if (!p) {
|
|
||||||
return RET_FAIL;
|
|
||||||
}
|
|
||||||
if (!sarg_xy(p, &sx, &sy) || !getsect(sx, sy, §)) {
|
if (!sarg_xy(p, &sx, &sy) || !getsect(sx, sy, §)) {
|
||||||
pr("Bad sector designation; try again!\n");
|
pr("Bad sector designation; try again!\n");
|
||||||
continue;
|
continue;
|
||||||
|
@ -210,11 +209,10 @@ trad(void)
|
||||||
} else if (trade.trd_type == EF_LAND) {
|
} else if (trade.trd_type == EF_LAND) {
|
||||||
while (1) {
|
while (1) {
|
||||||
p = getstring("Destination sector: ", buf);
|
p = getstring("Destination sector: ", buf);
|
||||||
|
if (!p)
|
||||||
|
return RET_FAIL;
|
||||||
if (!trade_check_ok(&trade, &tg.gen))
|
if (!trade_check_ok(&trade, &tg.gen))
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
if (!p) {
|
|
||||||
return RET_FAIL;
|
|
||||||
}
|
|
||||||
if (!sarg_xy(p, &sx, &sy) || !getsect(sx, sy, §)) {
|
if (!sarg_xy(p, &sx, &sy) || !getsect(sx, sy, §)) {
|
||||||
pr("Bad sector designation; try again!\n");
|
pr("Bad sector designation; try again!\n");
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue