Simplify best() and torp()

Use snxtsct_rewind() instead of snxtsct(), and snxtitem_rewind()
instead of snxtitem().
This commit is contained in:
Markus Armbruster 2008-07-20 16:45:38 -04:00
parent 90ba9608cb
commit 7d529769de
2 changed files with 5 additions and 5 deletions

View file

@ -54,7 +54,7 @@ best(void)
while (!player->aborted && nxtsct(&nstr, &s1)) { while (!player->aborted && nxtsct(&nstr, &s1)) {
if (s1.sct_own != player->cnum) if (s1.sct_own != player->cnum)
continue; continue;
snxtsct(&nstr2, player->argp[2]); snxtsct_rewind(&nstr2);
while (!player->aborted && nxtsct(&nstr2, &s2)) { while (!player->aborted && nxtsct(&nstr2, &s2)) {
if (s2.sct_own != player->cnum) if (s2.sct_own != player->cnum)
continue; continue;

View file

@ -62,13 +62,13 @@ torp(void)
char *ptr; char *ptr;
struct nstr_item nbst; struct nstr_item nbst;
char buf[1024]; char buf[1024];
char *sav; char *p;
int ntorping = 0; int ntorping = 0;
char prompt[128]; char prompt[128];
if (!(sav = getstarg(player->argp[1], "From ship(s)? ", buf))) if (!(p = getstarg(player->argp[1], "From ship(s)? ", buf)))
return RET_SYN; return RET_SYN;
if (!snxtitem(&nbst, EF_SHIP, sav)) if (!snxtitem(&nbst, EF_SHIP, p))
return RET_SYN; return RET_SYN;
while (nxtitem(&nbst, &sub)) { while (nxtitem(&nbst, &sub)) {
if (sub.shp_own != player->cnum) if (sub.shp_own != player->cnum)
@ -87,7 +87,7 @@ torp(void)
ntorping++; ntorping++;
} }
pr("%d ships are eligible to torp\n", ntorping); pr("%d ships are eligible to torp\n", ntorping);
snxtitem(&nbst, EF_SHIP, sav); snxtitem_rewind(&nbst);
while (nxtitem(&nbst, &sub)) { while (nxtitem(&nbst, &sub)) {
if (!sub.shp_own) if (!sub.shp_own)
continue; continue;