Skip to content

Commit

Permalink
bug 3033: no volcano message in oceans
Browse files Browse the repository at this point in the history
  • Loading branch information
ennorehling committed Sep 12, 2024
1 parent 93a2faa commit b2d8971
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/volcano.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;) {
Expand Down
12 changes: 12 additions & 0 deletions src/volcano.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

0 comments on commit b2d8971

Please sign in to comment.