forked from github/server
Noch einmal die allianz-anzeige überarbeitet.
Da ich die Kernroutine alliedfaction() angefasst habe, muss das gut getestet werden.
This commit is contained in:
parent
58144e3ab5
commit
961a036d19
|
@ -86,6 +86,10 @@ LIB32=link.exe -lib
|
|||
# PROP Default_Filter "*.h"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\aggressive.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\attributes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -175,6 +179,10 @@ SOURCE=.\viewrange.h
|
|||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\aggressive.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\at_movement.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -1635,20 +1635,26 @@ order_template(FILE * F, faction * f)
|
|||
}
|
||||
|
||||
static void
|
||||
show_allies(const faction * f, const ally * sf)
|
||||
show_allies(const faction * f, const ally * allies)
|
||||
{
|
||||
int allierte = 0;
|
||||
int i=0, h, hh = 0;
|
||||
int dh = 0;
|
||||
const ally * sff;
|
||||
for (sff = sf; sff; sff = sff->next) {
|
||||
if (alliedfaction(NULL, f, sf->faction, HELP_ALL) && sff->status > 0 && sff->status <= HELP_ALL) {
|
||||
allierte++;
|
||||
}
|
||||
const ally * sf;
|
||||
for (sf = allies; sf; sf = sf->next) {
|
||||
int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL);
|
||||
#ifdef ALLIANCES
|
||||
if (f->alliance!=sf->faction->alliance) continue;
|
||||
#endif
|
||||
if (mode > 0) ++allierte;
|
||||
}
|
||||
|
||||
while (sf) {
|
||||
if (alliedfaction(NULL, f, sf->faction, HELP_ALL) && sf->status > 0) {
|
||||
for (sf = allies; sf; sf = sf->next) {
|
||||
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++;
|
||||
if (dh) {
|
||||
if (i == allierte)
|
||||
|
@ -1660,11 +1666,11 @@ show_allies(const faction * f, const ally * sf)
|
|||
hh = 0;
|
||||
scat(factionname(sf->faction));
|
||||
scat(" (");
|
||||
if (sf->status == HELP_ALL) {
|
||||
if (mode == HELP_ALL) {
|
||||
scat("Alles");
|
||||
} else
|
||||
for (h = 1; h < HELP_ALL; h *= 2) {
|
||||
if ((sf->status & h) == h)
|
||||
if ((mode & h) == h)
|
||||
switch (h) {
|
||||
case HELP_MONEY:
|
||||
scat("Silber");
|
||||
|
@ -1704,8 +1710,6 @@ show_allies(const faction * f, const ally * sf)
|
|||
}
|
||||
scat(")");
|
||||
}
|
||||
sf = sf->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -346,8 +346,10 @@ allysfm(const side * s, const faction * f, int mode)
|
|||
static int
|
||||
allysfm(const side * s, const faction * f, int mode)
|
||||
{
|
||||
if (s->bf->faction==f) return true;
|
||||
if (s->group) return alliedgroup(s->battle->plane, s->bf->faction, s->group->allies, f, mode);
|
||||
if (s->bf->faction==f) return 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);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -738,32 +738,31 @@ autoalliance(const plane * pl, const faction * sf, const faction * f2)
|
|||
}
|
||||
|
||||
static int
|
||||
alliance(const ally * sf, const faction * f, int mode)
|
||||
alliance(const ally * sf, int mode)
|
||||
{
|
||||
int nmode = 0;
|
||||
while (sf) {
|
||||
if (sf->faction == f) {
|
||||
nmode = sf->status & mode;
|
||||
break;
|
||||
}
|
||||
sf = sf->next;
|
||||
}
|
||||
return nmode;
|
||||
if (sf==NULL) return 0;
|
||||
return sf->status & mode;
|
||||
}
|
||||
|
||||
int
|
||||
alliedgroup(const struct plane * pl, const struct faction * f, const struct ally * sf, const struct faction * f2, 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)
|
||||
alliedgroup(const struct plane * pl, const struct faction * f,
|
||||
const struct faction * f2, const struct ally * sf, int mode)
|
||||
{
|
||||
#ifdef ALLIANCES
|
||||
if (f->alliance!=f2->alliance) return 0;
|
||||
#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. */
|
||||
|
@ -786,7 +785,7 @@ alliedunit(const unit * u, const faction * f2, int mode)
|
|||
sf = u->faction->allies;
|
||||
a = a_find(u->attribs, &at_group);
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
||||
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 alliedgroup(const struct plane * pl, const struct faction * f, const struct ally * sf, 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 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 *getfaction(void);
|
||||
|
|
Loading…
Reference in New Issue