forked from github/server
BUG 2362: clone_men hitpoint calculation was wrong.
This commit is contained in:
parent
7e1f3dbdc5
commit
1c24628d62
|
@ -1060,7 +1060,7 @@ void clone_men(const unit * u, unit * dst, int n)
|
||||||
transfer_curse(u, dst, n);
|
transfer_curse(u, dst, n);
|
||||||
}
|
}
|
||||||
set_number(dst, dst->number + n);
|
set_number(dst, dst->number + n);
|
||||||
dst->hp += (long)u->hp * dst->number / u->number;
|
dst->hp += (long)u->hp * n / u->number;
|
||||||
assert(dst->hp >= dst->number);
|
assert(dst->hp >= dst->number);
|
||||||
/* TODO: Das ist schnarchlahm! und gehoert nicht hierhin */
|
/* TODO: Das ist schnarchlahm! und gehoert nicht hierhin */
|
||||||
a = a_find(dst->attribs, &at_effect);
|
a = a_find(dst->attribs, &at_effect);
|
||||||
|
|
|
@ -567,6 +567,27 @@ static void test_clone_men(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_transfermen(CuTest *tc) {
|
||||||
|
unit *u1, *u2;
|
||||||
|
region *r;
|
||||||
|
faction *f;
|
||||||
|
test_setup();
|
||||||
|
r = test_create_region(0, 0, NULL);
|
||||||
|
f = test_create_faction(NULL);
|
||||||
|
u1 = test_create_unit(f, r);
|
||||||
|
scale_number(u1, 3500);
|
||||||
|
u2 = test_create_unit(f, r);
|
||||||
|
scale_number(u2, 3500);
|
||||||
|
CuAssertIntEquals(tc, 70000, u1->hp);
|
||||||
|
CuAssertIntEquals(tc, 70000, u2->hp);
|
||||||
|
transfermen(u1, u2, u1->number);
|
||||||
|
CuAssertIntEquals(tc, 7000, u2->number);
|
||||||
|
CuAssertIntEquals(tc, 140000, u2->hp);
|
||||||
|
CuAssertIntEquals(tc, 0, u1->number);
|
||||||
|
CuAssertIntEquals(tc, 0, u1->hp);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_unit_suite(void)
|
CuSuite *get_unit_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -577,6 +598,7 @@ CuSuite *get_unit_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_update_monster_name);
|
SUITE_ADD_TEST(suite, test_update_monster_name);
|
||||||
SUITE_ADD_TEST(suite, test_clone_men);
|
SUITE_ADD_TEST(suite, test_clone_men);
|
||||||
SUITE_ADD_TEST(suite, test_clone_men_bug_2386);
|
SUITE_ADD_TEST(suite, test_clone_men_bug_2386);
|
||||||
|
SUITE_ADD_TEST(suite, test_transfermen);
|
||||||
SUITE_ADD_TEST(suite, test_remove_unit);
|
SUITE_ADD_TEST(suite, test_remove_unit);
|
||||||
SUITE_ADD_TEST(suite, test_remove_empty_units);
|
SUITE_ADD_TEST(suite, test_remove_empty_units);
|
||||||
SUITE_ADD_TEST(suite, test_remove_units_without_faction);
|
SUITE_ADD_TEST(suite, test_remove_units_without_faction);
|
||||||
|
|
Loading…
Reference in New Issue