diff --git a/scripts/tests/e2/recruit.lua b/scripts/tests/e2/recruit.lua index 2766f195b..83c7c09ec 100644 --- a/scripts/tests/e2/recruit.lua +++ b/scripts/tests/e2/recruit.lua @@ -130,7 +130,7 @@ function test_guarded_temp_cannot_recruit() count = count + 1 end assert_equal(0, zero) - assert_equal(1, count) + assert_equal(2, count) end function test_recruit_empty() @@ -171,5 +171,5 @@ function test_recruit_empty() count = count +1 end assert_equal(0, zero) - assert_equal(1, count) + assert_equal(2, count) end diff --git a/src/laws.c b/src/laws.c index 12f06ec0b..bb32248aa 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3889,7 +3889,7 @@ typedef enum cansee_t { static enum cansee_t cansee_ex(const unit *u, const region *r, const unit *target, int stealth, int rings) { enum cansee_t result = CANSEE_HIDDEN; - if (rings > 0 && rings >= target->number) { + if (rings >= target->number) { const resource_type *rtype = get_resourcetype(R_AMULET_OF_TRUE_SEEING); if (rtype) { int amulet = i_get(u->items, rtype->itype); @@ -3995,11 +3995,7 @@ bool cansee(const faction *f, const region *r, const unit *u, int modifier) rings = invisible(u, NULL); stealth = eff_stealth(u, r) - modifier; - - if (rings > 0 && rings < u->number && stealth <= 0) { - return true; - } - + if (stealth < 0 && rings < u->number) return true; result = bsm = big_sea_monster(u, r); for (u2 = r->units; u2; u2 = u2->next) { if (u2->faction == f) { diff --git a/src/laws.test.c b/src/laws.test.c index 2572f0dfb..0d33962d1 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -2247,6 +2247,22 @@ static void test_cansee_empty(CuTest *tc) { test_teardown(); } +static void test_cansee_skillmod(CuTest *tc) { + unit *u; + faction *f; + + test_setup(); + f = test_create_faction(); + u = test_create_unit(test_create_faction(), test_create_plain(0, 0)); + + CuAssertTrue(tc, !cansee(f, u->region, u, 0)); + set_level(u, SK_STEALTH, 1); + CuAssertTrue(tc, !cansee(f, u->region, u, 1)); + CuAssertTrue(tc, cansee(f, u->region, u, 2)); + + test_teardown(); +} + /** * Hidden monsters are seen in oceans if they are big enough. @@ -3008,6 +3024,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_cansee_guard); SUITE_ADD_TEST(suite, test_cansee_temp); SUITE_ADD_TEST(suite, test_cansee_empty); + SUITE_ADD_TEST(suite, test_cansee_skillmod); SUITE_ADD_TEST(suite, test_nmr_timeout); SUITE_ADD_TEST(suite, test_long_orders); SUITE_ADD_TEST(suite, test_long_order_on_ocean); diff --git a/src/spells.c b/src/spells.c index 42da7f32d..f1b1fc6ce 100644 --- a/src/spells.c +++ b/src/spells.c @@ -4042,8 +4042,10 @@ int sp_pump(castorder * co) } for (u = rt->units; u; u = u->next) { - if (u->faction == target->faction) + if (u->faction == target->faction) { see = true; + break; + } } if (see) {