diff --git a/src/test_eressea.c b/src/test_eressea.c index 4ea68180c..a28ef9443 100644 --- a/src/test_eressea.c +++ b/src/test_eressea.c @@ -112,6 +112,7 @@ int RunAllTests(int argc, char *argv[]) /* gamecode */ ADD_SUITE(prefix); ADD_SUITE(battle); + ADD_SUITE(volcano); ADD_SUITE(donations); ADD_SUITE(travelthru); ADD_SUITE(economy); diff --git a/src/volcano.c b/src/volcano.c index 52b0bfeaa..9fb19dffd 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -30,7 +30,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include /* attributes includes */ #include @@ -237,9 +237,8 @@ volcano_destruction(region * volcano, region * r, const char *damage) remove_empty_units_in_region(r); } -void volcano_outbreak(region * r) +void volcano_outbreak(region * r, region *rn) { - region *rn; unit *u; faction *f; @@ -250,8 +249,6 @@ void volcano_outbreak(region * r) } } - /* Zufällige Nachbarregion verwüsten */ - rn = rrandneighbour(r); volcano_destruction(r, r, "4d10"); if (rn) { volcano_destruction(r, rn, "3d10"); @@ -261,31 +258,37 @@ void volcano_outbreak(region * r) void volcano_update(void) { region *r; + const struct terrain_type *t_active, *t_volcano; + + t_volcano = get_terrain("volcano"); + t_active = get_terrain("activevolcano"); /* Vulkane qualmen, brechen aus ... */ for (r = regions; r; r = r->next) { - if (r->terrain == newterrain(T_VOLCANO_SMOKING)) { + if (r->terrain == t_active) { if (a_find(r->attribs, &at_reduceproduction)) { ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); - rsetterrain(r, T_VOLCANO); + r->terrain = t_volcano; } else { // TODO: is this code path inactive? are we only keeping it for old data? fix data instead. if (rng_int() % 100 < 12) { ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); - rsetterrain(r, T_VOLCANO); + r->terrain = t_volcano; } - else if (r->age > 20 && rng_int() % 100 < 8) { - volcano_outbreak(r); - rsetterrain(r, T_VOLCANO); + else if (r->uid == 1246051340 || (r->age > 20 && rng_int() % 100 < 8)) { + region *rn; + /* Zufällige Nachbarregion verwüsten */ + rn = rrandneighbour(r); + volcano_outbreak(r, rn); + r->terrain = t_volcano; } } } - else if (r->terrain == newterrain(T_VOLCANO)) { + else if (r->terrain == t_volcano) { if (rng_int() % 100 < 4) { ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r)); - rsetterrain(r, T_VOLCANO_SMOKING); + r->terrain = t_active; } } } - } diff --git a/src/volcano.h b/src/volcano.h index 8c823a83a..d06c381cc 100644 --- a/src/volcano.h +++ b/src/volcano.h @@ -25,7 +25,7 @@ extern "C" { struct region; - void volcano_outbreak(struct region * r); + void volcano_outbreak(struct region * r, struct region *rn); void volcano_update(void); #ifdef __cplusplus diff --git a/src/volcano.test.c b/src/volcano.test.c index 61c4bb764..dd644cd22 100644 --- a/src/volcano.test.c +++ b/src/volcano.test.c @@ -29,18 +29,23 @@ static void test_volcano_update(CuTest *tc) { } static void test_volcano_outbreak(CuTest *tc) { - region *r; + region *r, *rn; const struct terrain_type *t_volcano, *t_active; test_cleanup(); t_volcano = test_create_terrain("volcano", LAND_REGION); t_active = test_create_terrain("activevolcano", LAND_REGION); r = test_create_region(0, 0, t_active); + rn = test_create_region(1, 0, t_volcano); - volcano_outbreak(r); - CuAssertPtrEquals(tc, (void *)t_volcano, (void *)r->terrain); - CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "volcanooutbreak")); + volcano_outbreak(r, rn); +// CuAssertPtrEquals(tc, (void *)t_volcano, (void *)r->terrain); + CuAssertIntEquals(tc, 0, rtrees(r, 0)); + CuAssertIntEquals(tc, 0, rtrees(r, 1)); + CuAssertIntEquals(tc, 0, rtrees(r, 2)); + CuAssertPtrNotNull(tc, test_find_messagetype(rn->msgs, "volcanooutbreak")); CuAssertPtrNotNull(tc, a_find(r->attribs, &at_reduceproduction)); + CuAssertPtrNotNull(tc, a_find(rn->attribs, &at_reduceproduction)); test_cleanup(); }