Clean up more unreadable assignments within if conditionals
This commit is contained in:
parent
6459cfce7b
commit
a2ed975ec2
19 changed files with 92 additions and 81 deletions
|
@ -65,9 +65,8 @@ boar(void)
|
|||
*/
|
||||
|
||||
/* What are we boarding? */
|
||||
|
||||
if (!(p = getstarg(player->argp[1], "Victim ship #? ", buf)) ||
|
||||
(def->shp_uid = atoi(p)) < 0)
|
||||
p = getstarg(player->argp[1], "Victim ship #? ", buf);
|
||||
if (!p || (def->shp_uid = atoi(p)) < 0)
|
||||
return RET_SYN;
|
||||
|
||||
/*
|
||||
|
|
|
@ -66,7 +66,8 @@ deli(void)
|
|||
sprintf(prompt, "%s %s %s threshold or direction or 'query'? ",
|
||||
xyas(nstr.x, nstr.y, player->cnum),
|
||||
dchr[sect.sct_type].d_name, ich->i_name);
|
||||
if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
|
||||
p = getstarg(player->argp[3], prompt, buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
if (*p != 'q') {
|
||||
if (((*p >= '0') && (*p <= '9')) || *p == '+') {
|
||||
|
|
|
@ -60,7 +60,8 @@ grin(void)
|
|||
return RET_SYN;
|
||||
if (!snxtsct(&nstr, p))
|
||||
return RET_SYN;
|
||||
if ((p = getstarg(player->argp[2], "amount : ", buf)) == 0 || *p == 0)
|
||||
p = getstarg(player->argp[2], "amount : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
qty = atoi(p);
|
||||
if (qty < 0)
|
||||
|
|
|
@ -58,8 +58,8 @@ hard(void)
|
|||
|
||||
if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
|
||||
return RET_SYN;
|
||||
if ((p = getstarg(player->argp[2], "Increase by? ", buf)) == 0
|
||||
|| *p == 0)
|
||||
p = getstarg(player->argp[2], "Increase by? ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
level = atoi(p);
|
||||
if (level < 0)
|
||||
|
|
|
@ -92,7 +92,8 @@ improve(void)
|
|||
sprintf(prompt, "Sector %s has a %s of %d%%. Improve how much? ",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum),
|
||||
intrchr[type].in_name, value);
|
||||
if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
|
||||
p = getstarg(player->argp[3], prompt, buf);
|
||||
if (!p || !*p)
|
||||
continue;
|
||||
if (!check_sect_ok(§))
|
||||
continue;
|
||||
|
|
|
@ -61,9 +61,8 @@ lboa(void)
|
|||
*/
|
||||
|
||||
/* What are we boarding? */
|
||||
|
||||
if (!(p = getstarg(player->argp[1], "Victim land unit #? ", buf)) ||
|
||||
(def->lnd_uid = atoi(p)) < 0)
|
||||
p = getstarg(player->argp[1], "Victim land unit #? ", buf);
|
||||
if (!p || (def->lnd_uid = atoi(p)) < 0)
|
||||
return RET_SYN;
|
||||
|
||||
/*
|
||||
|
|
|
@ -83,9 +83,9 @@ load(void)
|
|||
char *p;
|
||||
char buf[1024];
|
||||
|
||||
if (!(p = getstarg(player->argp[1],
|
||||
"What commodity (or 'plane' or 'land')? ", buf))
|
||||
|| !*p)
|
||||
p = getstarg(player->argp[1],
|
||||
"What commodity (or 'plane' or 'land')? ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
|
||||
if (!strncmp(p, "plane", 5))
|
||||
|
@ -99,7 +99,8 @@ load(void)
|
|||
return RET_SYN;
|
||||
}
|
||||
|
||||
if (!(p = getstarg(player->argp[2], "Ship(s): ", buf)) || !*p)
|
||||
p = getstarg(player->argp[2], "Ship(s): ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
|
||||
noisy = isdigit(*p);
|
||||
|
@ -216,9 +217,9 @@ lload(void)
|
|||
char *p;
|
||||
char buf[1024];
|
||||
|
||||
if (!(p = getstarg(player->argp[1],
|
||||
"What commodity (or 'plane' or 'land')? ", buf))
|
||||
|| !*p)
|
||||
p = getstarg(player->argp[1],
|
||||
"What commodity (or 'plane' or 'land')? ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
if (!strncmp(p, "plane", 5))
|
||||
type = EF_PLANE;
|
||||
|
@ -231,7 +232,8 @@ lload(void)
|
|||
return RET_SYN;
|
||||
}
|
||||
|
||||
if (!(p = getstarg(player->argp[2], "Unit(s): ", buf)) || !*p)
|
||||
p = getstarg(player->argp[2], "Unit(s): ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
|
||||
noisy = isdigit(*p);
|
||||
|
@ -691,7 +693,8 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
|
|||
(load_unload == UNLOAD) ?
|
||||
"unload from" : "load onto",
|
||||
prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
|
||||
if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
|
||||
p = getstarg(player->argp[3], prompt, buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
|
||||
if (!still_ok_ship(sectp, sp))
|
||||
|
@ -852,7 +855,8 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
|
|||
(load_unload == UNLOAD) ?
|
||||
"unload from" : "load onto",
|
||||
prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
|
||||
if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
|
||||
p = getstarg(player->argp[3], prompt, buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
|
||||
if (!still_ok_land(sectp, lp))
|
||||
|
|
|
@ -149,8 +149,8 @@ mission(void)
|
|||
return RET_FAIL;
|
||||
}
|
||||
|
||||
if ((p = getstarg(player->argp[4], "operations point? ", buf)) == 0
|
||||
|| *p == 0)
|
||||
p = getstarg(player->argp[4], "operations point? ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
|
||||
if (*p != '.') {
|
||||
|
|
|
@ -48,7 +48,8 @@ offe(void)
|
|||
char *cp;
|
||||
char buf[1024];
|
||||
|
||||
if (!(cp = getstarg(player->argp[1], "loan or treaty? ", buf)) || !*cp)
|
||||
cp = getstarg(player->argp[1], "loan or treaty? ", buf);
|
||||
if (!cp || !*cp)
|
||||
return RET_SYN;
|
||||
|
||||
switch (*cp) {
|
||||
|
|
|
@ -124,8 +124,8 @@ orde(void)
|
|||
orders = 0;
|
||||
scuttling = 0;
|
||||
/* Need location */
|
||||
if ((p = getstarg(player->argp[3], "Destination? ", buf)) == 0
|
||||
|| *p == 0)
|
||||
p = getstarg(player->argp[3], "Destination? ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
if (!sarg_xy(p, &p0x, &p0y))
|
||||
return RET_SYN;
|
||||
|
|
|
@ -61,8 +61,8 @@ rese(void)
|
|||
}
|
||||
check_market();
|
||||
check_trade();
|
||||
if ((p = getstarg(player->argp[1], "Which lot : ", buf)) == 0
|
||||
|| *p == 0)
|
||||
p = getstarg(player->argp[1], "Which lot : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
number_set = atoi(p);
|
||||
getcomm(number_set, &comm);
|
||||
|
@ -74,8 +74,8 @@ rese(void)
|
|||
pr("Some one already has a bid out on that\n");
|
||||
return RET_OK;
|
||||
}
|
||||
if ((p = getstarg(player->argp[2], "New (lower) price: ", buf)) == 0
|
||||
|| *p == 0)
|
||||
p = getstarg(player->argp[2], "New (lower) price: ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
if (!check_comm_ok(&comm))
|
||||
return RET_FAIL;
|
||||
|
|
|
@ -96,8 +96,8 @@ rout(void)
|
|||
if (!player->owner)
|
||||
continue;
|
||||
p = &map[ns.dy][ns.dx * 2];
|
||||
if ((dir = sect.sct_del[i_del] & 0x7) &&
|
||||
nstr_exec(cond, ncond, §))
|
||||
dir = sect.sct_del[i_del] & 0x7;
|
||||
if (dir && nstr_exec(cond, ncond, §))
|
||||
memcpy(p, routech[dir], 3);
|
||||
p[1] = dchr[sect.sct_type].d_mnem;
|
||||
}
|
||||
|
|
|
@ -100,13 +100,14 @@ sell(void)
|
|||
return RET_FAIL;
|
||||
}
|
||||
number_sub = 0;
|
||||
if ((p = getstarg(player->argp[3], "Quantity: ", buf)) == 0 || *p == 0)
|
||||
p = getstarg(player->argp[3], "Quantity: ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
if (!check_sect_ok(§))
|
||||
return RET_FAIL;
|
||||
number_set = atoi(p);
|
||||
if ((p = getstarg(player->argp[4], "Price per unit: ", buf)) == 0 ||
|
||||
*p == 0)
|
||||
p = getstarg(player->argp[4], "Price per unit: ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
if (!check_sect_ok(§))
|
||||
return RET_FAIL;
|
||||
|
|
|
@ -60,8 +60,8 @@ setres(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
if (amt > 100)
|
||||
|
@ -79,8 +79,8 @@ setres(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
if (amt > 100)
|
||||
|
@ -98,8 +98,8 @@ setres(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
if (amt > 100)
|
||||
|
@ -116,8 +116,8 @@ setres(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
if (amt > 100)
|
||||
|
@ -135,8 +135,8 @@ setres(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
if (amt > 100)
|
||||
|
|
|
@ -67,8 +67,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_min;
|
||||
|
@ -88,8 +88,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_gmin;
|
||||
|
@ -111,8 +111,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf))
|
||||
|| (*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_oil;
|
||||
|
@ -132,8 +132,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf))
|
||||
|| (*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
if ((amt < 0) || (amt > MAXNOC - 1))
|
||||
|
@ -158,8 +158,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf))
|
||||
|| (*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
if ((amt < 0) || (amt > MAXNOC - 1))
|
||||
|
@ -181,8 +181,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_effic;
|
||||
|
@ -203,8 +203,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf))
|
||||
|| (*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_mines;
|
||||
|
@ -223,8 +223,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf))
|
||||
|| (*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_mobil;
|
||||
|
@ -248,8 +248,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_avail;
|
||||
|
@ -268,8 +268,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_work;
|
||||
|
@ -288,8 +288,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_fertil;
|
||||
|
@ -309,8 +309,8 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
|
||||
(*p == '\0'))
|
||||
p = getstarg(player->argp[3], "What value : ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
current = sect.sct_uran;
|
||||
|
|
|
@ -50,10 +50,10 @@ show(void)
|
|||
char buf[1024];
|
||||
int rlev;
|
||||
|
||||
if (!(p = getstarg(player->argp[1],
|
||||
p = getstarg(player->argp[1],
|
||||
"Show what (bridge, item, land, nuke, plane, sect, ship, tower, updates)? ",
|
||||
buf))
|
||||
|| !*p)
|
||||
buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
|
||||
natp = getnatp(player->cnum);
|
||||
|
@ -124,9 +124,9 @@ show(void)
|
|||
return RET_SYN;
|
||||
}
|
||||
|
||||
if (!(p = getstarg(player->argp[2],
|
||||
"Build, stats, or capability data (b,s,c)? ", buf))
|
||||
|| !*p)
|
||||
p = getstarg(player->argp[2],
|
||||
"Build, stats, or capability data (b,s,c)? ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
pr("Printing for tech level '%d'\n", tlev);
|
||||
if (*p == 'B' || *p == 'b')
|
||||
|
|
|
@ -67,8 +67,9 @@ tend(void)
|
|||
char prompt[512];
|
||||
char buf[1024];
|
||||
|
||||
if (!(p = getstarg(player->argp[1],
|
||||
"Tend what commodity (or 'land')? ", buf)) || !*p)
|
||||
p = getstarg(player->argp[1], "Tend what commodity (or 'land')? ",
|
||||
buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
|
||||
if (!strncmp(p, "land", 4))
|
||||
|
|
|
@ -114,7 +114,8 @@ trad(void)
|
|||
pr("Nothing to buy at the moment...\n");
|
||||
return RET_OK;
|
||||
}
|
||||
if ((p = getstring("Which lot to buy: ", buf)) == 0 || *p == 0)
|
||||
p = getstring("Which lot to buy: ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_OK;
|
||||
if (isdigit(*p) == 0)
|
||||
return RET_OK;
|
||||
|
@ -239,7 +240,8 @@ trad(void)
|
|||
}
|
||||
}
|
||||
|
||||
if ((p = getstring("How much do you bid: ", buf)) == 0 || *p == 0)
|
||||
p = getstring("How much do you bid: ", buf);
|
||||
if (!p || !*p)
|
||||
return RET_OK;
|
||||
if (!trade_check_ok(&trade, &tg))
|
||||
return RET_FAIL;
|
||||
|
|
|
@ -2450,7 +2450,8 @@ ask_move_in_off(struct combat *off, struct combat *def)
|
|||
return;
|
||||
sprintf(prompt, "How many mil to move in from %s (%d max)? ",
|
||||
xyas(off->x, off->y, player->cnum), mob_support);
|
||||
if (!(p = getstring(prompt, buf)) || !*p || (num_mil = atoi(p)) <= 0)
|
||||
p = getstring(prompt, buf);
|
||||
if (!p || !*p || (num_mil = atoi(p)) <= 0)
|
||||
return;
|
||||
/* Make sure we don't move in more than we can support mobility-wise */
|
||||
if (num_mil > mob_support)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue