From 153f319bedf505ba51ecfeeeff0311f803e37361 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 20 Mar 2023 04:27:14 +0200 Subject: [PATCH 22/22] Fix freeciv-manual failure with native_bases cache See osdn #47607 Signed-off-by: Marko Lindqvist --- client/helpdata.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/client/helpdata.c b/client/helpdata.c index c9d2f3a8e1..b7d850721a 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -2868,16 +2868,23 @@ char *helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *targets[extra_count()]; int j = 0; - /* Extra being native one is a hard requirement */ - extra_type_list_iterate(utype_class(utype)->cache.native_bases, - pextra) { + /* Extra being native one is a hard requirement + * Not using unit class native_bases cache here. + * Sometimes it's not initialized when we run this, + * and as this is not performance critical, no point + * in using it conditionally and having this only as + * fallback implementation. */ + extra_type_by_cause_iterate(EC_BASE, pextra) { + if (!is_native_extra_to_uclass(pextra, pclass)) { + continue; + } + if (!territory_claiming_base(pextra->data.base)) { - /* Hard requirement */ continue; } targets[j++] = extra_name_translation(pextra); - } extra_type_list_iterate_end; + } extra_type_by_cause_iterate_end; if (j > 0) { struct astring list = ASTRING_INIT; -- 2.39.2