From 4721a1f93ecb490fb1ecee768729792f4b8bad91 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 13 Apr 2025 18:00:41 +0100 Subject: [PATCH] Fix: Don't display badges if the class has no name. (#13994) Unnamed badges are intended to be for internal-use, not for player information. Additionally if there is no name to the class, then is causes problems when user configuration comes. --- src/newgrf_badge.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/newgrf_badge.cpp b/src/newgrf_badge.cpp index 94aa72d966..b1269a02fe 100644 --- a/src/newgrf_badge.cpp +++ b/src/newgrf_badge.cpp @@ -353,6 +353,9 @@ GUIBadgeClasses::GUIBadgeClasses(GrfSpecFeature feature) uint max_column = 0; for (BadgeClassID class_index : used.Classes()) { + const Badge *class_badge = GetClassBadge(class_index); + if (class_badge->name == STR_NULL) continue; + Dimension size = GetBadgeMaximalDimension(class_index, feature); if (size.width == 0) continue; @@ -360,9 +363,7 @@ GUIBadgeClasses::GUIBadgeClasses(GrfSpecFeature feature) bool visible = true; uint sort_order = UINT_MAX; - std::string_view label = GetClassBadge(class_index)->label; - - this->gui_classes.emplace_back(class_index, column, visible, sort_order, size, label); + this->gui_classes.emplace_back(class_index, column, visible, sort_order, size, class_badge->label); if (visible) max_column = std::max(max_column, column); }