source formatting.

This commit is contained in:
Enno Rehling 2005-12-02 20:23:54 +00:00
parent 5f43830f59
commit 5aa0ca5ff5
2 changed files with 246 additions and 246 deletions

View File

@ -555,266 +555,266 @@ static void
give_cmd(unit * u, order * ord) 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 i, n;
const item_type * itype; const item_type * itype;
int notfound_error = 63; int notfound_error = 63;
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
u2 = getunit(r, u->faction); u2 = getunit(r, u->faction);
if (!u2 && !getunitpeasants) { if (!u2 && !getunitpeasants) {
cmistake(u, ord, notfound_error, MSG_COMMERCE); cmistake(u, ord, notfound_error, MSG_COMMERCE);
return; return;
} }
/* Damit Tarner nicht durch die Fehlermeldung enttarnt werden können */ /* Damit Tarner nicht durch die Fehlermeldung enttarnt werden können */
if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !cansee(u->faction,r,u2,0) && !ucontact(u2, u) && !fval(u2, UFL_TAKEALL)) { if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !cansee(u->faction,r,u2,0) && !ucontact(u2, u) && !fval(u2, UFL_TAKEALL)) {
cmistake(u, ord, notfound_error, MSG_COMMERCE); cmistake(u, ord, notfound_error, MSG_COMMERCE);
return; return;
} }
if (u == u2) { if (u == u2) {
cmistake(u, ord, 8, MSG_COMMERCE); cmistake(u, ord, 8, MSG_COMMERCE);
return; return;
} }
/* UFL_TAKEALL ist ein grober Hack. Generalisierung tut not, ist aber nicht /* UFL_TAKEALL ist ein grober Hack. Generalisierung tut not, ist aber nicht
* wirklich einfach. */ * wirklich einfach. */
if (r->planep && fval(r->planep, PFL_NOGIVE) && (!u2 || !fval(u2, UFL_TAKEALL))) { if (r->planep && fval(r->planep, PFL_NOGIVE) && (!u2 || !fval(u2, UFL_TAKEALL))) {
cmistake(u, ord, 268, MSG_COMMERCE); cmistake(u, ord, 268, MSG_COMMERCE);
return; return;
} }
s = getstrtoken(); s = getstrtoken();
if (findparam(s, u->faction->locale) == P_CONTROL) { if (findparam(s, u->faction->locale) == P_CONTROL) {
if (!u2) { if (!u2) {
cmistake(u, ord, notfound_error, MSG_EVENT); cmistake(u, ord, notfound_error, MSG_EVENT);
return; return;
} }
if (!u->building && !u->ship) { if (!u->building && !u->ship) {
cmistake(u, ord, 140, MSG_EVENT); cmistake(u, ord, 140, MSG_EVENT);
return; return;
} }
if (u->building && u2->building != u->building) { if (u->building && u2->building != u->building) {
cmistake(u, ord, 33, MSG_EVENT); cmistake(u, ord, 33, MSG_EVENT);
return; return;
} }
if (u->ship && u2->ship != u->ship) { if (u->ship && u2->ship != u->ship) {
cmistake(u, ord, 32, MSG_EVENT); cmistake(u, ord, 32, MSG_EVENT);
return; return;
} }
if (!fval(u, UFL_OWNER)) { if (!fval(u, UFL_OWNER)) {
cmistake(u, ord, 49, MSG_EVENT); cmistake(u, ord, 49, MSG_EVENT);
return; return;
} }
if (!alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) { if (!alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
cmistake(u, ord, 40, MSG_EVENT); cmistake(u, ord, 40, MSG_EVENT);
return; return;
} }
freset(u, UFL_OWNER); freset(u, UFL_OWNER);
fset(u2, UFL_OWNER); fset(u2, UFL_OWNER);
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
msg_message("givecommand", "unit receipient", u, u2)); msg_message("givecommand", "unit receipient", u, u2));
if (u->faction != u2->faction) { if (u->faction != u2->faction) {
ADDMSG(&u2->faction->msgs, ADDMSG(&u2->faction->msgs,
msg_message("givecommand", "unit receipient", msg_message("givecommand", "unit receipient",
ucansee(u2->faction, u, u_unknown()), u2)); ucansee(u2->faction, u, u_unknown()), u2));
} }
return; return;
} }
if (u2 && u2->race == new_race[RC_SPELL]) { if (u2 && u2->race == new_race[RC_SPELL]) {
cmistake(u, ord, notfound_error, MSG_COMMERCE); cmistake(u, ord, notfound_error, MSG_COMMERCE);
return; return;
} }
/* if ((u->race->ec_flags & NOGIVE) || fval(u,UFL_LOCKED)) {*/ /* if ((u->race->ec_flags & NOGIVE) || fval(u,UFL_LOCKED)) {*/
if (u->race->ec_flags & NOGIVE && u2!=NULL) { if (u->race->ec_flags & NOGIVE && 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; return;
} }
/* sperrt hier auch personenübergaben! /* sperrt hier auch personenübergaben!
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; return;
} }
*/ */
/* Übergabe aller Kräuter */ /* Übergabe aller Kräuter */
if (findparam(s, u->faction->locale) == P_HERBS) { if (findparam(s, u->faction->locale) == P_HERBS) {
boolean given = false; boolean given = false;
if (!(u->race->ec_flags & GIVEITEM) && u2!=NULL) { 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; return;
} }
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; return;
} }
if (!u2) { if (!u2) {
if (!getunitpeasants) { if (!getunitpeasants) {
cmistake(u, ord, notfound_error, MSG_COMMERCE); cmistake(u, ord, notfound_error, MSG_COMMERCE);
return; return;
} }
} }
if (u->items) { if (u->items) {
item **itmp=&u->items; item **itmp=&u->items;
while (*itmp) { while (*itmp) {
const item_type * itype = (*itmp)->type; const item_type * itype = (*itmp)->type;
if (fval(itype, ITF_HERB) && (*itmp)->number>0) { if (fval(itype, ITF_HERB) && (*itmp)->number>0) {
/* give_item ändert im fall,das man alles übergibt, die /* give_item ändert im fall,das man alles übergibt, die
* item-liste der unit, darum continue vor pointerumsetzten */ * item-liste der unit, darum continue vor pointerumsetzten */
if (give_item((*itmp)->number, (*itmp)->type, u, u2, ord)==0) { if (give_item((*itmp)->number, (*itmp)->type, u, u2, ord)==0) {
given = true; given = true;
continue; continue;
} }
} }
itmp = &(*itmp)->next; itmp = &(*itmp)->next;
} }
} }
if (!given) cmistake(u, ord, 38, MSG_COMMERCE); if (!given) cmistake(u, ord, 38, MSG_COMMERCE);
return; return;
} }
if (findparam(s, u->faction->locale) == P_ZAUBER) { if (findparam(s, u->faction->locale) == P_ZAUBER) {
cmistake(u, ord, 7, MSG_COMMERCE); cmistake(u, ord, 7, MSG_COMMERCE);
/* geht nimmer */ /* geht nimmer */
return; return;
} }
if (findparam(s, u->faction->locale) == P_UNIT) { /* Einheiten uebergeben */ if (findparam(s, u->faction->locale) == P_UNIT) { /* Einheiten uebergeben */
if (!(u->race->ec_flags & GIVEUNIT)) { if (!(u->race->ec_flags & GIVEUNIT)) {
cmistake(u, ord, 167, MSG_COMMERCE); cmistake(u, ord, 167, MSG_COMMERCE);
return; return;
} }
if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
cmistake(u, ord, 40, MSG_COMMERCE);
return;
}
give_unit(u, u2, ord);
return;
}
if (findparam(s, u->faction->locale) == P_ANY) { /* Alle Gegenstände übergeben */
const char * s = getstrtoken();
if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) { if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
cmistake(u, ord, 40, MSG_COMMERCE); cmistake(u, ord, 40, MSG_COMMERCE);
return; return;
} }
give_unit(u, u2, ord);
return;
}
if (findparam(s, u->faction->locale) == P_ANY) { /* Alle Gegenstände übergeben */
const char * s = getstrtoken();
if (*s == 0) { if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
if (!(u->race->ec_flags & GIVEITEM) && u2!=NULL) { cmistake(u, ord, 40, MSG_COMMERCE);
ADDMSG(&u->faction->msgs, return;
msg_feedback(u, ord, "race_nogive", "race", u->race)); }
return;
}
if (u2 && !(u2->race->ec_flags & GETITEM)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_notake", "race", u2->race));
return;
}
/* für alle items einmal prüfen, ob wir mehr als von diesem Typ if (*s == 0) {
* reserviert ist besitzen und diesen Teil dann übergeben */ if (!(u->race->ec_flags & GIVEITEM) && u2!=NULL) {
if (u->items) { ADDMSG(&u->faction->msgs,
item **itmp=&u->items; msg_feedback(u, ord, "race_nogive", "race", u->race));
while (*itmp) { return;
if ((*itmp)->number > 0 }
&& (*itmp)->number - get_reservation(u, (*itmp)->type->rtype) > 0) { if (u2 && !(u2->race->ec_flags & GETITEM)) {
n = (*itmp)->number - get_reservation(u, (*itmp)->type->rtype); ADDMSG(&u->faction->msgs,
if (give_item(n, (*itmp)->type, u, u2, ord)==0) continue; msg_feedback(u, ord, "race_notake", "race", u2->race));
} return;
itmp = &(*itmp)->next; }
}
}
return;
}
i = findparam(s, u->faction->locale);
if (i == P_PERSON) {
if (!(u->race->ec_flags & GIVEPERSON)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_noregroup", "race", u->race));
return;
}
n = u->number;
give_men(n, u, u2, ord);
return;
}
if (!(u->race->ec_flags & GIVEITEM) && u2!=NULL) { /* für alle items einmal prüfen, ob wir mehr als von diesem Typ
ADDMSG(&u->faction->msgs, * reserviert ist besitzen und diesen Teil dann übergeben */
msg_feedback(u, ord, "race_nogive", "race", u->race)); if (u->items) {
return; item **itmp=&u->items;
} while (*itmp) {
if (u2 && !(u2->race->ec_flags & GETITEM)) { if ((*itmp)->number > 0
ADDMSG(&u->faction->msgs, && (*itmp)->number - get_reservation(u, (*itmp)->type->rtype) > 0) {
msg_feedback(u, ord, "race_notake", "race", u2->race)); n = (*itmp)->number - get_reservation(u, (*itmp)->type->rtype);
return; if (give_item(n, (*itmp)->type, u, u2, ord)==0) continue;
} }
itmp = &(*itmp)->next;
}
}
return;
}
i = findparam(s, u->faction->locale);
if (i == P_PERSON) {
if (!(u->race->ec_flags & GIVEPERSON)) {
ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "race_noregroup", "race", u->race));
return;
}
n = u->number;
give_men(n, u, u2, ord);
return;
}
itype = finditemtype(s, u->faction->locale); if (!(u->race->ec_flags & GIVEITEM) && u2!=NULL) {
if (itype!=NULL) { ADDMSG(&u->faction->msgs,
item * i = *i_find(&u->items, itype); msg_feedback(u, ord, "race_nogive", "race", u->race));
if (i!=NULL) { return;
n = i->number - get_reservation(u, itype->rtype); }
give_item(n, itype, u, u2, ord); if (u2 && !(u2->race->ec_flags & GETITEM)) {
return; ADDMSG(&u->faction->msgs,
} msg_feedback(u, ord, "race_notake", "race", u2->race));
} return;
} }
n = atoip(s); /* n: anzahl */ itype = finditemtype(s, u->faction->locale);
s = getstrtoken(); if (itype!=NULL) {
item * i = *i_find(&u->items, itype);
if (i!=NULL) {
n = i->number - get_reservation(u, itype->rtype);
give_item(n, itype, u, u2, ord);
return;
}
}
}
if (s == NULL) { n = atoip(s); /* n: anzahl */
cmistake(u, ord, 113, MSG_COMMERCE); s = getstrtoken();
return;
} if (s == NULL) {
cmistake(u, ord, 113, MSG_COMMERCE);
return;
}
if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) { if (u2 && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
const resource_type * rtype = findresourcetype(s, u->faction->locale); const resource_type * rtype = findresourcetype(s, u->faction->locale);
if (rtype==NULL || !fval(rtype, RTF_SNEAK)) if (rtype==NULL || !fval(rtype, RTF_SNEAK))
{ {
cmistake(u, ord, 40, MSG_COMMERCE); cmistake(u, ord, 40, MSG_COMMERCE);
return; return;
} }
} }
i = findparam(s, u->faction->locale); i = findparam(s, u->faction->locale);
if (i == 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));
return; return;
} }
give_men(n, u, u2, ord); give_men(n, u, u2, ord);
return; return;
} }
if (u2!=NULL) { if (u2!=NULL) {
if (!(u->race->ec_flags & GIVEITEM) && u2!=NULL) { 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; return;
} }
if (!(u2->race->ec_flags & GETITEM)) { if (!(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; return;
} }
} }
itype = finditemtype(s, u->faction->locale); itype = finditemtype(s, u->faction->locale);
if (itype!=NULL) { if (itype!=NULL) {
give_item(n, itype, u, u2, ord); give_item(n, itype, u, u2, ord);
return; return;
} }
cmistake(u, ord, 123, MSG_COMMERCE); cmistake(u, ord, 123, MSG_COMMERCE);
} }
static int static int

