From 961a036d199fdcad30c401420c95093f75213325 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 14 Dec 2002 15:49:18 +0000 Subject: [PATCH] =?UTF-8?q?Noch=20einmal=20die=20allianz-anzeige=20=C3=BCb?= =?UTF-8?q?erarbeitet.=20Da=20ich=20die=20Kernroutine=20alliedfaction()=20?= =?UTF-8?q?angefasst=20habe,=20muss=20das=20gut=20getestet=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/attributes/attributes.dsp | 8 ++ src/common/gamecode/report.c | 130 ++++++++++++++------------- src/common/kernel/battle.c | 6 +- src/common/kernel/eressea.c | 37 ++++---- src/common/kernel/eressea.h | 7 +- 5 files changed, 102 insertions(+), 86 deletions(-) diff --git a/src/common/attributes/attributes.dsp b/src/common/attributes/attributes.dsp index 6eb310aa1..f470175ad 100644 --- a/src/common/attributes/attributes.dsp +++ b/src/common/attributes/attributes.dsp @@ -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 diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 174d77fb9..95fe74f54 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1635,76 +1635,80 @@ 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) { - i++; - if (dh) { - if (i == allierte) - scat(" und "); - else - scat(", "); - } - dh = 1; - hh = 0; - scat(factionname(sf->faction)); - scat(" ("); - if (sf->status == HELP_ALL) { - scat("Alles"); - } else - for (h = 1; h < HELP_ALL; h *= 2) { - if ((sf->status & h) == h) - switch (h) { - case HELP_MONEY: - scat("Silber"); - hh = 1; - break; - case HELP_FIGHT: - if (hh) - scat(", "); - scat("Kämpfe"); - hh = 1; - break; - case HELP_OBSERVE: - if (hh) - scat(", "); - scat("Wahrnehmung"); - hh = 1; - break; - case HELP_GIVE: - if (hh) - scat(", "); - scat("Gib"); - hh = 1; - break; - case HELP_GUARD: - if (hh) - scat(", "); - scat("Bewache"); - hh = 1; - break; - case HELP_FSTEALTH: - if (hh) - scat(", "); - scat("Parteitarnung"); - hh = 1; - break; - } - } - scat(")"); + 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) + scat(" und "); + else + scat(", "); } - sf = sf->next; + dh = 1; + hh = 0; + scat(factionname(sf->faction)); + scat(" ("); + if (mode == HELP_ALL) { + scat("Alles"); + } else + for (h = 1; h < HELP_ALL; h *= 2) { + if ((mode & h) == h) + switch (h) { + case HELP_MONEY: + scat("Silber"); + hh = 1; + break; + case HELP_FIGHT: + if (hh) + scat(", "); + scat("Kämpfe"); + hh = 1; + break; + case HELP_OBSERVE: + if (hh) + scat(", "); + scat("Wahrnehmung"); + hh = 1; + break; + case HELP_GIVE: + if (hh) + scat(", "); + scat("Gib"); + hh = 1; + break; + case HELP_GUARD: + if (hh) + scat(", "); + scat("Bewache"); + hh = 1; + break; + case HELP_FSTEALTH: + if (hh) + scat(", "); + scat("Parteitarnung"); + hh = 1; + break; + } + } + scat(")"); } } diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 5f6df6153..d3f31794b 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -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 diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 551e7c070..5e5c5bcee 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -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 diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index e072e58bc..9d54cc002 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -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);