From c18d75207e8e96bfa74b93749a2103f1792e51b2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 28 Aug 2016 20:31:25 +0100 Subject: [PATCH] remove a TODO: static return variable from make_names. --- src/names.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/names.c b/src/names.c index a90a90f94..1d39df792 100644 --- a/src/names.c +++ b/src/names.c @@ -77,14 +77,14 @@ static void count_particles(const char *monster, int *num_prefix, int *num_name, } } -static const char *make_names(const char *monster, int *num_postfix, +static void make_name(unit *u, const char *monster, int *num_postfix, int pprefix, int *num_name, int *num_prefix, int ppostfix) { if (*num_name == 0) { count_particles(monster, num_prefix, num_name, num_postfix); } if (*num_name > 0) { - static char name[NAMESIZE + 1]; // FIXME: static return value + char name[NAMESIZE + 1]; // FIXME: static return value char zText[32]; int uv = 0, uu = 0, un = 0; const char *str; @@ -124,37 +124,32 @@ static const char *make_names(const char *monster, int *num_postfix, strlcat(name, (const char *)str, sizeof(name)); } } - return name; + unit_setname(u, name); } - return NULL; } static void undead_name(unit * u) { static int num_postfix, num_name, num_prefix; - const char *str = make_names("undead", &num_postfix, 2, &num_name, &num_prefix, 2); - unit_setname(u, str); + make_name(u, "undead", &num_postfix, 2, &num_name, &num_prefix, 2); } static void skeleton_name(unit * u) { static int num_postfix, num_name, num_prefix; - const char *str = make_names("skeleton", &num_postfix, 5, &num_name, &num_prefix, 2); - unit_setname(u, str); + make_name(u, "skeleton", &num_postfix, 5, &num_name, &num_prefix, 2); } static void zombie_name(unit * u) { static int num_postfix, num_name, num_prefix; - const char *str = make_names("zombie", &num_postfix, 5, &num_name, &num_prefix, 2); - unit_setname(u, str); + make_name(u, "zombie", &num_postfix, 5, &num_name, &num_prefix, 2); } static void ghoul_name(unit * u) { static int num_postfix, num_name, num_prefix; - const char *str = make_names("ghoul", &num_postfix, 5, &num_name, &num_prefix, 4); - unit_setname(u, str); + make_name(u, "ghoul", &num_postfix, 5, &num_name, &num_prefix, 4); } /* Drachen */