monster name pluralization changes with u->number.

This commit is contained in:
Enno Rehling 2016-12-31 20:17:02 +01:00
parent 065439e967
commit 5b7cdc4d48
2 changed files with 7 additions and 5 deletions

View File

@ -221,11 +221,7 @@ const char *silbe3[SIL3] = {
static void generic_name(unit * u) static void generic_name(unit * u)
{ {
const char * name = rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL); unit_setname(u, NULL);
name = LOC(u->faction->locale, name);
if (name) {
unit_setname(u, name);
}
} }
static void dragon_name(unit * u) static void dragon_name(unit * u)

View File

@ -42,12 +42,18 @@ static void test_monster_names(CuTest *tc) {
test_setup(); test_setup();
register_names(); register_names();
default_locale = test_create_locale();
locale_setstring(default_locale, "race::irongolem", "Eisengolem");
locale_setstring(default_locale, "race::irongolem_p", "Eisengolems");
rc = test_create_race("irongolem"); rc = test_create_race("irongolem");
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0)); u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
CuAssertPtrNotNull(tc, u->_name); CuAssertPtrNotNull(tc, u->_name);
rc->generate_name = (race_name_func)get_function("namegeneric"); rc->generate_name = (race_name_func)get_function("namegeneric");
rc->generate_name(u); rc->generate_name(u);
CuAssertPtrEquals(tc, 0, u->_name); CuAssertPtrEquals(tc, 0, u->_name);
CuAssertStrEquals(tc, "Eisengolem", unit_getname(u));
u->number = 2;
CuAssertStrEquals(tc, "Eisengolems", unit_getname(u));
test_cleanup(); test_cleanup();
} }