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

Function AppendCopyableBadgeList

src/newgrf_badge.cpp:250–264  ·  view source on GitHub ↗

* Append copyable badges from a list onto another. * Badges must exist and be marked with the Copy flag. * @param dst Destination badge list. * @param src Source badge list. * @param feature Feature of list. */

Source from the content-addressed store, hash-verified

248 * @param feature Feature of list.
249 */
250void AppendCopyableBadgeList(std::vector<BadgeID> &dst, std::span<const BadgeID> src, GrfSpecFeature feature)
251{
252 for (const BadgeID &index : src) {
253 /* Is badge already present? */
254 if (std::ranges::find(dst, index) != std::end(dst)) continue;
255
256 /* Is badge copyable? */
257 Badge *badge = GetBadge(index);
258 if (badge == nullptr) continue;
259 if (!badge->flags.Test(BadgeFlag::Copy)) continue;
260
261 dst.push_back(index);
262 badge->features.Set(feature);
263 }
264}
265
266/** Apply features from all badges to their badge classes. */
267void ApplyBadgeFeaturesToClassBadges()

Callers 1

FinaliseEngineArrayFunction · 0.85

Calls 6

GetBadgeFunction · 0.85
TestMethod · 0.80
push_backMethod · 0.80
findFunction · 0.50
endFunction · 0.50
SetMethod · 0.45

Tested by

no test coverage detected