forked from github/server
fix pathfinding
fix BENENNE FREMDE BURG
This commit is contained in:
parent
c87944afad
commit
aef98424ea
3 changed files with 26 additions and 7 deletions
|
@ -141,7 +141,7 @@ static region **internal_path_find(region * handle_start, const region * target,
|
||||||
int maxlen, bool(*allowed) (const region *, const region *))
|
int maxlen, bool(*allowed) (const region *, const region *))
|
||||||
{
|
{
|
||||||
static region *path[MAXDEPTH + 2]; /* STATIC_RETURN: used for return, not across calls */
|
static region *path[MAXDEPTH + 2]; /* STATIC_RETURN: used for return, not across calls */
|
||||||
direction_t d;
|
direction_t d = MAXDIRECTIONS;
|
||||||
node *root = new_node(handle_start, 0, NULL);
|
node *root = new_node(handle_start, 0, NULL);
|
||||||
node **handle_end = &root->next;
|
node **handle_end = &root->next;
|
||||||
node *n = root;
|
node *n = root;
|
||||||
|
@ -179,7 +179,7 @@ static region **internal_path_find(region * handle_start, const region * target,
|
||||||
n = n->next;
|
n = n->next;
|
||||||
}
|
}
|
||||||
free_nodes(root);
|
free_nodes(root);
|
||||||
if (n) {
|
if (d != MAXDIRECTIONS) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
10
src/laws.c
10
src/laws.c
|
@ -1702,7 +1702,7 @@ static int rename_cmd(unit * u, order * ord, char **s, const char *s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool try_rename(unit *u, building *b, order *ord) {
|
static bool try_rename(unit *u, building *b, order *ord) {
|
||||||
unit *owner = b ? building_owner(b) : 0;
|
unit *owner = b ? building_owner(b) : NULL;
|
||||||
bool foreign = !(owner && owner->faction == u->faction);
|
bool foreign = !(owner && owner->faction == u->faction);
|
||||||
|
|
||||||
if (!b) {
|
if (!b) {
|
||||||
|
@ -1732,12 +1732,12 @@ static bool try_rename(unit *u, building *b, order *ord) {
|
||||||
msg_message("renamed_building_notseen",
|
msg_message("renamed_building_notseen",
|
||||||
"building region", b, u->region));
|
"building region", b, u->region));
|
||||||
}
|
}
|
||||||
if (owner != u) {
|
|
||||||
cmistake(u, ord, 148, MSG_PRODUCE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (owner && owner->faction != u->faction) {
|
||||||
|
cmistake(u, ord, 148, MSG_PRODUCE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1355,6 +1355,24 @@ static void test_name_cmd(CuTest *tc) {
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_name_foreign_cmd(CuTest *tc) {
|
||||||
|
building *b;
|
||||||
|
faction *f;
|
||||||
|
region *r;
|
||||||
|
unit *u;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
u = test_create_unit(f = test_create_faction(NULL), r = test_create_region(0, 0, NULL));
|
||||||
|
b = test_create_building(u->region, NULL);
|
||||||
|
u->thisorder = create_order(K_NAME, f->locale, "%s %s %s Hodor",
|
||||||
|
LOC(f->locale, parameters[P_FOREIGN]),
|
||||||
|
LOC(f->locale, parameters[P_BUILDING]),
|
||||||
|
itoa36(b->no));
|
||||||
|
name_cmd(u, u->thisorder);
|
||||||
|
CuAssertStrEquals(tc, "Hodor", b->name);
|
||||||
|
test_teardown();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_name_cmd_2274(CuTest *tc) {
|
static void test_name_cmd_2274(CuTest *tc) {
|
||||||
unit *u1, *u2, *u3;
|
unit *u1, *u2, *u3;
|
||||||
faction *f;
|
faction *f;
|
||||||
|
@ -2155,6 +2173,7 @@ CuSuite *get_laws_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_nmr_warnings);
|
SUITE_ADD_TEST(suite, test_nmr_warnings);
|
||||||
SUITE_ADD_TEST(suite, test_ally_cmd);
|
SUITE_ADD_TEST(suite, test_ally_cmd);
|
||||||
SUITE_ADD_TEST(suite, test_name_cmd);
|
SUITE_ADD_TEST(suite, test_name_cmd);
|
||||||
|
SUITE_ADD_TEST(suite, test_name_foreign_cmd);
|
||||||
SUITE_ADD_TEST(suite, test_banner_cmd);
|
SUITE_ADD_TEST(suite, test_banner_cmd);
|
||||||
SUITE_ADD_TEST(suite, test_email_cmd);
|
SUITE_ADD_TEST(suite, test_email_cmd);
|
||||||
SUITE_ADD_TEST(suite, test_name_cmd_2274);
|
SUITE_ADD_TEST(suite, test_name_cmd_2274);
|
||||||
|
|
Loading…
Reference in a new issue