Noch einmal die allianz-anzeige überarbeitet.

Da ich die Kernroutine alliedfaction() angefasst habe, muss das gut getestet werden.
This commit is contained in:
Enno Rehling 2002-12-14 15:49:18 +00:00
parent 58144e3ab5
commit 961a036d19
5 changed files with 102 additions and 86 deletions

View File

@ -86,6 +86,10 @@ LIB32=link.exe -lib
# PROP Default_Filter "*.h" # PROP Default_Filter "*.h"
# Begin Source File # Begin Source File
SOURCE=.\aggressive.h
# End Source File
# Begin Source File
SOURCE=.\attributes.h SOURCE=.\attributes.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -175,6 +179,10 @@ SOURCE=.\viewrange.h
# End Group # End Group
# Begin Source File # Begin Source File
SOURCE=.\aggressive.c
# End Source File
# Begin Source File
SOURCE=.\at_movement.c SOURCE=.\at_movement.c
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -1635,20 +1635,26 @@ order_template(FILE * F, faction * f)
} }
static void static void
show_allies(const faction * f, const ally * sf) show_allies(const faction * f, const ally * allies)
{ {
int allierte = 0; int allierte = 0;
int i=0, h, hh = 0; int i=0, h, hh = 0;
int dh = 0; int dh = 0;
const ally * sff; const ally * sf;
for (sff = sf; sff; sff = sff->next) { for (sf = allies; sf; sf = sf->next) {
if (alliedfaction(NULL, f, sf->faction, HELP_ALL) && sff->status > 0 && sff->status <= HELP_ALL) { int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL);
allierte++; #ifdef ALLIANCES
} if (f->alliance!=sf->faction->alliance) continue;
#endif
if (mode > 0) ++allierte;
} }
while (sf) { for (sf = allies; sf; sf = sf->next) {
if (alliedfaction(NULL, f, sf->faction, HELP_ALL) && sf->status > 0) { int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL);
#ifdef ALLIANCES
if (f->alliance!=sf->faction->alliance) continue;
#endif
if (mode <= 0) continue;
i++; i++;
if (dh) { if (dh) {
if (i == allierte) if (i == allierte)
@ -1660,11 +1666,11 @@ show_allies(const faction * f, const ally * sf)
hh = 0; hh = 0;
scat(factionname(sf->faction)); scat(factionname(sf->faction));
scat(" ("); scat(" (");
if (sf->status == HELP_ALL) { if (mode == HELP_ALL) {
scat("Alles"); scat("Alles");
} else } else
for (h = 1; h < HELP_ALL; h *= 2) { for (h = 1; h < HELP_ALL; h *= 2) {
if ((sf->status & h) == h) if ((mode & h) == h)
switch (h) { switch (h) {
case HELP_MONEY: case HELP_MONEY:
scat("Silber"); scat("Silber");
@ -1704,8 +1710,6 @@ show_allies(const faction * f, const ally * sf)
} }
scat(")"); scat(")");
} }
sf = sf->next;
}
} }
static void static void

View File

@ -346,8 +346,10 @@ allysfm(const side * s, const faction * f, int mode)
static int static int
allysfm(const side * s, const faction * f, int mode) allysfm(const side * s, const faction * f, int mode)
{ {
if (s->bf->faction==f) return true; if (s->bf->faction==f) return mode;
if (s->group) return alliedgroup(s->battle->plane, s->bf->faction, s->group->allies, f, mode); if (s->group) {
return alliedgroup(s->battle->plane, s->bf->faction, f, s->group->allies, mode);
}
return alliedfaction(s->battle->plane, s->bf->faction, f, mode); return alliedfaction(s->battle->plane, s->bf->faction, f, mode);
} }
#endif #endif

View File

@ -738,32 +738,31 @@ autoalliance(const plane * pl, const faction * sf, const faction * f2)
} }
static int static int
alliance(const ally * sf, const faction * f, int mode) alliance(const ally * sf, int mode)
{ {
int nmode = 0; if (sf==NULL) return 0;
while (sf) { return sf->status & mode;
if (sf->faction == f) {
nmode = sf->status & mode;
break;
}
sf = sf->next;
}
return nmode;
} }
int int
alliedgroup(const struct plane * pl, const struct faction * f, const struct ally * sf, const struct faction * f2, int mode) alliedgroup(const struct plane * pl, const struct faction * f,
{ const struct faction * f2, const struct ally * sf, int mode)
return alliance(sf, f2, mode) | (mode & autoalliance(pl, f, f2));
}
int
alliedfaction(const struct plane * pl, const faction * f, const faction * f2, int mode)
{ {
#ifdef ALLIANCES #ifdef ALLIANCES
if (f->alliance!=f2->alliance) return 0; if (f->alliance!=f2->alliance) return 0;
#endif #endif
return alliedgroup(pl, f, f->allies, f2, mode); while (sf && sf->faction!=f2) sf=sf->next;
if (sf==NULL) {
return mode & autoalliance(pl, f, f2);
}
return alliance(sf, mode) | (mode & autoalliance(pl, f, f2));
}
int
alliedfaction(const struct plane * pl, const struct faction * f,
const struct faction * f2, int mode)
{
return alliedgroup(pl, f, f2, f->allies, mode);
} }
/* Die Gruppe von Einheit u hat helfe zu f2 gesetzt. */ /* Die Gruppe von Einheit u hat helfe zu f2 gesetzt. */
@ -786,7 +785,7 @@ alliedunit(const unit * u, const faction * f2, int mode)
sf = u->faction->allies; sf = u->faction->allies;
a = a_find(u->attribs, &at_group); a = a_find(u->attribs, &at_group);
if (a!=NULL) sf = ((group*)a->data.v)->allies; if (a!=NULL) sf = ((group*)a->data.v)->allies;
return alliance(sf, f2, mode) | (mode & autoalliance(pl, u->faction, f2)); return alliance(sf, mode) | (mode & autoalliance(pl, u->faction, f2));
} }
boolean boolean

View File

@ -1020,8 +1020,11 @@ struct unit *getunit(const struct region * r, const struct faction * f);
int read_unitid(const struct faction * f, const struct region * r); int read_unitid(const struct faction * f, const struct region * r);
extern int alliedunit(const struct unit * u, const struct faction * f2, int mode); extern int alliedunit(const struct unit * u, const struct faction * f2, int mode);
extern int alliedfaction(const struct plane * pl, const struct faction * f, const struct faction * f2, int mode); extern int alliedfaction(const struct plane * pl, const struct faction * f,
extern int alliedgroup(const struct plane * pl, const struct faction * f, const struct ally * sf, const struct faction * f2, int mode); const struct faction * f2, int mode);
extern int alliedgroup(const struct plane * pl, const struct faction * f,
const struct faction * f2, const struct ally * sf,
int mode);
struct faction *findfaction(int n); struct faction *findfaction(int n);
struct faction *getfaction(void); struct faction *getfaction(void);