diff --git a/src/direction.test.c b/src/direction.test.c index b9bb06d65..c76d6f64e 100644 --- a/src/direction.test.c +++ b/src/direction.test.c @@ -1,9 +1,16 @@ #include -#include "kernel/types.h" +#include + #include "direction.h" #include "util/language.h" #include "tests.h" +#include +#include +#include +#include +#include + #include static void test_init_directions(CuTest *tc) { @@ -56,6 +63,27 @@ static void test_get_direction_default(CuTest *tc) { CuAssertIntEquals(tc, D_EAST, get_direction("east", lang)); } +static void test_move_to_vortex(CuTest *tc) { + region *r1, *r2, *r = 0; + terrain_type *t_plain; + unit *u; + struct locale *lang; + + test_cleanup(); + lang = get_or_create_locale("en"); + locale_setstring(lang, "vortex", "wirbel"); + init_locale(lang); + register_special_direction("vortex"); + t_plain = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION); + r1 = test_create_region(0, 0, t_plain); + r2 = test_create_region(5, 0, t_plain); + CuAssertPtrNotNull(tc, create_special_direction(r1, r2, 10, "", "vortex", true)); + u = test_create_unit(test_create_faction(rc_get_or_create("hodor")), r1); + CuAssertIntEquals(tc, E_MOVE_NOREGION, movewhere(u, "barf", r1, &r)); + CuAssertIntEquals(tc, E_MOVE_OK, movewhere(u, "wirbel", r1, &r)); + CuAssertPtrEquals(tc, r2, r); +} + #define SUITE_DISABLE_TEST(suite, test) (void)test CuSuite *get_direction_suite(void) @@ -64,6 +92,7 @@ CuSuite *get_direction_suite(void) SUITE_ADD_TEST(suite, test_init_direction); SUITE_ADD_TEST(suite, test_init_directions); SUITE_ADD_TEST(suite, test_finddirection); + SUITE_ADD_TEST(suite, test_move_to_vortex); SUITE_DISABLE_TEST(suite, test_get_direction_default); return suite; } diff --git a/src/kernel/region.c b/src/kernel/region.c index f75bfb46f..a172e510a 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -331,12 +331,12 @@ region *find_special_direction(const region * r, const char *token, } attrib *create_special_direction(region * r, region * rt, int duration, - const char *desc, const char *keyword) + const char *desc, const char *keyword, bool active) { attrib *a = a_add(&r->attribs, a_new(&at_direction)); spec_direction *d = (spec_direction *) (a->data.v); - d->active = false; + d->active = active; d->x = rt->x; d->y = rt->y; d->duration = duration; diff --git a/src/kernel/region.h b/src/kernel/region.h index 367d77385..39ce618c8 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -195,7 +195,7 @@ extern "C" { struct spec_direction *special_direction(const region * from, const region * to); struct attrib *create_special_direction(struct region *r, struct region *rt, - int duration, const char *desc, const char *keyword); + int duration, const char *desc, const char *keyword, bool active); int deathcount(const struct region *r); int chaoscount(const struct region *r); diff --git a/src/spells/spells.c b/src/spells/spells.c index 8ce8edbff..40a0fc482 100644 --- a/src/spells/spells.c +++ b/src/spells/spells.c @@ -3138,8 +3138,8 @@ static int sp_chaossuction(castorder * co) } /* TODO: implement with a building */ - create_special_direction(r, rt, 2, "vortex_desc", "vortex"); - create_special_direction(rt, r, 2, "vortex_desc", "vortex"); + create_special_direction(r, rt, 2, "vortex_desc", "vortex", false); + create_special_direction(rt, r, 2, "vortex_desc", "vortex", false); new_border(&bt_chaosgate, r, rt); add_message(&r->msgs, msg_message("chaosgate_effect_1", "mage", mage));