forked from github/server
bug 2286: fix missing addresses.
was using cansee_unit wrong, mixed up traveler (ut) and target (u).
This commit is contained in:
parent
98447668ca
commit
7f03417c37
|
@ -1006,7 +1006,7 @@ static void cb_add_address(region *r, unit *ut, void *cbdata) {
|
|||
for (u = r->units; u; u = u->next) {
|
||||
faction *sf = visible_faction(f, u);
|
||||
assert(u->faction != f); /* if this is see_travel only, then I shouldn't be here. */
|
||||
if (data->lastf != sf && cansee_unit(u, ut, data->stealthmod)) {
|
||||
if (data->lastf != sf && cansee_unit(ut, u, data->stealthmod)) {
|
||||
add_seen_faction_i(data->flist, sf);
|
||||
data->lastf = sf;
|
||||
break;
|
||||
|
|
|
@ -317,9 +317,8 @@ static void test_get_addresses_fstealth(CuTest *tc) {
|
|||
f2 = test_create_faction(0);
|
||||
r = test_create_region(0, 0, 0);
|
||||
test_create_unit(f, r);
|
||||
test_create_unit(f1, r);
|
||||
u = test_create_unit(f2, r);
|
||||
set_factionstealth(u, f1);
|
||||
u = test_create_unit(f1, r);
|
||||
set_factionstealth(u, f2);
|
||||
|
||||
prepare_report(&ctx, f);
|
||||
CuAssertPtrEquals(tc, r, ctx.first);
|
||||
|
@ -327,8 +326,38 @@ static void test_get_addresses_fstealth(CuTest *tc) {
|
|||
get_addresses(&ctx);
|
||||
CuAssertPtrNotNull(tc, ctx.addresses);
|
||||
CuAssertTrue(tc, selist_contains(ctx.addresses, f, NULL));
|
||||
CuAssertTrue(tc, selist_contains(ctx.addresses, f1, NULL));
|
||||
CuAssertTrue(tc, ! selist_contains(ctx.addresses, f2, NULL));
|
||||
CuAssertTrue(tc, !selist_contains(ctx.addresses, f1, NULL));
|
||||
CuAssertTrue(tc, selist_contains(ctx.addresses, f2, NULL));
|
||||
CuAssertIntEquals(tc, 2, selist_length(ctx.addresses));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_get_addresses_travelthru(CuTest *tc) {
|
||||
report_context ctx;
|
||||
faction *f, *f2, *f1;
|
||||
region *r1, *r2;
|
||||
unit *u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(0);
|
||||
f1 = test_create_faction(0);
|
||||
f2 = test_create_faction(0);
|
||||
r1 = test_create_region(0, 0, 0);
|
||||
r2 = test_create_region(1, 0, 0);
|
||||
u = test_create_unit(f, r2);
|
||||
travelthru_add(r1, u);
|
||||
u = test_create_unit(f1, r1);
|
||||
set_factionstealth(u, f2);
|
||||
u->building = test_create_building(u->region, test_create_buildingtype("tower"));
|
||||
|
||||
prepare_report(&ctx, f);
|
||||
CuAssertPtrEquals(tc, r1, ctx.first);
|
||||
CuAssertPtrEquals(tc, NULL, ctx.last);
|
||||
get_addresses(&ctx);
|
||||
CuAssertPtrNotNull(tc, ctx.addresses);
|
||||
CuAssertTrue(tc, selist_contains(ctx.addresses, f, NULL));
|
||||
CuAssertTrue(tc, !selist_contains(ctx.addresses, f1, NULL));
|
||||
CuAssertTrue(tc, selist_contains(ctx.addresses, f2, NULL));
|
||||
CuAssertIntEquals(tc, 2, selist_length(ctx.addresses));
|
||||
test_cleanup();
|
||||
}
|
||||
|
@ -546,6 +575,7 @@ CuSuite *get_reports_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_prepare_travelthru);
|
||||
SUITE_ADD_TEST(suite, test_get_addresses);
|
||||
SUITE_ADD_TEST(suite, test_get_addresses_fstealth);
|
||||
SUITE_ADD_TEST(suite, test_get_addresses_travelthru);
|
||||
SUITE_ADD_TEST(suite, test_reorder_units);
|
||||
SUITE_ADD_TEST(suite, test_seen_faction);
|
||||
SUITE_ADD_TEST(suite, test_regionid);
|
||||
|
|
Loading…
Reference in New Issue