diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 47e4a63b4..a95dbe4cb 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1470,12 +1470,12 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace, /* u->region auch */ u->hp = unit_max_hp(u) * number; - if (!dname) { - name_unit(u); - } - else { + if (dname) { u->_name = _strdup(dname); } + else if (urace->generate_name || playerrace(urace)) { + name_unit(u); + } if (creator) { attrib *a; diff --git a/src/monsters.test.c b/src/monsters.test.c index dd69e6bdb..5e4f7138a 100644 --- a/src/monsters.test.c +++ b/src/monsters.test.c @@ -11,6 +11,7 @@ #include #include "monster.h" +#include "monsters.h" #include "guard.h" #include "reports.h" #include "skill.h" @@ -244,10 +245,24 @@ static void test_monsters_learn_exp(CuTest * tc) test_cleanup(); } +static void test_spawn_seaserpent(CuTest *tc) { + region *r; + unit *u; + faction *f; + test_cleanup(); + r = test_create_region(0, 0, 0); + f = test_create_faction(0); + u = spawn_seaserpent(r, f); + CuAssertPtrNotNull(tc, u); + CuAssertPtrEquals(tc, 0, u->_name); + test_cleanup(); +} + CuSuite *get_monsters_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_monsters_attack); + SUITE_ADD_TEST(suite, test_spawn_seaserpent); SUITE_ADD_TEST(suite, test_monsters_attack_ocean); SUITE_ADD_TEST(suite, test_seaserpent_piracy); SUITE_ADD_TEST(suite, test_monsters_waiting);