only name monsters that have a naming function. test is bad, failing.

This commit is contained in:
Enno Rehling 2016-08-31 16:43:02 +02:00
parent 9a72157cf3
commit 8a157de36c
2 changed files with 19 additions and 4 deletions

View File

@ -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;

View File

@ -11,6 +11,7 @@
#include <kernel/unit.h>
#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);