diff --git a/src/creport.c b/src/creport.c index d48c61739..325d0dec0 100644 --- a/src/creport.c +++ b/src/creport.c @@ -512,17 +512,14 @@ static void report_crtypes(FILE * F, const struct locale *lang) for (i = 0; i != MTMAXHASH; ++i) { struct known_mtype *kmt; for (kmt = mtypehash[i]; kmt; kmt = kmt->nexthash) { - const struct nrmessage_type *nrt = nrt_find(kmt->mtype); - if (nrt) { - char buffer[DISPLAYSIZE]; - int hash = (int)kmt->mtype->key; - assert(hash > 0); - fprintf(F, "MESSAGETYPE %d\n", hash); - fputc('\"', F); - fputs(str_escape(nrt_string(nrt, lang), buffer, sizeof(buffer)), F); - fputs("\";text\n", F); - fprintf(F, "\"%s\";section\n", nrt_section(nrt)); - } + char buffer[DISPLAYSIZE]; + int hash = (int)kmt->mtype->key; + assert(hash > 0); + fprintf(F, "MESSAGETYPE %d\n", hash); + fputc('\"', F); + fputs(str_escape(nrt_string(kmt->mtype, lang), buffer, sizeof(buffer)), F); + fputs("\";text\n", F); + fprintf(F, "\"%s\";section\n", nrt_section(kmt->mtype)); } while (mtypehash[i]) { kmt = mtypehash[i]; diff --git a/src/report.c b/src/report.c index 9edc8aca2..dd8b50a5d 100644 --- a/src/report.c +++ b/src/report.c @@ -723,7 +723,7 @@ rp_messages(struct stream *out, message_list * msgs, faction * viewer, int inden struct mlist *m = msgs->begin; while (m) { /* messagetype * mt = m->type; */ - if (!categorized || strcmp(nr_section(m->msg), section->name) == 0) { + if (!categorized || strcmp(nrt_section(m->msg->type), section->name) == 0) { char lbuf[8192]; if (!k && categorized) { diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index 057019242..c123add92 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -30,17 +30,18 @@ #define NRT_MAXHASH 1021 static nrmessage_type *nrtypes[NRT_MAXHASH]; -const char *nrt_string(const struct nrmessage_type *nrt, const struct locale *lang) +const char *nrt_string(const struct message_type *mtype, + const struct locale *lang) { - const char * str = locale_getstring(lang, nrt->mtype->name); + const char * str = locale_getstring(lang, mtype->name); if (!str) { - str = locale_getstring(default_locale, nrt->mtype->name); + str = locale_getstring(default_locale, mtype->name); } assert(str); return str; } -nrmessage_type *nrt_find(const struct message_type * mtype) +static nrmessage_type *nrt_find(const struct message_type * mtype) { nrmessage_type *found = NULL; unsigned int hash = mtype->key % NRT_MAXHASH; @@ -139,7 +140,7 @@ size_t size, const void *userdata) if (nrt) { const char *m = - translate(nrt_string(nrt, lang), userdata, nrt->vars, msg->parameters); + translate(nrt_string(msg->type, lang), userdata, nrt->vars, msg->parameters); if (m) { return str_strlcpy((char *)buffer, m, size); } @@ -152,14 +153,9 @@ size_t size, const void *userdata) return 0; } -const char *nr_section(const struct message *msg) -{ - nrmessage_type *nrt = nrt_find(msg->type); - return nrt ? nrt->section : NULL; -} - -const char *nrt_section(const nrmessage_type * nrt) +const char *nrt_section(const struct message_type * mtype) { + nrmessage_type *nrt = nrt_find(mtype); return nrt ? nrt->section : NULL; } diff --git a/src/util/nrmessage.h b/src/util/nrmessage.h index abb47551c..357e5d5c5 100644 --- a/src/util/nrmessage.h +++ b/src/util/nrmessage.h @@ -35,13 +35,12 @@ extern "C" { void free_nrmesssages(void); void nrt_register(const struct message_type *mtype, const char *section); - struct nrmessage_type *nrt_find(const struct message_type *); - const char *nrt_string(const struct nrmessage_type *nrt, const struct locale *lang); - const char *nrt_section(const struct nrmessage_type *nrt); + const char *nrt_string(const struct message_type *mtype, + const struct locale *lang); + const char *nrt_section(const struct message_type *mtype); size_t nr_render(const struct message *msg, const struct locale *lang, char *buffer, size_t size, const void *userdata); - const char *nr_section(const struct message *msg); #ifdef __cplusplus }