View File

@ -1000,19 +1000,19 @@ alliedfaction(const struct plane * pl, const struct faction * f,
int int
alliedunit(const unit * u, const faction * f2, int mode) alliedunit(const unit * u, const faction * f2, int mode)
{ {
ally * sf; ally * sf;
const plane * pl = getplane(u->region); const plane * pl = getplane(u->region);
int automode; int automode;
if (u->faction == f2) return mode; if (u->faction == f2) return mode;
if (u->faction == NULL || f2==NULL) return 0; if (u->faction == NULL || f2==NULL) return 0;
automode = mode & autoalliance(pl, u->faction, f2); automode = mode & autoalliance(pl, u->faction, f2);
if (pl!=NULL && (pl->flags & PFL_NOALLIANCES)) if (pl!=NULL && (pl->flags & PFL_NOALLIANCES))
mode = (mode & automode) | (mode & HELP_GIVE); mode = (mode & automode) | (mode & HELP_GIVE);
sf = u->faction->allies; sf = u->faction->allies;
if (fval(u, UFL_GROUP)) { if (fval(u, UFL_GROUP)) {
const attrib * a = a_findc(u->attribs, &at_group); const attrib * a = a_findc(u->attribs, &at_group);
if (a!=NULL) sf = ((group*)a->data.v)->allies; if (a!=NULL) sf = ((group*)a->data.v)->allies;