forked from github/server
fix marking seen_neighbour regions.
fix reports-tests that didn't think about them.
This commit is contained in:
parent
63a97d6bc0
commit
ec9d8eab1c
|
@ -1137,6 +1137,16 @@ static void add_seen(region *r, seen_mode mode) {
|
|||
|
||||
static void faction_add_seen(faction *f, region *r, seen_mode mode) {
|
||||
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.mode<seen_neighbour) {
|
||||
faction_add_seen(f, next[d], seen_neighbour);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SMART_INTERVALS
|
||||
update_interval(f, r);
|
||||
#endif
|
||||
|
@ -1154,16 +1164,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)) {
|
||||
region * next[MAXDIRECTIONS];
|
||||
int d;
|
||||
|
||||
get_neighbours(rl, next);
|
||||
faction_add_seen(f, rl, seen_lighthouse);
|
||||
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
||||
if (next[d]) {
|
||||
faction_add_seen(f, next[d], seen_neighbour);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ql_free(rlist);
|
||||
|
|
|
@ -237,7 +237,7 @@ static void test_prepare_travelthru(CuTest *tc) {
|
|||
f2 = test_create_faction(0);
|
||||
r1 = test_create_region(0, 0, 0);
|
||||
r2 = test_create_region(1, 0, 0);
|
||||
r3 = test_create_region(2, 0, 0);
|
||||
r3 = test_create_region(3, 0, 0);
|
||||
test_create_unit(f2, r1);
|
||||
test_create_unit(f2, r3);
|
||||
u = test_create_unit(f, r1);
|
||||
|
@ -253,7 +253,9 @@ static void test_prepare_travelthru(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, seen_none, r2->seen.mode);
|
||||
|
||||
prepare_report(&ctx, f2);
|
||||
CuAssertIntEquals(tc, seen_none, r2->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_unit, r1->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_neighbour, r2->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_unit, r3->seen.mode);
|
||||
CuAssertPtrEquals(tc, f2, ctx.f);
|
||||
CuAssertPtrEquals(tc, r1, ctx.first);
|
||||
CuAssertPtrEquals(tc, NULL, ctx.last);
|
||||
|
@ -295,11 +297,17 @@ void test_prepare_lighthouse_capacity(CuTest *tc) {
|
|||
prepare_report(&ctx, u1->faction);
|
||||
CuAssertPtrEquals(tc, r1, ctx.first);
|
||||
CuAssertPtrEquals(tc, NULL, ctx.last);
|
||||
CuAssertIntEquals(tc, seen_unit, r1->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
|
||||
prepare_report(&ctx, u2->faction);
|
||||
CuAssertPtrEquals(tc, r1, ctx.first);
|
||||
CuAssertPtrEquals(tc, r2, ctx.last);
|
||||
CuAssertPtrEquals(tc, 0, ctx.last);
|
||||
CuAssertIntEquals(tc, seen_unit, r1->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_neighbour, r2->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
|
@ -360,7 +368,7 @@ static void test_prepare_report(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, seen_none, r->seen.mode);
|
||||
finish_reports(&ctx);
|
||||
|
||||
r = test_create_region(1, 0, 0);
|
||||
r = test_create_region(2, 0, 0);
|
||||
CuAssertPtrEquals(tc, r, regions->next);
|
||||
prepare_report(&ctx, f);
|
||||
CuAssertPtrEquals(tc, regions, ctx.first);
|
||||
|
|
Loading…
Reference in New Issue