From 87dbd4a8336c883c7cb41d213dd98cfc2b9ba919 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 28 Apr 2024 17:53:11 +0200 Subject: [PATCH] Codechange: use ranged for loop to determine widest title --- src/league_gui.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/league_gui.cpp b/src/league_gui.cpp index 062b195212..8b52359c92 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -141,11 +141,11 @@ public: this->ordinal_width += WidgetDimensions::scaled.hsep_wide; // Keep some extra spacing uint widest_width = 0; - uint widest_title = 0; - for (uint i = 0; i < lengthof(_performance_titles); i++) { - uint width = GetStringBoundingBox(_performance_titles[i]).width; + StringID widest_title = STR_NULL; + for (auto title : _performance_titles) { + uint width = GetStringBoundingBox(title).width; if (width > widest_width) { - widest_title = i; + widest_title = title; widest_width = width; } } @@ -156,7 +156,7 @@ public: for (const Company *c : Company::Iterate()) { SetDParam(0, c->index); SetDParam(1, c->index); - SetDParam(2, _performance_titles[widest_title]); + SetDParam(2, widest_title); widest_width = std::max(widest_width, GetStringBoundingBox(STR_COMPANY_LEAGUE_COMPANY_NAME).width); }