forked from github/server
cleaning up GIVE, because there was too much parameter-searching going on here for the normal case of GIVE X N ITEM
This commit is contained in:
parent
8af1cad1dc
commit
7dea6457d1
|
@ -696,7 +696,7 @@ static void give_cmd(unit * u, order * ord)
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
unit *u2;
|
unit *u2;
|
||||||
const char *s;
|
const char *s;
|
||||||
int i, n;
|
int n;
|
||||||
const item_type *itype;
|
const item_type *itype;
|
||||||
param_t p;
|
param_t p;
|
||||||
plane *pl;
|
plane *pl;
|
||||||
|
@ -705,7 +705,8 @@ static void give_cmd(unit * u, order * ord)
|
||||||
skip_token();
|
skip_token();
|
||||||
u2 = getunit(r, u->faction);
|
u2 = getunit(r, u->faction);
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
p = findparam(s, u->faction->locale);
|
n = atoip(s);
|
||||||
|
p = (n>0) ? NOPARAM : findparam(s, u->faction->locale);
|
||||||
|
|
||||||
/* first, do all the ones that do not require HELP_GIVE or CONTACT */
|
/* first, do all the ones that do not require HELP_GIVE or CONTACT */
|
||||||
if (p == P_CONTROL) {
|
if (p == P_CONTROL) {
|
||||||
|
@ -858,44 +859,37 @@ static void give_cmd(unit * u, order * ord)
|
||||||
itmp = &itm->next;
|
itmp = &itm->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
if (isparam(s, u->faction->locale, P_PERSON)) {
|
if (isparam(s, u->faction->locale, P_PERSON)) {
|
||||||
if (!(u->race->ec_flags & GIVEPERSON)) {
|
if (!(u->race->ec_flags & GIVEPERSON)) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_noregroup", "race", u->race));
|
msg_feedback(u, ord, "race_noregroup", "race", u->race));
|
||||||
return;
|
} else {
|
||||||
|
n = u->number;
|
||||||
|
give_men(n, u, u2, ord);
|
||||||
}
|
}
|
||||||
n = u->number;
|
} else if (!(u->race->ec_flags & GIVEITEM) && u2 != NULL) {
|
||||||
give_men(n, u, u2, ord);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(u->race->ec_flags & GIVEITEM) && u2 != NULL) {
|
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_nogive", "race", u->race));
|
msg_feedback(u, ord, "race_nogive", "race", u->race));
|
||||||
return;
|
} else if (u2 && !(u2->race->ec_flags & GETITEM)) {
|
||||||
}
|
|
||||||
if (u2 && !(u2->race->ec_flags & GETITEM)) {
|
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_notake", "race", u2->race));
|
msg_feedback(u, ord, "race_notake", "race", u2->race));
|
||||||
return;
|
} else {
|
||||||
}
|
itype = finditemtype(s, u->faction->locale);
|
||||||
|
if (itype != NULL) {
|
||||||
itype = finditemtype(s, u->faction->locale);
|
item *i = *i_find(&u->items, itype);
|
||||||
if (itype != NULL) {
|
if (i != NULL) {
|
||||||
item *i = *i_find(&u->items, itype);
|
if (check_give(u, u2, itype, 0)) {
|
||||||
if (i != NULL) {
|
n = i->number - get_reservation(u, itype->rtype);
|
||||||
if (check_give(u, u2, itype, 0)) {
|
give_item(n, itype, u, u2, ord);
|
||||||
n = i->number - get_reservation(u, itype->rtype);
|
} else {
|
||||||
give_item(n, itype, u, u2, ord);
|
feedback_give_not_allowed(u, ord);
|
||||||
} else {
|
}
|
||||||
feedback_give_not_allowed(u, ord);
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
} else if (p == P_EACH) {
|
} else if (p == P_EACH) {
|
||||||
if (u2 == NULL) {
|
if (u2 == NULL) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
|
@ -903,10 +897,7 @@ static void give_cmd(unit * u, order * ord)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s = getstrtoken(); /* skip one ahead to get the amount. */
|
s = getstrtoken(); /* skip one ahead to get the amount. */
|
||||||
}
|
n = atoip(s); /* n: Anzahl */
|
||||||
|
|
||||||
n = atoip((const char *)s); /* n: Anzahl */
|
|
||||||
if (p == P_EACH) {
|
|
||||||
n *= u2->number;
|
n *= u2->number;
|
||||||
}
|
}
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
|
@ -916,8 +907,7 @@ static void give_cmd(unit * u, order * ord)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = findparam(s, u->faction->locale);
|
if (isparam(s, u->faction->locale, P_PERSON)) {
|
||||||
if (i == P_PERSON) {
|
|
||||||
if (!(u->race->ec_flags & GIVEPERSON)) {
|
if (!(u->race->ec_flags & GIVEPERSON)) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_noregroup", "race", u->race));
|
msg_feedback(u, ord, "race_noregroup", "race", u->race));
|
||||||
|
|
Loading…
Reference in New Issue