forked from github/server
fix the test and the formula for damaged ships' speeds.
This commit is contained in:
parent
8636aabe8a
commit
bfdef37808
|
@ -300,7 +300,7 @@ int crew_skill(const ship *sh) {
|
||||||
|
|
||||||
int shipspeed(const ship * sh, const unit * u)
|
int shipspeed(const ship * sh, const unit * u)
|
||||||
{
|
{
|
||||||
double k = sh->type->range;
|
int k = sh->type->range;
|
||||||
static const struct curse_type *stormwind_ct, *nodrift_ct;
|
static const struct curse_type *stormwind_ct, *nodrift_ct;
|
||||||
static bool init;
|
static bool init;
|
||||||
attrib *a;
|
attrib *a;
|
||||||
|
@ -344,7 +344,7 @@ int shipspeed(const ship * sh, const unit * u)
|
||||||
|
|
||||||
c = get_curse(sh->attribs, ct_find("shipspeedup"));
|
c = get_curse(sh->attribs, ct_find("shipspeedup"));
|
||||||
while (c) {
|
while (c) {
|
||||||
k += curse_geteffect(c);
|
k += curse_geteffect_int(c);
|
||||||
c = c->nexthash;
|
c = c->nexthash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,12 +352,12 @@ int shipspeed(const ship * sh, const unit * u)
|
||||||
k *= SHIPSPEED;
|
k *= SHIPSPEED;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sh->damage)
|
if (sh->damage>0) {
|
||||||
k =
|
int size = sh->size * DAMAGE_SCALE;
|
||||||
(k * (sh->size * DAMAGE_SCALE - sh->damage) + sh->size * DAMAGE_SCALE -
|
k *= (size - sh->damage);
|
||||||
1) / (sh->size * DAMAGE_SCALE);
|
k = (k + size - 1) / size;
|
||||||
|
}
|
||||||
return (int)k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *shipname(const ship * sh)
|
const char *shipname(const ship * sh)
|
||||||
|
|
|
@ -505,15 +505,12 @@ static void test_shipspeed_race_bonus(CuTest *tc) {
|
||||||
static void test_shipspeed_damage(CuTest *tc) {
|
static void test_shipspeed_damage(CuTest *tc) {
|
||||||
ship *sh;
|
ship *sh;
|
||||||
unit *cap, *crew;
|
unit *cap, *crew;
|
||||||
race *rc;
|
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
sh = setup_ship();
|
sh = setup_ship();
|
||||||
setup_crew(sh, 0, &cap, &crew);
|
setup_crew(sh, 0, &cap, &crew);
|
||||||
assert(sh && cap && crew);
|
assert(sh && cap && crew);
|
||||||
|
|
||||||
rc = rc_get_or_create(cap->_race->_name);
|
|
||||||
rc->flags |= RCF_SHIPSPEED;
|
|
||||||
sh->damage = 1;
|
sh->damage = 1;
|
||||||
CuAssertIntEquals_Msg(tc, "minimally damaged ships lose no range", 2, shipspeed(sh, cap));
|
CuAssertIntEquals_Msg(tc, "minimally damaged ships lose no range", 2, shipspeed(sh, cap));
|
||||||
sh->damage = sh->size * DAMAGE_SCALE / 2;
|
sh->damage = sh->size * DAMAGE_SCALE / 2;
|
||||||
|
|
Loading…
Reference in New Issue