diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a1a63c15a..d704fd060 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,6 +192,7 @@ set(TESTS_SRC battle.test.c vortex.test.c tests.test.c + volcano.test.c reports.test.c seen.test.c travelthru.test.c diff --git a/src/randenc.c b/src/randenc.c index 699da5367..bff7dacb7 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -842,33 +842,8 @@ void randomevents(void) } } } - - /* Vulkane qualmen, brechen aus ... */ - for (r = regions; r; r = r->next) { - if (r->terrain == newterrain(T_VOLCANO_SMOKING)) { - if (a_find(r->attribs, &at_reduceproduction)) { - ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); - rsetterrain(r, T_VOLCANO); - } - else { - if (rng_int() % 100 < 12) { - ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); - rsetterrain(r, T_VOLCANO); - } - else if (r->age > 20 && rng_int() % 100 < 8) { - volcano_outbreak(r); - rsetterrain(r, T_VOLCANO); - } - } - } - else if (r->terrain == newterrain(T_VOLCANO)) { - if (rng_int() % 100 < 4) { - ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r)); - rsetterrain(r, T_VOLCANO_SMOKING); - } - } - } - + + volcano_update(); /* Monumente zerfallen, Schiffe verfaulen */ for (r = regions; r; r = r->next) { diff --git a/src/volcano.c b/src/volcano.c index b9fc1fc16..d035d4a23 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -30,6 +30,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include /* attributes includes */ #include @@ -257,3 +258,33 @@ void volcano_outbreak(region * r) } } +void volcano_update(void) +{ + region *r; + /* Vulkane qualmen, brechen aus ... */ + for (r = regions; r; r = r->next) { + if (r->terrain == newterrain(T_VOLCANO_SMOKING)) { + if (a_find(r->attribs, &at_reduceproduction)) { + ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); + rsetterrain(r, T_VOLCANO); + } + else { + if (rng_int() % 100 < 12) { + ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); + rsetterrain(r, T_VOLCANO); + } + else if (r->age > 20 && rng_int() % 100 < 8) { + volcano_outbreak(r); + rsetterrain(r, T_VOLCANO); + } + } + } + else if (r->terrain == newterrain(T_VOLCANO)) { + if (rng_int() % 100 < 4) { + ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r)); + rsetterrain(r, T_VOLCANO_SMOKING); + } + } + } + +} diff --git a/src/volcano.h b/src/volcano.h index 0521b4292..8c823a83a 100644 --- a/src/volcano.h +++ b/src/volcano.h @@ -26,7 +26,8 @@ extern "C" { struct region; void volcano_outbreak(struct region * r); - + void volcano_update(void); + #ifdef __cplusplus } #endif diff --git a/src/volcano.test.c b/src/volcano.test.c new file mode 100644 index 000000000..3ce799961 --- /dev/null +++ b/src/volcano.test.c @@ -0,0 +1,17 @@ +#include +#include "volcano.h" + +#include + +static void test_volcano_update(CuTest *tc) { + test_cleanup(); + volcano_update(); + test_cleanup(); +} + +CuSuite *get_volcano_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_volcano_update); + return suite; +}