(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;
|
||||
int gotsect = 0;
|
||||
int built;
|
||||
int number = 1, x;
|
||||
int asked = 0;
|
||||
int number;
|
||||
s_char buf[1024];
|
||||
|
||||
natp = getnatp(player->cnum);
|
||||
|
@ -101,7 +100,6 @@ buil(void)
|
|||
return RET_SYN;
|
||||
what = *p;
|
||||
|
||||
for (x = 0; x < number; x++) {
|
||||
if (!snxtsct(&nstr, player->argp[2])) {
|
||||
pr("Bad sector specification.\n");
|
||||
return RET_SYN;
|
||||
|
@ -213,21 +211,23 @@ buil(void)
|
|||
pr("You can't build that!\n");
|
||||
return RET_SYN;
|
||||
}
|
||||
|
||||
number = 1;
|
||||
if (what != 'b' && what != 't') {
|
||||
if (player->argp[4]) {
|
||||
if (atoi(player->argp[4]) > 20 && !asked) {
|
||||
number = atoi(player->argp[4]);
|
||||
if (number > 20) {
|
||||
s_char bstr[80];
|
||||
asked = 1;
|
||||
(void)sprintf(bstr,
|
||||
sprintf(bstr,
|
||||
"Are you sure that you want to build %s of them? ",
|
||||
player->argp[4]);
|
||||
p = getstarg(player->argp[6], bstr, buf);
|
||||
if (p == 0 || *p != 'y')
|
||||
return RET_SYN;
|
||||
}
|
||||
number = atoi(player->argp[4]);
|
||||
}
|
||||
}
|
||||
|
||||
if (what != 'b' && what != 'n' && what != 't') {
|
||||
if (player->argp[5]) {
|
||||
tlev = atoi(player->argp[5]);
|
||||
|
@ -241,9 +241,10 @@ buil(void)
|
|||
return RET_FAIL;
|
||||
}
|
||||
pr("building with tech level %d.\n", tlev);
|
||||
} else
|
||||
tlev = (int)natp->nat_level[NAT_TLEV];
|
||||
}
|
||||
}
|
||||
|
||||
while (number-- > 0) {
|
||||
while (nxtsct(&nstr, §)) {
|
||||
gotsect++;
|
||||
if (!player->owner)
|
||||
|
@ -275,6 +276,7 @@ buil(void)
|
|||
putsect(§);
|
||||
}
|
||||
}
|
||||
snxtsct_rewind(&nstr);
|
||||
}
|
||||
if (!gotsect) {
|
||||
pr("Bad sector specification.\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue