From b2d897132b276237e5782ca7d420be8b34c56e71 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Sep 2024 20:06:53 +0200 Subject: [PATCH] bug 3033: no volcano message in oceans --- src/volcano.c | 30 +++++++++++++++--------------- src/volcano.test.c | 12 ++++++++++++ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/volcano.c b/src/volcano.c index ef69e1426..a99b8b36a 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -156,25 +156,25 @@ static region *rrandneighbour(region * r) static void volcano_destruction(region * volcano, region * r, const char *damage) { - attrib *a; unit **up; int percent = 25, time = 6 + rng_int() % 12; - rsettrees(r, 2, 0); - rsettrees(r, 1, 0); - rsettrees(r, 0, 0); - - a = a_find(r->attribs, &at_reduceproduction); - if (!a) { - a = a_add(&r->attribs, make_reduceproduction(percent, time)); - } - else { - /* Produktion vierteln ... */ - a->data.sa[0] = (short)percent; - /* Fuer 6-17 Runden */ - a->data.sa[1] = (short)(a->data.sa[1] + time); + if (r->land) { + attrib *a; + a = a_find(r->attribs, &at_reduceproduction); + if (!a) { + a = a_add(&r->attribs, make_reduceproduction(percent, time)); + } + else { + /* Produktion vierteln ... */ + a->data.sa[0] = (short)percent; + /* Fuer 6-17 Runden */ + a->data.sa[1] = (short)(a->data.sa[1] + time); + } + rsettrees(r, 2, 0); + rsettrees(r, 1, 0); + rsettrees(r, 0, 0); } - /* Personen bekommen 4W10 Punkte Schaden. */ for (up = &r->units; *up;) { diff --git a/src/volcano.test.c b/src/volcano.test.c index 61eccc7cd..64973dee9 100644 --- a/src/volcano.test.c +++ b/src/volcano.test.c @@ -167,6 +167,17 @@ static void test_volcano_damage_healing_potions(CuTest* tc) { test_teardown(); } +static void test_volcano_outbreak_ocean(CuTest *tc) { + region *r, *rn; + test_setup(); + r = test_create_plain(0, 0); + rn = test_create_ocean(0, 1); + volcano_outbreak(r, rn); + CuAssertPtrNotNull(tc, a_find(r->attribs, &at_reduceproduction)); + CuAssertPtrEquals(tc, NULL, a_find(rn->attribs, &at_reduceproduction)); + test_teardown(); +} + static void test_volcano_outbreak(CuTest *tc) { region *r, *rn; unit *u1, *u2; @@ -226,6 +237,7 @@ CuSuite *get_volcano_suite(void) SUITE_ADD_TEST(suite, test_volcano_damage_armor); SUITE_ADD_TEST(suite, test_volcano_damage_buildings); SUITE_ADD_TEST(suite, test_volcano_damage_cats); + SUITE_ADD_TEST(suite, test_volcano_outbreak_ocean); SUITE_ADD_TEST(suite, test_volcano_outbreak); return suite; }