forked from github/server
implementation of "EACH":
GIVE abcd EACH 1 sword GIB abcd JE[DEM] 1 schwert
This commit is contained in:
parent
31b8b57b77
commit
79134609a2
|
@ -563,6 +563,7 @@ give_cmd(unit * u, order * ord)
|
|||
int i, n;
|
||||
const item_type * itype;
|
||||
int notfound_error = 63;
|
||||
param_t p;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -591,8 +592,9 @@ give_cmd(unit * u, order * ord)
|
|||
}
|
||||
|
||||
s = getstrtoken();
|
||||
p = findparam(s, u->faction->locale);
|
||||
|
||||
if (findparam(s, u->faction->locale) == P_CONTROL) {
|
||||
if (p == P_CONTROL) {
|
||||
if (!u2) {
|
||||
cmistake(u, ord, notfound_error, MSG_EVENT);
|
||||
return;
|
||||
|
@ -629,19 +631,20 @@ give_cmd(unit * u, order * ord)
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (u2 && u2->race == new_race[RC_SPELL]) {
|
||||
|
||||
else if (u2 && u2->race == new_race[RC_SPELL]) {
|
||||
cmistake(u, ord, notfound_error, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
|
||||
/* if ((u->race->ec_flags & NOGIVE) || fval(u,UFL_LOCKED)) {*/
|
||||
if (u->race->ec_flags & NOGIVE && u2!=NULL) {
|
||||
else if (u->race->ec_flags & NOGIVE && u2!=NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "race_nogive", "race", u->race));
|
||||
return;
|
||||
}
|
||||
/* sperrt hier auch personenübergaben!
|
||||
if (u2 && !(u2->race->ec_flags & GETITEM)) {
|
||||
else if (u2 && !(u2->race->ec_flags & GETITEM)) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "race_notake", "race", u2->race));
|
||||
return;
|
||||
|
@ -649,7 +652,7 @@ give_cmd(unit * u, order * ord)
|
|||
*/
|
||||
|
||||
/* Übergabe aller Kräuter */
|
||||
if (findparam(s, u->faction->locale) == P_HERBS) {
|
||||
else if (p == P_HERBS) {
|
||||
boolean given = false;
|
||||
if (!(u->race->ec_flags & GIVEITEM) && u2!=NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
|
@ -685,12 +688,14 @@ give_cmd(unit * u, order * ord)
|
|||
if (!given) cmistake(u, ord, 38, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
if (findparam(s, u->faction->locale) == P_ZAUBER) {
|
||||
|
||||
else if (p == P_ZAUBER) {
|
||||
cmistake(u, ord, 7, MSG_COMMERCE);
|
||||
/* geht nimmer */
|
||||
return;
|
||||
}
|
||||
if (findparam(s, u->faction->locale) == P_UNIT) { /* Einheiten uebergeben */
|
||||
|
||||
else if (p == P_UNIT) { /* Einheiten uebergeben */
|
||||
if (!(u->race->ec_flags & GIVEUNIT)) {
|
||||
cmistake(u, ord, 167, MSG_COMMERCE);
|
||||
return;
|
||||
|
@ -703,15 +708,18 @@ give_cmd(unit * u, order * ord)
|
|||
give_unit(u, u2, ord);
|
||||
return;
|
||||
}
|
||||
if (findparam(s, u->faction->locale) == P_ANY) { /* Alle Gegenstände übergeben */
|
||||
|
||||
else if (p==P_ANY) {
|
||||
const char * s = getstrtoken();
|
||||
|
||||
if (*s == 0) { /* Alle Gegenstände übergeben */
|
||||
|
||||
if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
|
||||
cmistake(u, ord, 40, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (*s == 0) {
|
||||
/* do these checks once, not for each item we have: */
|
||||
if (!(u->race->ec_flags & GIVEITEM) && u2!=NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "race_nogive", "race", u->race));
|
||||
|
@ -739,8 +747,10 @@ give_cmd(unit * u, order * ord)
|
|||
}
|
||||
return;
|
||||
}
|
||||
i = findparam(s, u->faction->locale);
|
||||
if (i == P_PERSON) {
|
||||
else {
|
||||
param_t p2 = findparam(s, u->faction->locale);
|
||||
|
||||
if (p2 == P_PERSON) {
|
||||
if (!(u->race->ec_flags & GIVEPERSON)) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "race_noregroup", "race", u->race));
|
||||
|
@ -772,8 +782,19 @@ give_cmd(unit * u, order * ord)
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (p==P_EACH) {
|
||||
if (u2==NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "peasants_give_invalid", ""));
|
||||
return;
|
||||
}
|
||||
s = getstrtoken(); /* skip one ahead to get the amount. */
|
||||
}
|
||||
|
||||
n = atoip(s); /* n: anzahl */
|
||||
if (p==P_EACH) {
|
||||
n *= u2->number;
|
||||
}
|
||||
s = getstrtoken();
|
||||
|
||||
if (s == NULL) {
|
||||
|
|
|
@ -280,6 +280,7 @@ const char *parameters[MAXPARAMS] =
|
|||
{
|
||||
"LOCALE",
|
||||
"ALLES",
|
||||
"JEDEM",
|
||||
"BAUERN",
|
||||
"BURG",
|
||||
"EINHEIT",
|
||||
|
|
|
@ -451,6 +451,7 @@ typedef unsigned char param_t;
|
|||
enum {
|
||||
P_LOCALE,
|
||||
P_ANY,
|
||||
P_EACH,
|
||||
P_PEASANT,
|
||||
P_BUILDING,
|
||||
P_UNIT,
|
||||
|
|
|
@ -1825,6 +1825,9 @@
|
|||
<string name="AGGRESSIV">
|
||||
<text locale="de">AGGRESSIV</text>
|
||||
</string>
|
||||
<string name="JEDEM">
|
||||
<text locale="de">JEDEM</text>
|
||||
</string>
|
||||
<string name="ALLES">
|
||||
<text locale="de">ALLES</text>
|
||||
</string>
|
||||
|
|
|
@ -1157,6 +1157,9 @@
|
|||
<string name="ALLES">
|
||||
<text locale="en">ALL</text>
|
||||
</string>
|
||||
<string name="JEDEM">
|
||||
<text locale="en">EACH</text>
|
||||
</string>
|
||||
<string name="ANZAHL">
|
||||
<text locale="en">NUMBER</text>
|
||||
</string>
|
||||
|
|
Loading…
Reference in New Issue