diff --git a/res/e3a/races.xml b/res/e3a/races.xml index ccc118877..acc002b1a 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -615,7 +615,6 @@ - diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 3cf5136a4..9f3624d70 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -602,7 +602,6 @@ regaura="1.000000" weight="100" capacity="540" speed="1.000000" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes"> - diff --git a/src/kernel/race.c b/src/kernel/race.c index 2ede414c7..1385bd932 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -542,10 +542,6 @@ variant read_race_reference(struct storage *store) return result; } -void register_race_description_function(race_desc_func func, const char *name) { - register_function((pf_generic)func, name); -} - void register_race_name_function(race_name_func func, const char *name) { register_function((pf_generic)func, name); } diff --git a/src/kernel/race.h b/src/kernel/race.h index ceb5e59d9..80f2622f3 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -112,7 +112,6 @@ extern "C" { int level; } att; - typedef const char *(*race_desc_func)(const struct race *rc, const struct locale *lang); typedef void (*race_name_func)(struct unit *); typedef struct race { @@ -145,7 +144,6 @@ extern "C" { signed char bonus[MAXSKILLS]; race_name_func generate_name; - race_desc_func describe; void(*age) (struct unit * u); bool(*move_allowed) (const struct region *, const struct region *); struct item *(*itemdrop) (const struct race *, int size); @@ -267,7 +265,6 @@ extern "C" { const char *raceprefix(const struct unit *u); void register_race_name_function(race_name_func, const char *); - void register_race_description_function(race_desc_func, const char *); #ifdef __cplusplus } diff --git a/src/kernel/save.c b/src/kernel/save.c index 3ddaf7a7c..d4045d05f 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -695,17 +695,6 @@ unit *read_unit(struct gamedata *data) else u->irace = NULL; - if (rc->describe) { - const char *rcdisp = rc->describe(rc, u->faction->locale); - if (u->display && rcdisp) { - /* see if the data file contains old descriptions */ - if (strcmp(rcdisp, u->display) == 0) { - free(u->display); - u->display = NULL; - } - } - } - READ_INT(data->store, &n); if (n > 0) { building * b = findbuilding(n); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 1acebac6d..ab1669ed9 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -531,8 +531,15 @@ const char *u_description(const unit * u, const struct locale *lang) if (u->display && u->display[0]) { return u->display; } - else if (u_race(u)->describe) { - return u_race(u)->describe(u->_race, lang); + else { + char zText[64]; + const char * d; + const race * rc = u_race(u); + snprintf(zText, sizeof(zText), "describe_%s", rc->_name); + d = locale_getstring(lang, zText); + if (d) { + return d; + } } return NULL; } diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index 16ff2890b..c187f7bab 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -390,14 +390,24 @@ static void test_limited_skills(CuTest *tc) { static void test_unit_description(CuTest *tc) { race *rc; unit *u; + struct locale *lang; + test_setup(); + lang = test_create_locale(); rc = test_create_race("hodor"); u = test_create_unit(test_create_faction(rc), test_create_region(0,0,0)); + CuAssertPtrEquals(tc, 0, u->display); - CuAssertStrEquals(tc, 0, u_description(u, u->faction->locale)); + CuAssertStrEquals(tc, 0, u_description(u, lang)); u->display = strdup("Hodor"); CuAssertStrEquals(tc, "Hodor", u_description(u, NULL)); - CuAssertStrEquals(tc, "Hodor", u_description(u, u->faction->locale)); + CuAssertStrEquals(tc, "Hodor", u_description(u, lang)); + + free(u->display); + u->display = NULL; + locale_setstring(lang, "describe_hodor", "HODOR"); + CuAssertStrEquals(tc, "HODOR", u_description(u, lang)); + test_cleanup(); } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 2cf0b42e8..44a8c161e 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1795,9 +1795,6 @@ static int parse_races(xmlDocPtr doc) if (strcmp((const char *)propValue, "name") == 0) { rc->generate_name = (race_name_func)fun; } - else if (strcmp((const char *)propValue, "describe") == 0) { - rc->describe = (race_desc_func)fun; - } else if (strcmp((const char *)propValue, "age") == 0) { rc->age = (void(*)(struct unit *))fun; } diff --git a/src/names.c b/src/names.c index cf0d9fd09..780386deb 100644 --- a/src/names.c +++ b/src/names.c @@ -45,13 +45,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -static const char *describe_race(const race * rc, const struct locale *lang) -{ - char zText[32]; - sprintf(zText, "describe_%s", rc->_name); - return locale_getstring(lang, zText); -} - static void count_particles(const char *monster, int *num_prefix, int *num_name, int *num_postfix) { char zText[32]; @@ -395,29 +388,29 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) int result; UNUSED_ARG(buflen); - /* Prüfen, ob Kurz genug */ + /* Pr�fen, ob Kurz genug */ if (strlen(s) <= maxchars) { return s; } - /* Anzahl der Wörter feststellen */ + /* Anzahl der W�rter feststellen */ while (*p != 0) { result = unicode_utf8_to_ucs4(&ucs, p, &size); assert(result == 0 || "damnit, we're not handling invalid input here!"); - /* Leerzeichen überspringen */ + /* Leerzeichen �berspringen */ while (*p != 0 && !iswalnum((wint_t)ucs)) { p += size; result = unicode_utf8_to_ucs4(&ucs, p, &size); assert(result == 0 || "damnit, we're not handling invalid input here!"); } - /* Counter erhöhen */ + /* Counter erh�hen */ if (*p != 0) ++c; - /* alnums überspringen */ + /* alnums �berspringen */ while (*p != 0 && iswalnum((wint_t)ucs)) { p += size; result = unicode_utf8_to_ucs4(&ucs, p, &size); @@ -425,10 +418,10 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) } } - /* Buchstaben pro Teilkürzel = MAX(1,max/AnzWort) */ + /* Buchstaben pro Teilk�rzel = MAX(1,max/AnzWort) */ bpt = (c > 0) ? MAX(1, maxchars / c) : 1; - /* Einzelne Wörter anspringen und jeweils die ersten BpT kopieren */ + /* Einzelne W�rter anspringen und jeweils die ersten BpT kopieren */ p = s; c = 0; @@ -438,7 +431,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) assert(result == 0 || "damnit, we're not handling invalid input here!"); while (*p != 0 && c < maxchars) { - /* Leerzeichen überspringen */ + /* Leerzeichen �berspringen */ while (*p != 0 && !iswalnum((wint_t)ucs)) { p += size; @@ -446,7 +439,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) assert(result == 0 || "damnit, we're not handling invalid input here!"); } - /* alnums übertragen */ + /* alnums �bertragen */ for (i = 0; i < bpt && *p != 0 && iswalnum((wint_t)ucs); ++i) { memcpy(bufp, p, size); @@ -458,7 +451,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) assert(result == 0 || "damnit, we're not handling invalid input here!"); } - /* Bis zum nächsten Leerzeichen */ + /* Bis zum n�chsten Leerzeichen */ while (c < maxchars && *p != 0 && iswalnum((wint_t)ucs)) { p += size; @@ -474,7 +467,6 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) void register_names(void) { - register_race_description_function(describe_race, "describe_race"); /* function name * generate a name for a nonplayerunit * race->generate_name() */ diff --git a/src/names.test.c b/src/names.test.c index 8109fc2d4..01fe0ff41 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -32,7 +32,6 @@ static void test_names(CuTest * tc) CuAssertPtrNotNull(tc, get_function("namedragon")); CuAssertPtrNotNull(tc, get_function("namedracoid")); CuAssertPtrNotNull(tc, get_function("namegeneric")); - CuAssertPtrNotNull(tc, get_function("describe_race")); test_cleanup(); }