fix undead name generation.

This commit is contained in:
Enno Rehling 2016-12-31 20:03:50 +01:00
parent a7f8ad052d
commit 4a802be67c
4 changed files with 4 additions and 18 deletions

View File

@ -369,10 +369,3 @@ void register_race_description_function(race_desc_func func, const char *name) {
void register_race_name_function(race_name_func func, const char *name) { void register_race_name_function(race_name_func func, const char *name) {
register_function((pf_generic)func, name); register_function((pf_generic)func, name);
} }
char * race_namegen(const struct race *rc, struct unit *u) {
if (rc->generate_name) {
rc->generate_name(u);
}
return NULL;
}

View File

@ -252,7 +252,6 @@ extern "C" {
const char *raceprefix(const struct unit *u); const char *raceprefix(const struct unit *u);
void register_race_name_function(race_name_func, const char *); void register_race_name_function(race_name_func, const char *);
void register_race_description_function(race_desc_func, const char *); void register_race_description_function(race_desc_func, const char *);
char * race_namegen(const struct race *rc, struct unit *u);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1480,15 +1480,9 @@ void default_name(const unit *u, char name[], int len) {
void name_unit(unit * u) void name_unit(unit * u)
{ {
if (u_race(u)->generate_name) { const race *rc = u_race(u);
char *gen_name = race_namegen(u_race(u), u); if (rc->generate_name) {
if (gen_name) { rc->generate_name(u);
free(u->_name);
u->_name = gen_name;
}
else {
unit_setname(u, racename(u->faction->locale, u, u_race(u)));
}
} }
else { else {
char name[32]; char name[32];

View File

@ -24,7 +24,7 @@ static void test_names(CuTest * tc)
locale_setstring(default_locale, "undead_postfix_0", "Kobolde"); locale_setstring(default_locale, "undead_postfix_0", "Kobolde");
CuAssertPtrNotNull(tc, foo = (race_name_func)get_function("nameundead")); CuAssertPtrNotNull(tc, foo = (race_name_func)get_function("nameundead"));
rc->generate_name = foo; rc->generate_name = foo;
race_namegen(rc, u); rc->generate_name(u);
CuAssertStrEquals(tc, "Graue Kobolde", u->_name); CuAssertStrEquals(tc, "Graue Kobolde", u->_name);
CuAssertPtrNotNull(tc, get_function("nameskeleton")); CuAssertPtrNotNull(tc, get_function("nameskeleton"));
CuAssertPtrNotNull(tc, get_function("namezombie")); CuAssertPtrNotNull(tc, get_function("namezombie"));