diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 0b09a972b..ee8a409d8 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -34,7 +34,7 @@ Singdrachen sind von der Größe eines ausgewachsenden Tigers. Ihre Färbung reicht von schillerndem Rot, über dunkles Grün bis hin zu tiefem Schwarz. Alle bekannten Drachen dieser Art weisen eine hohe Intelligenz und ein hohes Maß an magischen Fähigkeiten auf. Wie Ihre großen Verwandten verfügen sie über einen Feuerodem. Sie lieben den Gesang und das üppige Mahl. Von Zeit zu Zeit gehen sie eine engen magisches Bund zu einem Magier ein. Wenn dies geschieht, so steht dem Magier ein äußerst loyaler und lohnender Vertrauter zur Seite. - + Song Dragons are roughly the size of a fully grown tiger. Their coloring ranges from bright red, through a dark green shade to a deep black. All known dragons of this species display a high level of intelligence and highly developed magical skills. Like their larger cousins, Song Dragons posess a firegland. They love singing and a good meal. From time to time one of these magnificent creatures will bond with a mage. When this happens, the mage is assured of a most loyal and useful familiar at his side. diff --git a/res/e3a/races.xml b/res/e3a/races.xml index aeafc4218..99c3420af 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -619,7 +619,7 @@ - + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index e91d2f6f6..201a6a797 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -602,7 +602,7 @@ regaura="1.000000" recruitcost="50000" 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 6eea8651b..4a6546f46 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -319,6 +319,10 @@ const char *dbrace(const struct race *rc) return zText; } +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 45e769648..2d1648b7d 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -45,6 +45,8 @@ extern "C" { struct param; struct spell; + extern int num_races; + typedef enum { RC_DWARF, /* 0 - Zwerg */ RC_ELF, @@ -117,8 +119,7 @@ extern "C" { int level; } att; - extern int num_races; - + typedef const char *(*race_desc_func)(const struct race *rc, const struct locale *lang); typedef void (*race_name_func)(struct unit *); typedef struct race { @@ -152,7 +153,7 @@ extern "C" { signed char bonus[MAXSKILLS]; race_name_func generate_name; - const char *(*describe) (const struct unit *, const struct locale *); + 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); @@ -168,8 +169,8 @@ extern "C" { const struct race *data; } race_list; - extern void racelist_clear(struct race_list **rl); - extern void racelist_insert(struct race_list **rl, const struct race *r); + void racelist_clear(struct race_list **rl); + void racelist_insert(struct race_list **rl, const struct race *r); struct race_list *get_familiarraces(void); @@ -178,8 +179,8 @@ extern "C" { /** TODO: compatibility hacks: **/ race_t old_race(const struct race *); - extern race *rc_get_or_create(const char *name); - extern const race *rc_find(const char *); + race *rc_get_or_create(const char *name); + const race *rc_find(const char *); void free_races(void); typedef enum name_t { NAME_SINGULAR, NAME_PLURAL, NAME_DEFINITIVE, NAME_CATEGORY } name_t; @@ -236,7 +237,6 @@ extern "C" { #define BF_INV_NONMAGIC (1<<5) /* Immun gegen nichtmagischen Schaden */ #define BF_NO_ATTACK (1<<6) /* Kann keine ATTACKIERE Befehle ausfuehren */ - int unit_old_max_hp(struct unit *u); const char *racename(const struct locale *lang, const struct unit *u, const race * rc); @@ -257,11 +257,9 @@ extern "C" { variant read_race_reference(struct storage *store); const char *raceprefix(const struct unit *u); - - void give_starting_equipment(const struct equipment *eq, - struct unit *u); const char *dbrace(const struct race *rc); void register_race_name_function(race_name_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 diff --git a/src/kernel/save.c b/src/kernel/save.c index b3bdd2c17..9cfcc0f57 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -699,6 +699,7 @@ void write_attribs(storage *store, attrib *alist, const void *owner) unit *read_unit(struct gamedata *data) { unit *u; + const race *rc; int number, n, p; order **orderp; char obuf[DISPLAYSIZE]; @@ -760,7 +761,9 @@ unit *read_unit(struct gamedata *data) u->age = (short)n; READ_TOK(data->store, rname, sizeof(rname)); - u_setrace(u, rc_find(rname)); + rc = rc_find(rname); + assert(rc); + u_setrace(u, rc); READ_TOK(data->store, rname, sizeof(rname)); if (rname[0] && skill_enabled(SK_STEALTH)) @@ -768,8 +771,8 @@ unit *read_unit(struct gamedata *data) else u->irace = NULL; - if (u_race(u)->describe) { - const char *rcdisp = u_race(u)->describe(u, u->faction->locale); + 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) { diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 1db0d7761..c2ae688f4 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -470,7 +470,7 @@ const char *u_description(const unit * u, const struct locale *lang) return u->display; } else if (u_race(u)->describe) { - return u_race(u)->describe(u, lang); + return u_race(u)->describe(u->_race, lang); } return NULL; } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index e944471f8..5075e26be 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1800,8 +1800,7 @@ static int parse_races(xmlDocPtr doc) rc->generate_name = (race_name_func)fun; } else if (strcmp((const char *)propValue, "describe") == 0) { - rc->describe = - (const char *(*)(const struct unit *, const struct locale *))fun; + 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 1d39df792..a9386ac07 100644 --- a/src/names.c +++ b/src/names.c @@ -45,9 +45,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -static const char *describe_braineater(unit * u, const struct locale *lang) +static const char *describe_race(const race * rc, const struct locale *lang) { - return LOC(lang, "describe_braineater"); + char zText[32]; + sprintf(zText, "describe_%s", rc->_name); + return LOC(lang, zText); } static void count_particles(const char *monster, int *num_prefix, int *num_name, int *num_postfix) @@ -480,7 +482,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) void register_names(void) { - register_function((pf_generic)describe_braineater, "describe_braineater"); + 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 a6dd6bb11..f50937f17 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -32,7 +32,7 @@ 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_braineater")); + CuAssertPtrNotNull(tc, get_function("describe_race")); test_cleanup(); }