(arm, tran_nuke): Lookup of the nuke name was broken by nuke.h
rev. 1.10. Replace by typematch(). (arm): Simplify search for nuke at sector.
This commit is contained in:
parent
19953e6c22
commit
100d0fc495
2 changed files with 14 additions and 28 deletions
|
@ -53,11 +53,9 @@ arm(void)
|
|||
struct plnstr start; /* Used for sanity checking */
|
||||
struct nukstr nuke;
|
||||
s_char *p;
|
||||
int i;
|
||||
int pno;
|
||||
int nuketype;
|
||||
int nukenum;
|
||||
int len;
|
||||
int found;
|
||||
struct nstr_item ni;
|
||||
s_char buf[1024];
|
||||
int disarm = **player->argp == 'd';
|
||||
|
@ -89,27 +87,21 @@ arm(void)
|
|||
return RET_SYN;
|
||||
if (!check_plane_ok(&start))
|
||||
return RET_FAIL;
|
||||
len = strlen(p);
|
||||
for (i = 0, ncp = nchr; i < N_MAXNUKE; i++, ncp++) {
|
||||
if (strncmp(ncp->n_name, p, len) == 0)
|
||||
break;
|
||||
}
|
||||
if (i >= N_MAXNUKE) {
|
||||
nuketype = typematch(p, EF_NUKE);
|
||||
if (nuketype < 0) {
|
||||
pr("No such nuke type!\n");
|
||||
return RET_SYN;
|
||||
}
|
||||
nuketype = i;
|
||||
nukenum = -1;
|
||||
snxtitem_all(&ni, EF_NUKE);
|
||||
ncp = &nchr[nuketype];
|
||||
found = 0;
|
||||
snxtitem_xy(&ni, EF_NUKE, pl.pln_x, pl.pln_y);
|
||||
while (nxtitem(&ni, &nuke)) {
|
||||
if (nuke.nuk_own != player->cnum)
|
||||
continue;
|
||||
if (nuke.nuk_x != pl.pln_x || nuke.nuk_y != pl.pln_y)
|
||||
continue;
|
||||
nukenum = ni.cur;
|
||||
break;
|
||||
if (nuke.nuk_own == player->cnum) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nukenum < 0) {
|
||||
if (!found) {
|
||||
pr("You don't own any nukes in that sector.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
|
|
@ -75,12 +75,10 @@ static int
|
|||
tran_nuke(void)
|
||||
{
|
||||
struct nchrstr *ncp;
|
||||
int len;
|
||||
coord x, y;
|
||||
coord dstx, dsty;
|
||||
int found;
|
||||
s_char *p;
|
||||
int i;
|
||||
int nuketype;
|
||||
int moving;
|
||||
struct nukstr nuke;
|
||||
|
@ -115,16 +113,12 @@ tran_nuke(void)
|
|||
return RET_SYN;
|
||||
if (!check_sect_ok(§))
|
||||
return RET_FAIL;
|
||||
len = strlen(p);
|
||||
for (i = 0, ncp = nchr; i < N_MAXNUKE; i++, ncp++) {
|
||||
if (strncmp(ncp->n_name, p, len) == 0)
|
||||
break;
|
||||
}
|
||||
if (i >= N_MAXNUKE) {
|
||||
nuketype = typematch(p, EF_NUKE);
|
||||
if (nuketype < 0) {
|
||||
pr("No such nuke type!\n");
|
||||
return RET_SYN;
|
||||
}
|
||||
nuketype = i;
|
||||
ncp = &nchr[nuketype];
|
||||
if (!nuke.nuk_types[nuketype]) {
|
||||
pr("No %s nukes in %s\n",
|
||||
ncp->n_name, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue