bug 2238: respect the dragon speed multiplier.

This commit is contained in:
Enno Rehling 2017-12-26 06:26:56 +01:00
parent a7c45d31ad
commit f4e56d1512
2 changed files with 45 additions and 33 deletions

View file

@ -1388,23 +1388,20 @@ int movement_speed(const unit * u)
const race *rc = u_race(u);
double dk = rc->speed;
assert(u->number);
/* dragons have a fixed speed, and no other effects work on them: */
if (fval(rc, RCF_DRAGON)) {
return BP_DRAGON;
}
switch (old_race(u_race(u))) {
case RC_BIRTHDAYDRAGON: /* FIXME: catdragon has RCF_DRAGON, so this cannot happen */
case RC_SONGDRAGON:
if (u_race(u) == get_race(RC_SONGDRAGON)) {
mp = BP_DRAGON;
break;
default:
}
else {
if (fval(rc, RCF_DRAGON)) {
mp = BP_DRAGON;
}
else {
mp = walk_mode(u);
if (mp >= BP_RIDING) {
dk = 1.0;
}
break;
}
if (u->attribs) {
curse *c = get_curse(u->attribs, &ct_speed);
if (c != NULL) {
@ -1428,7 +1425,8 @@ int movement_speed(const unit * u)
}
}
}
}
}
return (int)(dk * mp);
}

View file

@ -592,10 +592,24 @@ static void test_route_pause(CuTest *tc) {
test_cleanup();
}
static void test_movement_speed_dragon(CuTest *tc) {
unit *u;
race *rc;
test_setup();
rc = test_create_race("dragon");
rc->flags |= RCF_DRAGON;
rc->speed = 1.5;
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
CuAssertIntEquals(tc, 6, movement_speed(u));
test_cleanup();
}
CuSuite *get_move_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_movement_speed);
SUITE_ADD_TEST(suite, test_movement_speed_dragon);
SUITE_ADD_TEST(suite, test_walkingcapacity);
SUITE_ADD_TEST(suite, test_ship_not_allowed_in_coast);
SUITE_ADD_TEST(suite, test_ship_leave_trail);