From 2220f4b2c30dc420dcda20659cd345e60fcd586a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 14 Feb 2007 22:06:06 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=1043 "Partei fehlt im cr" Bei Einheiten, die auf der Durchreise (auf dem Ozean) gesichtet wurden fehlte manchmal der entsprechende Partei-Block im cr. Das gehoert getestet, glaube ich :-) --- src/common/kernel/eressea.c | 34 +++++++++++++ src/common/kernel/eressea.h | 1 + src/common/kernel/reports.c | 95 ++++++++++++++++++++++--------------- 3 files changed, 93 insertions(+), 37 deletions(-) diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 8d603ef63..e76ce453b 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1101,6 +1101,40 @@ cansee(const faction * f, const region * r, const unit * u, int modifier) return false; } +boolean +cansee_unit(const unit * u, const unit * target, int modifier) +/* target->region kann != u->region sein, wenn es um durchreisen geht */ +{ + if (target->race == new_race[RC_SPELL] || target->number == 0) return false; + else if (target->faction == u->faction) return true; + else { + int n, rings, o; + + if (getguard(target) || usiege(target) || target->building || target->ship) { + return true; + } + + n = eff_stealth(target, target->region) - modifier; + rings = invisible(target, NULL); + if (rings==0 && n<=0) { + return true; + } + + if (rings && invisible(target, u) >= target->number) { + return false; + } + o = eff_skill(u, SK_OBSERVATION, target->region); + +#ifdef NIGHTEYES + if (u->enchanted == SP_NIGHT_EYES && o < NIGHT_EYE_TALENT) + o = NIGHT_EYE_TALENT; +#endif + if (o >= n) { + return true; + } + } + return false; +} boolean cansee_durchgezogen(const faction * f, const region * r, const unit * u, int modifier) diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index c4b9aed30..ce8591867 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -905,6 +905,7 @@ extern int atoi36(const char * s); extern boolean cansee(const struct faction * f, const struct region * r, const struct unit * u, int modifier); boolean cansee_durchgezogen(const struct faction * f, const struct region * r, const struct unit * u, int modifier); +extern boolean cansee_unit(const struct unit * u, const struct unit * target, int modifier); boolean seefaction(const struct faction * f, const struct region * r, const struct unit * u, int modifier); extern int effskill(const struct unit * u, skill_t sk); diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index df09ce8e0..b21ec6faf 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -809,6 +809,21 @@ ucansee(const struct faction *f, const struct unit *u, const struct unit *x) return x; } +static void +add_faction(faction_list ** flist, faction * sf) +{ + faction_list ** fnew = flist; + while (*fnew && (*fnew)->data->no < sf->no) { + fnew =&(*fnew)->next; + } + if ((*fnew==NULL) || (*fnew)->data!=sf) { + faction_list * finsert = malloc(sizeof(faction_list)); + finsert->next = *fnew; + *fnew = finsert; + finsert->data = sf; + } +} + static void get_addresses(report_context * ctx) { @@ -825,44 +840,50 @@ get_addresses(report_context * ctx) } for (;sr!=NULL;sr=sr->next) { - const region * r = sr->r; - const unit * u = r->units; - - while (u!=NULL) { - faction * sf = visible_faction(ctx->f, u); - boolean ballied = sf && sf!=ctx->f && sf!=lastf - && !fval(u, UFL_PARTEITARNUNG) && cansee(ctx->f, r, u, 0); - if (ballied || ALLIED(ctx->f, sf)) { - faction_list ** fnew = &flist; - while (*fnew && (*fnew)->data->no < sf->no) { - fnew =&(*fnew)->next; + if (sr->mode==see_travel) { + unit * u = r->units; + while (u) { + faction * sf = visible_faction(ctx->f, u); + assert(u->faction!=ctx->f); + if (lastf!=sf) { + attrib * a = a_find(r->attribs, &at_travelunit); + while (a && a->type==&at_travelunit) { + unit * u2 = (unit*)a->data.v; + if (u2->faction==ctx->f) { + if (cansee_unit(u2, u, 0)) { + add_faction(&flist, sf); + lastf = sf; + break; + } + } + a = a->next; + } } - if ((*fnew==NULL) || (*fnew)->data!=sf) { - faction_list * finsert = malloc(sizeof(faction_list)); - finsert->next = *fnew; - *fnew = finsert; - finsert->data = sf; - } - lastf = sf; + u = u->next; } - u = u->next; + } else if (sr->moder; + const unit * u = r->units; + while (u!=NULL) { + if (u->faction!=ctx->f) { + faction * sf = visible_faction(ctx->f, u); + boolean ballied = sf && sf!=ctx->f && sf!=lastf + && !fval(u, UFL_PARTEITARNUNG) && cansee(ctx->f, r, u, 0); + if (ballied || ALLIED(ctx->f, sf)) { + add_faction(&flist, sf); + lastf = sf; + } + } + u = u->next; + } } } if (ctx->f->alliance != NULL) { faction *f2; - for(f2 = factions; f2; f2 = f2->next) { - if(f2->alliance != NULL && f2->alliance == ctx->f->alliance) { - faction_list ** fnew = &flist; - while (*fnew && (*fnew)->data->no < f2->no) { - fnew =&(*fnew)->next; - } - if ((*fnew==NULL) || (*fnew)->data!=f2) { - faction_list * finsert = malloc(sizeof(faction_list)); - finsert->next = *fnew; - *fnew = finsert; - finsert->data = f2; - } + for (f2 = factions; f2; f2 = f2->next) { + if (f2->alliance != NULL && f2->alliance == ctx->f->alliance) { + add_faction(&flist, f2); } } } @@ -992,12 +1013,12 @@ static report_type * report_types; void register_reporttype(const char * extension, report_fun write, int flag) { - report_type * type = malloc(sizeof(report_type)); - type->extension = extension; - type->write = write; - type->flag = flag; - type->next = report_types; - report_types = type; + report_type * type = malloc(sizeof(report_type)); + type->extension = extension; + type->write = write; + type->flag = flag; + type->next = report_types; + report_types = type; } static region_list *