"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 :-)
This commit is contained in:
Enno Rehling 2007-02-14 22:06:06 +00:00
parent 9da7d99f22
commit 2220f4b2c3
3 changed files with 93 additions and 37 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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) {
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;
}
}
u = u->next;
}
} else if (sr->mode<see_travel) {
const region * r = sr->r;
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)) {
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;
}
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);
}
}
}