renaming buildings should finally work again.
This commit is contained in:
Enno Rehling 2010-08-10 23:33:38 -07:00
parent beec74e0c6
commit 3d5f7a92b8
2 changed files with 29 additions and 8 deletions

View File

@ -1627,20 +1627,17 @@ rename_building(unit * u, order * ord, building * b, const char * name) {
}
if (foreign) {
unit *uo;
if (renamed_building(b)) {
cmistake(u, ord, 246, MSG_EVENT);
return -1;
}
uo = building_owner(b);
if (uo) {
if (cansee(uo->faction, u->region, u, 0)) {
ADDMSG(&uo->faction->msgs, msg_message("renamed_building_seen",
if (owner) {
if (cansee(owner->faction, u->region, u, 0)) {
ADDMSG(&owner->faction->msgs, msg_message("renamed_building_seen",
"building renamer region", b, u, u->region));
} else {
ADDMSG(&uo->faction->msgs, msg_message("renamed_building_notseen",
ADDMSG(&owner->faction->msgs, msg_message("renamed_building_notseen",
"building region", b, u->region));
}
}
@ -1651,7 +1648,7 @@ rename_building(unit * u, order * ord, building * b, const char * name) {
}
}
return rename_cmd(u, ord, &b->name, getstrtoken());
return rename_cmd(u, ord, &b->name, name);
}
static int

View File

@ -18,6 +18,29 @@ static void test_new_building_can_be_renamed(CuTest * tc) {
CuAssertTrue(tc, !renamed_building(b));
}
static void test_rename_building(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);
}
static void test_fishing_feeds_2_people(CuTest * tc) {
region * r;
faction * f;
@ -141,6 +164,7 @@ CuSuite* get_laws_suite(void)
{
CuSuite* suite = CuSuiteNew();
SUITE_ADD_TEST(suite, &test_new_building_can_be_renamed);
SUITE_ADD_TEST(suite, &test_rename_building);
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_gets_reset);