mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-22 14:09:10 +00:00
Fix c2d4098afa
: Crash when accessing unconfigurable badge feature. (#14403)
Some features support badges but do not have a way to configure them. Accessing these features could crash the game.
This commit is contained in:
@@ -118,14 +118,16 @@ void ResetBadgeClassConfiguration(GrfSpecFeature feature)
|
||||
*/
|
||||
std::pair<const BadgeClassConfigItem &, int> GetBadgeClassConfigItem(GrfSpecFeature feature, std::string_view label)
|
||||
{
|
||||
auto config = GetBadgeClassConfiguration(feature);
|
||||
auto found = std::ranges::find(config, label, &BadgeClassConfigItem::label);
|
||||
if (found == std::end(config)) {
|
||||
return {BadgeClassConfig::EMPTY_CONFIG_ITEM, 0};
|
||||
if (BadgeClassConfig::CONFIGURABLE_FEATURES.Test(feature)) {
|
||||
auto config = GetBadgeClassConfiguration(feature);
|
||||
auto found = std::ranges::find(config, label, &BadgeClassConfigItem::label);
|
||||
if (found != std::end(config)) {
|
||||
/* Sort order is simply the position in the configuration list. */
|
||||
return {*found, static_cast<int>(std::distance(std::begin(config), found))};
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort order is simply the position in the configuration list. */
|
||||
return {*found, static_cast<int>(std::distance(std::begin(config), found))};
|
||||
return {BadgeClassConfig::EMPTY_CONFIG_ITEM, 0};
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user