diff --git a/res/core/messages.xml b/res/core/messages.xml index 448fdcee1..63a37752b 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -2596,6 +2596,18 @@ + + + + + + + + + + + + diff --git a/res/translations/messages.de.po b/res/translations/messages.de.po index 7e373f16b..623a9e88a 100644 --- a/res/translations/messages.de.po +++ b/res/translations/messages.de.po @@ -941,6 +941,12 @@ msgstr "\"$unit($unit) in $region($region) bläst das Horn des Tanzes, doch niem msgid "malnourish" msgstr "\"$unit($unit) in $region($region) wird durch unzureichende Nahrung geschwächt.\"" +msgid "malnourish_demon" +msgstr "\"$unit($unit) in $region($region) wird durch unzureichende Opfer geschwächt.\"" + +msgid "malnourish_insect" +msgstr "\"$unit($unit) wird durch die extreme Kälte in $region($region) geschwächt.\"" + msgid "iceberg_land" msgstr "\"Der Eisberg $region($region) treibt an eine Küste.\"" diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po index c14a38365..e79148570 100644 --- a/res/translations/messages.en.po +++ b/res/translations/messages.en.po @@ -939,7 +939,13 @@ msgid "hornofpeace_r_nosuccess" msgstr "\"$unit($unit) in $region($region) blows the Horn of Dancing, but nobody here gets into the mood.\"" msgid "malnourish" -msgstr "\"$unit($unit) is weakened due to malnourishment.\"" +msgstr "\"$unit($unit) in $region($region) is weakened due to malnourishment.\"" + +msgid "malnourish_demon" +msgstr "\"$unit($unit) is weakened due to lack of victims in $region($region).\"" + +msgid "malnourish_insect" +msgstr "\"$unit($unit) is weakened due to the cold in $region($region).\"" msgid "iceberg_land" msgstr "\"The iceberg $region($region) drifts onto a coast.\"" diff --git a/src/laws.test.c b/src/laws.test.c index 0d33962d1..9558422a6 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -2069,7 +2069,35 @@ static void test_demon_hunger(CuTest * tc) get_food(r); CuAssertIntEquals(tc, 10, i_get(u->items, rtype->itype)); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "malnourish")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "malnourish_demon")); + + test_teardown(); +} + +static void test_insect_hunger(CuTest * tc) +{ + const resource_type *rtype; + region *r; + race *rc; + faction *f; + unit *u; + + test_setup(); + config_set("hunger.damage", NULL); + init_resources(); + r = test_create_region(0, 0, test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION)); + rc = test_create_race("insect"); + f = test_create_faction_ex(rc, NULL); + u = test_create_unit(f, r); + u->hp = 999; + + rtype = get_resourcetype(R_SILVER); + i_change(&u->items, rtype->itype, 20); + + get_food(r); + + CuAssertIntEquals(tc, 10, i_get(u->items, rtype->itype)); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "malnourish_insect")); test_teardown(); } @@ -3016,6 +3044,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_repopulate_income_based); SUITE_ADD_TEST(suite, test_repopulate_blocked); SUITE_ADD_TEST(suite, test_demon_hunger); + SUITE_ADD_TEST(suite, test_insect_hunger); SUITE_ADD_TEST(suite, test_armedmen); SUITE_ADD_TEST(suite, test_cansee); SUITE_ADD_TEST(suite, test_cansee_ring); diff --git a/src/upkeep.c b/src/upkeep.c index 8e0b412cc..8cff97d04 100644 --- a/src/upkeep.c +++ b/src/upkeep.c @@ -68,7 +68,7 @@ static const char *hunger_damage(const race *rc) { return damage; } -static bool hunger(int number, unit * u) +static bool hunger(int number, unit * u, const char *reason) { region *r = u->region; int dead = 0, hpsub = 0; @@ -105,7 +105,7 @@ static bool hunger(int number, unit * u) /* Meldung nur, wenn noch keine fuer Tote generiert. */ if (dead == 0) { /* Durch unzureichende Ernaehrung wird %s geschwaecht */ - ADDMSG(&u->faction->msgs, msg_message("malnourish", "unit region", u, r)); + ADDMSG(&u->faction->msgs, msg_message(reason, "unit region", u, r)); } } return (dead || hpsub); @@ -234,7 +234,7 @@ void get_food(region * r) int lspp = lifestyle(u) / u->number; if (lspp > 0) { int number = (need + lspp - 1) / lspp; - if (hunger(number, u)) + if (hunger(number, u, "malnourish")) fset(u, UFL_HUNGER); } } @@ -288,7 +288,7 @@ void get_food(region * r) if (hungry > 0) { if (demon_hunger) { /* demons who don't feed are hungry */ - if (hunger(hungry, u)) + if (hunger(hungry, u, "malnourish_demon")) fset(u, UFL_HUNGER); } else { @@ -301,7 +301,7 @@ void get_food(region * r) else if (is_cold && rc == rc_insect) { /* insects in glaciers get hunger damage */ if (!is_cursed(u->attribs, &ct_insectfur)) { - if (hunger(u->number, u)) { + if (hunger(u->number, u, "malnourish_insect")) { fset(u, UFL_HUNGER); } }