diff --git a/core/scripts/tests/common.lua b/core/scripts/tests/common.lua index 88dae3080..cbc529d14 100755 --- a/core/scripts/tests/common.lua +++ b/core/scripts/tests/common.lua @@ -45,6 +45,29 @@ function setup() eressea.settings.set("NewbieImmunity", "0") eressea.settings.set("rules.economy.food", "4") eressea.settings.set("rules.encounters", "0") + eressea.settings.set("rules.peasants.growth", "1") +end + +function test_no_peasant_growth() + local r = region.create(0, 0, "plain") + r:set_resource("peasant", 2000) + eressea.settings.set("rules.peasants.growth", "0") + process_orders() + assert_equal(r:get_resource("peasant"), 2000) +end + +function test_demon_food() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "demon", "de") + local u = unit.create(f, r, 1) + local p = r:get_resource("peasant") + r:set_resource("peasant", 2000) + eressea.settings.set("rules.economy.food", "0") + eressea.settings.set("rules.peasants.growth", "0") + process_orders() + assert_not_nil(u) + assert_equal(1, u.number) + assert_equal(1999, r:get_resource("peasant")) end function test_fleeing_units_can_be_transported() diff --git a/core/src/bindings/bind_storage.c b/core/src/bindings/bind_storage.c index fcf45c46a..4d982e00c 100644 --- a/core/src/bindings/bind_storage.c +++ b/core/src/bindings/bind_storage.c @@ -62,12 +62,10 @@ static int tolua_storage_read_unit(lua_State * L) static int tolua_storage_write_unit(lua_State * L) { - gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); - struct unit *u = (struct unit *)tolua_tousertype(L, 2, 0); - if (global.data_version) { + gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); + struct unit *u = (struct unit *)tolua_tousertype(L, 2, 0); write_unit(data, u); - } - return 0; + return 0; } static int tolua_storage_read_float(lua_State * L) diff --git a/core/src/gamecode/laws.c b/core/src/gamecode/laws.c index c2e89b3c4..7259612b3 100755 --- a/core/src/gamecode/laws.c +++ b/core/src/gamecode/laws.c @@ -938,7 +938,9 @@ void demographics(void) * und gewandert sind */ calculate_emigration(r); - peasants(r); + if (get_param_int(global.parameters, "rules.peasants.growth", 1)) { + peasants(r); + } if (r->age > 20) { plagues(r, false); }