Factor snxtsct_use_condarg() out of snxtsct()

This commit is contained in:
Markus Armbruster 2011-04-08 21:13:07 +02:00
parent 84072cff5d
commit 7de511fb66
2 changed files with 19 additions and 8 deletions

View file

@ -312,6 +312,7 @@ extern void snxtsct_area(struct nstr_sect *, struct range *);
extern void snxtsct_all(struct nstr_sect *);
extern void snxtsct_rewind(struct nstr_sect *);
extern void snxtsct_dist(struct nstr_sect *, coord, coord, int);
extern int snxtsct_use_condarg(struct nstr_sect *);
/* src/lib/subs/nstr.c */
extern int nstr_comp(struct nscstr *np, int len, int type, char *str);
extern char *nstr_comp_val(char *, struct valstr *, int);

View file

@ -28,7 +28,7 @@
*
* Known contributors to this file:
* Dave Pare, 1989
* Markus Armbruster, 2006-2009
* Markus Armbruster, 2006-2011
*/
#include <config.h>
@ -57,7 +57,7 @@ snxtsct(struct nstr_sect *np, char *str)
struct range range;
struct natstr *natp;
coord cx, cy;
int dist, n;
int dist;
char buf[1024];
if (!str || !*str) {
@ -91,12 +91,7 @@ snxtsct(struct nstr_sect *np, char *str)
default:
return 0;
}
if (!player->condarg)
return 1;
n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond),
EF_SECTOR, player->condarg);
np->ncond = n >= 0 ? n : 0;
return n >= 0;
return snxtsct_use_condarg(np);
}
void
@ -125,6 +120,21 @@ snxtsct_area(struct nstr_sect *np, struct range *range)
np->dy = 0;
}
int
snxtsct_use_condarg(struct nstr_sect *np)
{
int n;
if (!player->condarg)
return 1;
n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond),
EF_SECTOR, player->condarg);
if (n < 0)
return 0;
np->ncond = n;
return 1;
}
void
snxtsct_rewind(struct nstr_sect *np)
{