forked from github/server
Bug 2575
This commit is contained in:
parent
5d7ef85fe5
commit
7dbb417b93
2 changed files with 25 additions and 1 deletions
|
@ -729,8 +729,9 @@ static int build_stages(unit *u, const building_type *btype, int built, int n, i
|
|||
}
|
||||
else {
|
||||
/* err is the amount we built of this stage */
|
||||
built += err;
|
||||
made += err;
|
||||
if (err != con->maxsize && con->maxsize > 0) {
|
||||
if (con->maxsize > 0 && built < con->maxsize) {
|
||||
/* we did not finish the stage, can quit here */
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,28 @@ static void test_build_building_stages(CuTest *tc) {
|
|||
item_type *it_stone;
|
||||
unit *u;
|
||||
|
||||
test_setup();
|
||||
init_resources();
|
||||
it_stone = test_create_itemtype("stone");
|
||||
btype = setup_castle(it_stone);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u->building = test_create_building(u->region, btype);
|
||||
u->building->size = 1;
|
||||
set_level(u, SK_BUILDING, 2);
|
||||
i_change(&u->items, it_stone, 4);
|
||||
build_building(u, btype, -1, INT_MAX, NULL);
|
||||
CuAssertPtrNotNull(tc, u->building);
|
||||
CuAssertIntEquals(tc, 3, u->building->size);
|
||||
CuAssertIntEquals(tc, 2, i_get(u->items, it_stone));
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_build_building_stage_continue(CuTest *tc) {
|
||||
building_type *btype;
|
||||
item_type *it_stone;
|
||||
unit *u;
|
||||
|
||||
test_setup();
|
||||
init_resources();
|
||||
it_stone = test_create_itemtype("stone");
|
||||
|
@ -450,6 +472,7 @@ CuSuite *get_build_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_build_with_potion);
|
||||
SUITE_ADD_TEST(suite, test_build_building_success);
|
||||
SUITE_ADD_TEST(suite, test_build_building_stages);
|
||||
SUITE_ADD_TEST(suite, test_build_building_stage_continue);
|
||||
SUITE_ADD_TEST(suite, test_build_building_with_golem);
|
||||
SUITE_ADD_TEST(suite, test_build_building_no_materials);
|
||||
SUITE_ADD_TEST(suite, test_build_destroy_cmd);
|
||||
|
|
Loading…
Reference in a new issue