CLAIM command did not like that tokens could be NULL.

This commit is contained in:
Enno Rehling 2015-04-09 12:33:23 +02:00
parent 224a9af33c
commit ad0a753c52
1 changed files with 15 additions and 12 deletions

View File

@ -3911,12 +3911,13 @@ int claim_cmd(unit * u, struct order *ord)
{
char token[128];
const char *t;
int n;
const item_type *itype;
int n = 1;
const item_type *itype = 0;
init_order(ord);
t = gettoken(token, sizeof(token));
if (t) {
n = atoi((const char *)t);
if (n == 0) {
n = 1;
@ -3924,11 +3925,13 @@ int claim_cmd(unit * u, struct order *ord)
else {
t = gettoken(token, sizeof(token));
}
if (t) {
itype = finditemtype(t, u->faction->locale);
if (itype != NULL) {
}
}
if (itype) {
item **iclaim = i_find(&u->faction->items, itype);
if (iclaim != NULL && *iclaim != NULL) {
if (iclaim && *iclaim) {
n = _min(n, (*iclaim)->number);
i_change(iclaim, itype, -n);
i_change(&u->items, itype, n);