(buil): Simplify the loop for building multiple units. Unit type
argument "" no longer makes it prompt for the unit type on every iteration.
This commit is contained in:
parent
90bddc6541
commit
2e32b87695
1 changed files with 141 additions and 139 deletions
|
@ -89,8 +89,7 @@ buil(void)
|
||||||
s_char *p;
|
s_char *p;
|
||||||
int gotsect = 0;
|
int gotsect = 0;
|
||||||
int built;
|
int built;
|
||||||
int number = 1, x;
|
int number;
|
||||||
int asked = 0;
|
|
||||||
s_char buf[1024];
|
s_char buf[1024];
|
||||||
|
|
||||||
natp = getnatp(player->cnum);
|
natp = getnatp(player->cnum);
|
||||||
|
@ -101,7 +100,6 @@ buil(void)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
what = *p;
|
what = *p;
|
||||||
|
|
||||||
for (x = 0; x < number; x++) {
|
|
||||||
if (!snxtsct(&nstr, player->argp[2])) {
|
if (!snxtsct(&nstr, player->argp[2])) {
|
||||||
pr("Bad sector specification.\n");
|
pr("Bad sector specification.\n");
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
|
@ -213,21 +211,23 @@ buil(void)
|
||||||
pr("You can't build that!\n");
|
pr("You can't build that!\n");
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
number = 1;
|
||||||
if (what != 'b' && what != 't') {
|
if (what != 'b' && what != 't') {
|
||||||
if (player->argp[4]) {
|
if (player->argp[4]) {
|
||||||
if (atoi(player->argp[4]) > 20 && !asked) {
|
number = atoi(player->argp[4]);
|
||||||
|
if (number > 20) {
|
||||||
s_char bstr[80];
|
s_char bstr[80];
|
||||||
asked = 1;
|
sprintf(bstr,
|
||||||
(void)sprintf(bstr,
|
|
||||||
"Are you sure that you want to build %s of them? ",
|
"Are you sure that you want to build %s of them? ",
|
||||||
player->argp[4]);
|
player->argp[4]);
|
||||||
p = getstarg(player->argp[6], bstr, buf);
|
p = getstarg(player->argp[6], bstr, buf);
|
||||||
if (p == 0 || *p != 'y')
|
if (p == 0 || *p != 'y')
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
}
|
}
|
||||||
number = atoi(player->argp[4]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (what != 'b' && what != 'n' && what != 't') {
|
if (what != 'b' && what != 'n' && what != 't') {
|
||||||
if (player->argp[5]) {
|
if (player->argp[5]) {
|
||||||
tlev = atoi(player->argp[5]);
|
tlev = atoi(player->argp[5]);
|
||||||
|
@ -241,9 +241,10 @@ buil(void)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
pr("building with tech level %d.\n", tlev);
|
pr("building with tech level %d.\n", tlev);
|
||||||
} else
|
|
||||||
tlev = (int)natp->nat_level[NAT_TLEV];
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (number-- > 0) {
|
||||||
while (nxtsct(&nstr, §)) {
|
while (nxtsct(&nstr, §)) {
|
||||||
gotsect++;
|
gotsect++;
|
||||||
if (!player->owner)
|
if (!player->owner)
|
||||||
|
@ -275,6 +276,7 @@ buil(void)
|
||||||
putsect(§);
|
putsect(§);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
snxtsct_rewind(&nstr);
|
||||||
}
|
}
|
||||||
if (!gotsect) {
|
if (!gotsect) {
|
||||||
pr("Bad sector specification.\n");
|
pr("Bad sector specification.\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue