From 4052cb71ffd804fde7fefd8fea1bdd037ea36e0e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 7 Oct 2019 22:01:02 +0200 Subject: [PATCH] Show convoy in reports. --- src/creport.c | 2 +- src/report.c | 7 +++++-- src/util/language.c | 13 +++++++++++++ src/util/language.h | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/creport.c b/src/creport.c index 4a5188108..46b998066 100644 --- a/src/creport.c +++ b/src/creport.c @@ -84,7 +84,7 @@ static char g_bigbuf[BUFFERSIZE]; bool opt_cr_absolute_coords = false; /* globals */ -#define C_REPORT_VERSION 66 +#define C_REPORT_VERSION 67 struct locale *crtag_locale(void) { static struct locale * lang; diff --git a/src/report.c b/src/report.c index 63886096e..407db00ff 100644 --- a/src/report.c +++ b/src/report.c @@ -1724,11 +1724,14 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, if (captain && captain->faction == f) { int n = 0, p = 0; + const char *stname; + getshipweight(sh, &n, &p); n = (n + 99) / 100; /* 1 Silber = 1 GE */ - sbs_printf(&sbs, "%s, %s, (%d/%d)", shipname(sh), - LOC(f->locale, sh->type->_name), n, ship_capacity(sh) / 100); + stname = locale_plural(f->locale, sh->type->_name, sh->number, true); + sbs_printf(&sbs, "%s, %d %s, (%d/%d)", shipname(sh), sh->number, + stname, n, ship_capacity(sh) / 100); } else { sbs_printf(&sbs, "%s, %s", shipname(sh), LOC(f->locale, sh->type->_name)); diff --git a/src/util/language.c b/src/util/language.c index f7894ac4e..f8dac8b39 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -129,6 +129,19 @@ const char *locale_getstring(const locale * lang, const char *key) return NULL; } +const char *locale_plural(const struct locale *lang, const char *key, int n, bool warn) { + assert(lang); + assert(key); + + if (n != 1) { + char plural[32]; + snprintf(plural, 32, "%s_p", key); + plural[31] = '\0'; + return locale_string(lang, plural, warn); + } + return locale_string(lang, key, warn); +} + const char *locale_string(const locale * lang, const char *key, bool warn) { assert(lang); diff --git a/src/util/language.h b/src/util/language.h index fce6bbebd..da1f17817 100644 --- a/src/util/language.h +++ b/src/util/language.h @@ -32,6 +32,7 @@ extern "C" { const char *locale_getstring(const struct locale *lang, const char *key); const char *locale_string(const struct locale *lang, const char *key, bool warn); /* does fallback */ + const char *locale_plural(const struct locale *lang, const char *key, int n, bool warn); unsigned int locale_index(const struct locale *lang); const char *locale_name(const struct locale *lang);