Factor snxtitem_use_condarg() out of snxtitem()
This commit is contained in:
parent
74a69cf74c
commit
84072cff5d
2 changed files with 18 additions and 7 deletions
|
@ -305,6 +305,7 @@ extern void snxtitem_group(struct nstr_item *, int, char);
|
||||||
extern void snxtitem_rewind(struct nstr_item *);
|
extern void snxtitem_rewind(struct nstr_item *);
|
||||||
extern int snxtitem_list(struct nstr_item *, int, int *, int);
|
extern int snxtitem_list(struct nstr_item *, int, int *, int);
|
||||||
extern void snxtitem_cargo(struct nstr_item *, int, int, int);
|
extern void snxtitem_cargo(struct nstr_item *, int, int, int);
|
||||||
|
extern int snxtitem_use_condarg(struct nstr_item *);
|
||||||
/* src/lib/subs/snxtsct.c */
|
/* src/lib/subs/snxtsct.c */
|
||||||
extern int snxtsct(struct nstr_sect *, char *);
|
extern int snxtsct(struct nstr_sect *, char *);
|
||||||
extern void snxtsct_area(struct nstr_sect *, struct range *);
|
extern void snxtsct_area(struct nstr_sect *, struct range *);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Dave Pare, 1989
|
* Dave Pare, 1989
|
||||||
* Markus Armbruster, 2009
|
* Markus Armbruster, 2009-2011
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -125,12 +125,7 @@ snxtitem(struct nstr_item *np, int type, char *str, char *prompt)
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!player->condarg)
|
return snxtitem_use_condarg(np);
|
||||||
return 1;
|
|
||||||
n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond), type,
|
|
||||||
player->condarg);
|
|
||||||
np->ncond = n >= 0 ? n : 0;
|
|
||||||
return n >= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -239,3 +234,18 @@ snxtitem_cargo(struct nstr_item *np, int type,
|
||||||
np->sel = NS_CARGO;
|
np->sel = NS_CARGO;
|
||||||
np->next = unit_cargo_first(carrier_type, carrier_uid, type);
|
np->next = unit_cargo_first(carrier_type, carrier_uid, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
snxtitem_use_condarg(struct nstr_item *np)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
if (!player->condarg)
|
||||||
|
return 1;
|
||||||
|
n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond),
|
||||||
|
np->type, player->condarg);
|
||||||
|
if (n < 0)
|
||||||
|
return 0;
|
||||||
|
np->ncond = n;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue