From d8770932f01fc99341380f23c73d2f22a0b3807c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Jan 2017 11:44:34 +0100 Subject: [PATCH] fix issue #477 (intermittent volcano) --- scripts/tests/xmas.lua | 2 ++ src/volcano.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/tests/xmas.lua b/scripts/tests/xmas.lua index 7ac4ce731..5477e08ab 100644 --- a/scripts/tests/xmas.lua +++ b/scripts/tests/xmas.lua @@ -8,6 +8,8 @@ function setup() eressea.settings.set("rules.grow.formula", "0") eressea.settings.set("rules.peasants.growth.factor", "0") eressea.settings.set("volcano.active.percent", "0") + eressea.settings.set("volcano.outbreak.percent", "0") + eressea.settings.set("volcano.stop.percent", "0") end function test_snowglobe_fail() diff --git a/src/volcano.c b/src/volcano.c index a9a4f0ba7..89a865017 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -256,11 +256,19 @@ void volcano_outbreak(region * r, region *rn) } static bool stop_smoke_chance(void) { - return rng_int() % 100 < 12; + static int cache, percent = 0; + if (config_changed(&cache)) { + percent = config_get_int("volcano.stop.percent", 12); + } + return percent!=0 && (rng_int() % 100) < percent; } static bool outbreak_chance(void) { - return rng_int() % 100 < 8; + static int cache, percent = 0; + if (config_changed(&cache)) { + percent = config_get_int("volcano.outbreak.percent", 8); + } + return percent!=0 && (rng_int() % 100) < percent; } void volcano_update(void)