bug 2214: drifting ships in E3 should take no damage.

This commit is contained in:
Enno Rehling 2017-12-25 23:22:19 +01:00
parent e9508d6f8e
commit a7c45d31ad
3 changed files with 26 additions and 17 deletions

View File

@ -65,6 +65,7 @@
"rules.stealth.anon_battle": false,
"rules.check_overload": false,
"rules.combat.goblinbonus": 3,
"rules.ship.damage_drift": 0.0,
"rules.alliances": true,
"rules.combat.herospeed": 3,
"rules.combat.demon_vampire": 5,

View File

@ -802,9 +802,14 @@ direction_t drift_target(ship *sh) {
static void drifting_ships(region * r)
{
bool drift = config_get_int("rules.ship.drifting", 1) != 0;
double damage_drift = config_get_flt("rules.ship.damage_drift", 0.02);
static int config;
static bool drift;
static double damage_drift;
if (config_changed(&config)) {
drift = config_get_int("rules.ship.drifting", 1) != 0;
damage_drift = config_get_flt("rules.ship.damage_drift", 0.02);
}
if (fval(r->terrain, SEA_REGION)) {
ship **shp = &r->ships;
while (*shp) {
@ -872,8 +877,9 @@ static void drifting_ships(region * r)
damage_ship(sh, damage_overload(ovl));
msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("massive_overload", "ship", sh));
}
else
else {
damage_ship(sh, damage_drift);
}
if (sh->damage >= sh->size * DAMAGE_SCALE) {
msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("shipsink", "ship", sh));
remove_ship(&sh->region->ships, sh);

View File

@ -281,8 +281,6 @@ void setup_drift (struct drift_fixture *fix) {
static void test_ship_no_overload(CuTest *tc) {
struct drift_fixture fix;
test_cleanup();
setup_drift(&fix);
fix.u->number = 2;
@ -296,8 +294,6 @@ static void test_ship_no_overload(CuTest *tc) {
static void test_ship_empty(CuTest *tc) {
struct drift_fixture fix;
test_cleanup();
setup_drift(&fix);
fix.u->ship = NULL;
ship_update_owner(fix.sh);
@ -310,10 +306,24 @@ static void test_ship_empty(CuTest *tc) {
test_cleanup();
}
static void test_ship_normal_overload(CuTest *tc) {
static void test_no_drift_damage(CuTest *tc) {
struct drift_fixture fix;
setup_drift(&fix);
fix.u->ship = NULL;
ship_update_owner(fix.sh);
config_set("rules.ship.damage_drift", "0.0");
movement();
CuAssertPtrEquals(tc, fix.sh->region, findregion(0, 0));
CuAssertIntEquals(tc, 0, ship_damage_percent(fix.sh));
CuAssertPtrEquals(tc, 0, test_find_messagetype(fix.f->msgs, "ship_drift"));
test_cleanup();
}
static void test_ship_normal_overload(CuTest *tc) {
struct drift_fixture fix;
setup_drift(&fix);
@ -329,8 +339,6 @@ static void test_ship_normal_overload(CuTest *tc) {
static void test_ship_big_overload(CuTest *tc) {
struct drift_fixture fix;
test_cleanup();
setup_drift(&fix);
fix.u->number = 22;
@ -345,8 +353,6 @@ static void test_ship_big_overload(CuTest *tc) {
static void test_ship_no_real_overload(CuTest *tc) {
struct drift_fixture fix;
test_cleanup();
setup_drift(&fix);
fix.u->number = 21;
@ -362,8 +368,6 @@ static void test_ship_no_real_overload(CuTest *tc) {
static void test_ship_ridiculous_overload(CuTest *tc) {
struct drift_fixture fix;
test_cleanup();
setup_drift(&fix);
fix.u->number = 500;
@ -377,8 +381,6 @@ static void test_ship_ridiculous_overload(CuTest *tc) {
static void test_ship_ridiculous_overload_no_captain(CuTest *tc) {
struct drift_fixture fix;
test_cleanup();
setup_drift(&fix);
set_level(fix.u, SK_SAILING, 0);
@ -393,7 +395,6 @@ static void test_ship_ridiculous_overload_no_captain(CuTest *tc) {
static void test_ship_ridiculous_overload_bad(CuTest *tc) {
struct drift_fixture fix;
test_cleanup();
setup_drift(&fix);
fix.u->number = 500;
@ -607,6 +608,7 @@ CuSuite *get_move_suite(void)
SUITE_ADD_TEST(suite, test_age_trails);
SUITE_ADD_TEST(suite, test_ship_no_overload);
SUITE_ADD_TEST(suite, test_ship_empty);
SUITE_ADD_TEST(suite, test_no_drift_damage);
SUITE_ADD_TEST(suite, test_ship_normal_overload);
SUITE_ADD_TEST(suite, test_ship_no_real_overload);
SUITE_ADD_TEST(suite, test_ship_big_overload);