forked from github/server
CLAIM command did not like that tokens could be NULL.
This commit is contained in:
parent
224a9af33c
commit
ad0a753c52
27
src/laws.c
27
src/laws.c
|
@ -3911,24 +3911,27 @@ int claim_cmd(unit * u, struct order *ord)
|
||||||
{
|
{
|
||||||
char token[128];
|
char token[128];
|
||||||
const char *t;
|
const char *t;
|
||||||
int n;
|
int n = 1;
|
||||||
const item_type *itype;
|
const item_type *itype = 0;
|
||||||
|
|
||||||
init_order(ord);
|
init_order(ord);
|
||||||
|
|
||||||
t = gettoken(token, sizeof(token));
|
t = gettoken(token, sizeof(token));
|
||||||
n = atoi((const char *)t);
|
if (t) {
|
||||||
if (n == 0) {
|
n = atoi((const char *)t);
|
||||||
n = 1;
|
if (n == 0) {
|
||||||
|
n = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
t = gettoken(token, sizeof(token));
|
||||||
|
}
|
||||||
|
if (t) {
|
||||||
|
itype = finditemtype(t, u->faction->locale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (itype) {
|
||||||
t = gettoken(token, sizeof(token));
|
|
||||||
}
|
|
||||||
itype = finditemtype(t, u->faction->locale);
|
|
||||||
|
|
||||||
if (itype != NULL) {
|
|
||||||
item **iclaim = i_find(&u->faction->items, itype);
|
item **iclaim = i_find(&u->faction->items, itype);
|
||||||
if (iclaim != NULL && *iclaim != NULL) {
|
if (iclaim && *iclaim) {
|
||||||
n = _min(n, (*iclaim)->number);
|
n = _min(n, (*iclaim)->number);
|
||||||
i_change(iclaim, itype, -n);
|
i_change(iclaim, itype, -n);
|
||||||
i_change(&u->items, itype, n);
|
i_change(&u->items, itype, n);
|
||||||
|
|
Loading…
Reference in New Issue