diff --git a/src/reports.c b/src/reports.c index 11d913ef5..c38fdeae0 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1135,19 +1135,24 @@ static void add_seen(region *r, seen_mode mode) { } } -static void faction_add_seen(faction *f, region *r, seen_mode mode) { +static void add_seen_nb(faction *f, region *r, seen_mode mode) { + region *first = r, *last = r; add_seen(r, mode); if (mode > seen_neighbour) { region *next[MAXDIRECTIONS]; int d; get_neighbours(r, next); for (d = 0; d != MAXDIRECTIONS; ++d) { - if (next[d] && next[d]->seen.modeseen.modeindex>rn->index) first = rn; + if (last->indexindex) last = rn; } } } - update_interval(f, r); + update_interval(f, first); + update_interval(f, last); } /** mark all regions seen by the lighthouse. @@ -1162,7 +1167,7 @@ static void prepare_lighthouse(building * b, report_context *ctx) for (ql = rlist, qi = 0; ql; ql_advance(&ql, &qi, 1)) { region *rl = (region *)ql_get(ql, qi); if (!fval(rl->terrain, FORBIDDEN_REGION)) { - faction_add_seen(f, rl, seen_lighthouse); + add_seen_nb(f, rl, seen_lighthouse); } } ql_free(rlist); @@ -1286,7 +1291,7 @@ static region *firstregion(faction * f) static void cb_add_seen(region *r, unit *u, void *cbdata) { faction *f = (faction *)cbdata; if (u->faction==f) { - faction_add_seen(f, r, seen_travel); + add_seen_nb(f, r, seen_travel); } } @@ -1327,7 +1332,7 @@ void prepare_report(report_context *ctx, faction *f) if (u && u->faction==f) { prepare_lighthouse(b, ctx); if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { - faction_add_seen(f, r, seen_unit); + add_seen_nb(f, r, seen_unit); } } } @@ -1338,7 +1343,7 @@ void prepare_report(report_context *ctx, faction *f) for (u = r->units; u; u = u->next) { if (u->faction==f) { if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) { - faction_add_seen(f, r, seen_unit); + add_seen_nb(f, r, seen_unit); } if (fval(r, RF_LIGHTHOUSE)) { if (u->building && u->building->type == bt_lighthouse && inside_building(u)) { @@ -1349,7 +1354,7 @@ void prepare_report(report_context *ctx, faction *f) } } - if (fval(r, RF_TRAVELUNIT)) { + if (fval(r, RF_TRAVELUNIT) && r->seen.modefirst); + CuAssertPtrEquals(tc, r1, f->last); travelthru_add(r2, u); + CuAssertPtrEquals(tc, r1, f->first); + CuAssertPtrEquals(tc, r3, f->last); prepare_report(&ctx, f); CuAssertPtrEquals(tc, r1, ctx.first); CuAssertPtrEquals(tc, 0, ctx.last); diff --git a/src/travelthru.c b/src/travelthru.c index 8e1fc946b..e55cacaa0 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -64,6 +64,8 @@ attrib_type at_travelunit = { */ void travelthru_add(region * r, unit * u) { + region *next[MAXDIRECTIONS]; + int d; attrib *a; quicklist *ql; @@ -84,6 +86,10 @@ void travelthru_add(region * r, unit * u) * could be in regions that are located before the [first, last] interval, * and recalculation is needed */ update_interval(u->faction, r); + get_neighbours(r, next); + for (d=0;d!=MAXDIRECTIONS;++d) { + update_interval(u->faction, next[d]); + } } bool travelthru_cansee(const struct region *r, const struct faction *f, const struct unit *u) {