forked from github/server
fixing building renaming
http://bugs.eressea.de/view.php?id=1798 foreign/owned was swapped
This commit is contained in:
parent
592d0c377b
commit
366035510c
|
@ -1614,7 +1614,7 @@ rename_cmd(unit * u, order * ord, char **s, const char * s2)
|
||||||
static int
|
static int
|
||||||
rename_building(unit * u, order * ord, building * b, const char * name) {
|
rename_building(unit * u, order * ord, building * b, const char * name) {
|
||||||
unit * owner = b?building_owner(b):0;
|
unit * owner = b?building_owner(b):0;
|
||||||
boolean foreign = owner && owner->faction==u->faction;
|
boolean foreign = !(owner && owner->faction==u->faction);
|
||||||
|
|
||||||
if (!b) {
|
if (!b) {
|
||||||
cmistake(u, ord, u->building?6:145, MSG_EVENT);
|
cmistake(u, ord, u->building?6:145, MSG_EVENT);
|
||||||
|
|
|
@ -41,6 +41,32 @@ static void test_rename_building(CuTest * tc) {
|
||||||
CuAssertStrEquals(tc, "Villa Nagel", b->name);
|
CuAssertStrEquals(tc, "Villa Nagel", b->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_rename_building_twice(CuTest * tc) {
|
||||||
|
region * r;
|
||||||
|
building * b;
|
||||||
|
unit * u;
|
||||||
|
faction * f;
|
||||||
|
building_type * btype;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
test_create_world();
|
||||||
|
|
||||||
|
btype = bt_find("castle");
|
||||||
|
|
||||||
|
r = findregion(-1, 0);
|
||||||
|
b = new_building(btype, r, default_locale);
|
||||||
|
f = test_create_faction(rc_find("human"));
|
||||||
|
u = test_create_unit(f, r);
|
||||||
|
u->building = b;
|
||||||
|
fset(u, UFL_OWNER);
|
||||||
|
|
||||||
|
rename_building(u, NULL, b, "Villa Nagel");
|
||||||
|
CuAssertStrEquals(tc, "Villa Nagel", b->name);
|
||||||
|
|
||||||
|
rename_building(u, NULL, b, "Villa Kunterbunt");
|
||||||
|
CuAssertStrEquals(tc, "Villa Kunterbunt", b->name);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_fishing_feeds_2_people(CuTest * tc) {
|
static void test_fishing_feeds_2_people(CuTest * tc) {
|
||||||
region * r;
|
region * r;
|
||||||
faction * f;
|
faction * f;
|
||||||
|
@ -165,6 +191,7 @@ CuSuite* get_laws_suite(void)
|
||||||
CuSuite* suite = CuSuiteNew();
|
CuSuite* suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, &test_new_building_can_be_renamed);
|
SUITE_ADD_TEST(suite, &test_new_building_can_be_renamed);
|
||||||
SUITE_ADD_TEST(suite, &test_rename_building);
|
SUITE_ADD_TEST(suite, &test_rename_building);
|
||||||
|
SUITE_ADD_TEST(suite, &test_rename_building_twice);
|
||||||
SUITE_ADD_TEST(suite, &test_fishing_feeds_2_people);
|
SUITE_ADD_TEST(suite, &test_fishing_feeds_2_people);
|
||||||
SUITE_ADD_TEST(suite, &test_fishing_does_not_give_goblins_money);
|
SUITE_ADD_TEST(suite, &test_fishing_does_not_give_goblins_money);
|
||||||
SUITE_ADD_TEST(suite, &test_fishing_gets_reset);
|
SUITE_ADD_TEST(suite, &test_fishing_gets_reset);
|
||||||
|
|
|
@ -116,6 +116,7 @@ void test_create_world(void)
|
||||||
rc_human->maintenance = 10;
|
rc_human->maintenance = 10;
|
||||||
|
|
||||||
btype = calloc(sizeof(building_type), 1);
|
btype = calloc(sizeof(building_type), 1);
|
||||||
|
btype->flags = BTF_NAMECHANGE;
|
||||||
btype->_name = strdup("castle");
|
btype->_name = strdup("castle");
|
||||||
bt_register(btype);
|
bt_register(btype);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue