MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / BadgeClassLoadConfigFeature

Function BadgeClassLoadConfigFeature

src/newgrf_badge_config.cpp:138–163  ·  view source on GitHub ↗

* Load badge column preferences. * @param ini IniFile to load to. * @param feature Feature to load. */

Source from the content-addressed store, hash-verified

136 * @param feature Feature to load.
137 */
138static void BadgeClassLoadConfigFeature(const IniFile &ini, GrfSpecFeature feature)
139{
140 assert(BadgeClassConfig::CONFIGURABLE_FEATURES.Test(feature));
141 assert(!BadgeClassConfig::sections[feature].empty());
142
143 auto &config = _badge_config.features[feature];
144 config.clear();
145
146 const IniGroup *group = ini.GetGroup(BadgeClassConfig::sections[feature]);
147 if (group == nullptr) return;
148
149 for (const IniItem &item : group->items) {
150 int column = 0;
151 bool show_icon = true;
152 bool show_filter = false;
153
154 if (item.value.has_value() && !item.value.value().empty()) {
155 StringConsumer consumer(item.value.value());
156 if (consumer.ReadCharIf('?')) show_filter = true;
157 if (consumer.ReadCharIf('!')) show_icon = false;
158 if (auto value = consumer.TryReadIntegerBase<int>(10); value.has_value()) column = *value;
159 }
160
161 config.emplace_back(item.name, column, show_icon, show_filter);
162 }
163}
164
165/**
166 * Load badge column preferences.

Callers 1

BadgeClassLoadConfigFunction · 0.85

Calls 6

TestMethod · 0.80
GetGroupMethod · 0.80
ReadCharIfMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected