diff --git a/src/bind_faction.c b/src/bind_faction.c index 8dbdc3871..010bd0f12 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -297,7 +297,7 @@ static int tolua_faction_set_origin(lua_State * L) plane *pl = rplane(r); int id = pl ? pl->id : 0; - set_ursprung(f, id, r->x - plane_center_x(pl), r->y - plane_center_y(pl)); + set_origin(f, id, r->x - plane_center_x(pl), r->y - plane_center_y(pl)); return 0; } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 139f0e06c..72643c3cb 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -257,7 +257,7 @@ unit *addplayer(region * r, faction * f) char buffer[32]; assert(f->units == NULL); - set_ursprung(f, 0, r->x, r->y); + set_origin(f, 0, r->x, r->y); u = create_unit(r, f, 1, f->race, 0, NULL, NULL); equip_items(&u->faction->items, get_equipment("new_faction")); equip_unit(u, get_equipment("first_unit")); diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 94c6a77c1..4852b08dc 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -109,6 +110,20 @@ static void test_get_monsters(CuTest *tc) { test_cleanup(); } +static void test_set_origin(CuTest *tc) { + faction *f; + + test_cleanup(); + test_create_world(); + f = test_create_faction(0); + CuAssertPtrEquals(tc, 0, f->ursprung); + set_origin(f, 0, 1, 1); + CuAssertIntEquals(tc, 0, f->ursprung->id); + CuAssertIntEquals(tc, 1, f->ursprung->x); + CuAssertIntEquals(tc, 1, f->ursprung->y); + test_cleanup(); +} + CuSuite *get_faction_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -117,5 +132,6 @@ CuSuite *get_faction_suite(void) SUITE_ADD_TEST(suite, test_remove_empty_factions_allies); SUITE_ADD_TEST(suite, test_remove_dead_factions); SUITE_ADD_TEST(suite, test_get_monsters); + SUITE_ADD_TEST(suite, test_set_origin); return suite; } diff --git a/src/kernel/plane.c b/src/kernel/plane.c index 6be95f41b..f610a4a64 100644 --- a/src/kernel/plane.c +++ b/src/kernel/plane.c @@ -136,7 +136,7 @@ ursprung_x(const faction * f, const plane * pl, const region * rdefault) } if (!rdefault) return 0; - set_ursprung((faction *)f, id, rdefault->x - plane_center_x(pl), + set_origin((faction *)f, id, rdefault->x - plane_center_x(pl), rdefault->y - plane_center_y(pl)); return rdefault->x - plane_center_x(pl); } @@ -159,7 +159,7 @@ ursprung_y(const faction * f, const plane * pl, const region * rdefault) } if (!rdefault) return 0; - set_ursprung((faction *)f, id, rdefault->x - plane_center_x(pl), + set_origin((faction *)f, id, rdefault->x - plane_center_x(pl), rdefault->y - plane_center_y(pl)); return rdefault->y - plane_center_y(pl); } @@ -221,7 +221,7 @@ const region * r) *y = ny; } -void set_ursprung(faction * f, int id, int x, int y) +void set_origin(faction * f, int id, int x, int y) { ursprung *ur; assert(f != NULL); diff --git a/src/kernel/plane.h b/src/kernel/plane.h index 3ef387754..76c10fdca 100644 --- a/src/kernel/plane.h +++ b/src/kernel/plane.h @@ -70,7 +70,7 @@ extern "C" { struct plane *getplanebyid(int id); int plane_center_x(const struct plane *pl); int plane_center_y(const struct plane *pl); - void set_ursprung(struct faction *f, int id, int x, int y); + void set_origin(struct faction *f, int id, int x, int y); struct plane *create_new_plane(int id, const char *name, int minx, int maxx, int miny, int maxy, int flags); struct plane *getplanebyname(const char *); diff --git a/src/kernel/save.c b/src/kernel/save.c index ef89b9daf..d9a18f2b3 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1250,7 +1250,7 @@ faction *readfaction(struct gamedata * data) READ_INT(data->store, &id); READ_INT(data->store, &ux); READ_INT(data->store, &uy); - set_ursprung(f, id, ux, uy); + set_origin(f, id, ux, uy); } f->newbies = 0; diff --git a/src/laws.c b/src/laws.c index 9a1358733..59416cbfb 100755 --- a/src/laws.c +++ b/src/laws.c @@ -2544,7 +2544,7 @@ int origin_cmd(unit * u, struct order *ord) px = (short)getint(); py = (short)getint(); - set_ursprung(u->faction, getplaneid(u->region), px, py); + set_origin(u->faction, getplaneid(u->region), px, py); return 0; }