alliance-Abfragen in ifdefs gepackt,

neues Makro: ALLIED(f1, f2), funktioniert mit oder ohne Allianzen aktiviert
im Code - bitte benutzen, statt tests von hand zu machen.
This commit is contained in:
Enno Rehling 2002-10-06 07:28:36 +00:00
parent 7ef6724321
commit 20671dc2c9
4 changed files with 13 additions and 4 deletions

View File

@ -2929,10 +2929,12 @@ steal(region * r, unit * u, request ** stealorders)
return; return;
} }
#ifdef ALLIANCES
if(u->faction->alliance == u2->faction->alliance) { if(u->faction->alliance == u2->faction->alliance) {
cmistake(u, findorder(u, u->thisorder), 47, MSG_INCOME); cmistake(u, findorder(u, u->thisorder), 47, MSG_INCOME);
return; return;
} }
#endif
assert(u->region==u2->region); assert(u->region==u2->region);
if (!can_contact(r, u, u2)) { if (!can_contact(r, u, u2)) {

View File

@ -1811,7 +1811,7 @@ list_address(FILE * F, const faction * uf, const faction_list * seenfactions)
const faction * f = flist->data; const faction * f = flist->data;
if (f->no!=MONSTER_FACTION) { if (f->no!=MONSTER_FACTION) {
sprintf(buf, "%s: %s; %s", factionname(f), f->email, f->banner); sprintf(buf, "%s: %s; %s", factionname(f), f->email, f->banner);
rparagraph(F, buf, 4, (uf->alliance != NULL && f->alliance != NULL && uf->alliance == f->alliance)?'+':'*'); rparagraph(F, buf, 4, ALLIED(uf, f)?'+':'*');
} }
flist = flist->next; flist = flist->next;
} }

View File

@ -83,6 +83,11 @@ struct xml_stack;
#include <attrib.h> #include <attrib.h>
#define AT_PERSISTENT #define AT_PERSISTENT
#ifdef ALLIANCES
# define ALLIED(f1, f2) (f1->alliance && f1->alliance==f2->alliance)
#else
# define ALLIED(f1, f2) (f1==f2)
#endif
/* eressea-defined attribute-type flags */ /* eressea-defined attribute-type flags */
#define ATF_CURSE ATF_USER_DEFINED #define ATF_CURSE ATF_USER_DEFINED

View File

@ -857,7 +857,6 @@ faction_list *
get_addresses(const faction * f, const seen_region * seenregions) get_addresses(const faction * f, const seen_region * seenregions)
{ {
/* "TODO: travelthru" */ /* "TODO: travelthru" */
faction *f2;
const seen_region * sr = seenregions; const seen_region * sr = seenregions;
const faction * lastf = NULL; const faction * lastf = NULL;
faction_list * flist = calloc(1, sizeof(faction_list)); faction_list * flist = calloc(1, sizeof(faction_list));
@ -867,8 +866,9 @@ get_addresses(const faction * f, const seen_region * seenregions)
const unit * u = r->units; const unit * u = r->units;
while (u!=NULL) { while (u!=NULL) {
faction * sf = visible_faction(f, u); faction * sf = visible_faction(f, u);
if (sf && sf!=f && sf!=lastf && ((!fval(u, FL_PARTEITARNUNG) && cansee(f, r, u, 0)) boolean ballied = sf && sf!=f && sf!=lastf
|| (f->alliance != NULL && sf->alliance != NULL && f->alliance == sf->alliance))) { && !fval(u, FL_PARTEITARNUNG) && cansee(f, r, u, 0);
if (ballied || ALLIED(f, sf)) {
faction_list ** fnew = &flist; faction_list ** fnew = &flist;
while (*fnew && (*fnew)->data->no < sf->no) { while (*fnew && (*fnew)->data->no < sf->no) {
fnew =&(*fnew)->next; fnew =&(*fnew)->next;
@ -885,6 +885,7 @@ get_addresses(const faction * f, const seen_region * seenregions)
} }
sr = sr->next; sr = sr->next;
} }
#ifdef ALLIANCES
if(f->alliance != NULL) { if(f->alliance != NULL) {
for(f2 = factions; f2; f2 = f2->next) { for(f2 = factions; f2; f2 = f2->next) {
if(f2->alliance != NULL && f2->alliance == f->alliance) { if(f2->alliance != NULL && f2->alliance == f->alliance) {
@ -901,5 +902,6 @@ get_addresses(const faction * f, const seen_region * seenregions)
} }
} }
} }
#endif
return flist; return flist;
} }