(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 plnstr start; /* Used for sanity checking */
|
||||||
struct nukstr nuke;
|
struct nukstr nuke;
|
||||||
s_char *p;
|
s_char *p;
|
||||||
int i;
|
|
||||||
int pno;
|
int pno;
|
||||||
int nuketype;
|
int nuketype;
|
||||||
int nukenum;
|
int found;
|
||||||
int len;
|
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
s_char buf[1024];
|
s_char buf[1024];
|
||||||
int disarm = **player->argp == 'd';
|
int disarm = **player->argp == 'd';
|
||||||
|
@ -89,27 +87,21 @@ arm(void)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if (!check_plane_ok(&start))
|
if (!check_plane_ok(&start))
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
len = strlen(p);
|
nuketype = typematch(p, EF_NUKE);
|
||||||
for (i = 0, ncp = nchr; i < N_MAXNUKE; i++, ncp++) {
|
if (nuketype < 0) {
|
||||||
if (strncmp(ncp->n_name, p, len) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i >= N_MAXNUKE) {
|
|
||||||
pr("No such nuke type!\n");
|
pr("No such nuke type!\n");
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
}
|
}
|
||||||
nuketype = i;
|
ncp = &nchr[nuketype];
|
||||||
nukenum = -1;
|
found = 0;
|
||||||
snxtitem_all(&ni, EF_NUKE);
|
snxtitem_xy(&ni, EF_NUKE, pl.pln_x, pl.pln_y);
|
||||||
while (nxtitem(&ni, &nuke)) {
|
while (nxtitem(&ni, &nuke)) {
|
||||||
if (nuke.nuk_own != player->cnum)
|
if (nuke.nuk_own == player->cnum) {
|
||||||
continue;
|
found = 1;
|
||||||
if (nuke.nuk_x != pl.pln_x || nuke.nuk_y != pl.pln_y)
|
break;
|
||||||
continue;
|
}
|
||||||
nukenum = ni.cur;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (nukenum < 0) {
|
if (!found) {
|
||||||
pr("You don't own any nukes in that sector.\n");
|
pr("You don't own any nukes in that sector.\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,12 +75,10 @@ static int
|
||||||
tran_nuke(void)
|
tran_nuke(void)
|
||||||
{
|
{
|
||||||
struct nchrstr *ncp;
|
struct nchrstr *ncp;
|
||||||
int len;
|
|
||||||
coord x, y;
|
coord x, y;
|
||||||
coord dstx, dsty;
|
coord dstx, dsty;
|
||||||
int found;
|
int found;
|
||||||
s_char *p;
|
s_char *p;
|
||||||
int i;
|
|
||||||
int nuketype;
|
int nuketype;
|
||||||
int moving;
|
int moving;
|
||||||
struct nukstr nuke;
|
struct nukstr nuke;
|
||||||
|
@ -115,16 +113,12 @@ tran_nuke(void)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if (!check_sect_ok(§))
|
if (!check_sect_ok(§))
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
len = strlen(p);
|
nuketype = typematch(p, EF_NUKE);
|
||||||
for (i = 0, ncp = nchr; i < N_MAXNUKE; i++, ncp++) {
|
if (nuketype < 0) {
|
||||||
if (strncmp(ncp->n_name, p, len) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i >= N_MAXNUKE) {
|
|
||||||
pr("No such nuke type!\n");
|
pr("No such nuke type!\n");
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
}
|
}
|
||||||
nuketype = i;
|
ncp = &nchr[nuketype];
|
||||||
if (!nuke.nuk_types[nuketype]) {
|
if (!nuke.nuk_types[nuketype]) {
|
||||||
pr("No %s nukes in %s\n",
|
pr("No %s nukes in %s\n",
|
||||||
ncp->n_name, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
ncp->n_name, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue