From 514565d66bba0ec0a7dc0fb5f9b55bda5ecbcd95 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 28 Aug 2016 20:02:45 +0100 Subject: [PATCH] move race_name_func registrations into race.c --- src/kernel/race.c | 4 ++++ src/kernel/race.h | 3 ++- src/names.c | 17 +++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/kernel/race.c b/src/kernel/race.c index 905464baa..8b842eecd 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_name_function(race_name_func func, const char *name) { + register_function((pf_generic)func, name); +} + char * race_namegen(const struct race *rc, const struct unit *u) { if (rc->generate_name) { const char * str = rc->generate_name(u); diff --git a/src/kernel/race.h b/src/kernel/race.h index bd7607d31..b25b4764e 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -151,7 +151,7 @@ extern "C" { struct att attack[RACE_ATTACKS]; signed char bonus[MAXSKILLS]; - const char *(*generate_name) (const struct unit *); + race_name_func generate_name; const char *(*describe) (const struct unit *, const struct locale *); void(*age) (struct unit * u); bool(*move_allowed) (const struct region *, const struct region *); @@ -261,6 +261,7 @@ extern "C" { 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 *); char * race_namegen(const struct race *rc, const struct unit *u); #ifdef __cplusplus diff --git a/src/names.c b/src/names.c index 18fad3d34..faf7d72fd 100644 --- a/src/names.c +++ b/src/names.c @@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* kernel includes */ #include +#include #include #include #include @@ -31,8 +32,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* util includes */ #include #include -#include #include +#include #include #include @@ -482,11 +483,11 @@ void register_names(void) /* function name * generate a name for a nonplayerunit * race->generate_name() */ - register_function((pf_generic)undead_name, "nameundead"); - register_function((pf_generic)skeleton_name, "nameskeleton"); - register_function((pf_generic)zombie_name, "namezombie"); - register_function((pf_generic)ghoul_name, "nameghoul"); - register_function((pf_generic)dragon_name, "namedragon"); - register_function((pf_generic)dracoid_name, "namedracoid"); - register_function((pf_generic)generic_name, "namegeneric"); + register_race_name_function(undead_name, "nameundead"); + register_race_name_function(skeleton_name, "nameskeleton"); + register_race_name_function(zombie_name, "namezombie"); + register_race_name_function(ghoul_name, "nameghoul"); + register_race_name_function(dragon_name, "namedragon"); + register_race_name_function(dracoid_name, "namedracoid"); + register_race_name_function(generic_name, "namegeneric"); }