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

Function GetBadgeByLabel

src/newgrf_badge.cpp:124–130  ·  view source on GitHub ↗

* Get a badge by label if it exists. * @param label Label of badge. * @returns Badge with specified label, or nullptr if it does not exist. */

Source from the content-addressed store, hash-verified

122 * @returns Badge with specified label, or nullptr if it does not exist.
123 */
124Badge *GetBadgeByLabel(std::string_view label)
125{
126 auto it = std::ranges::find(_badges.specs, label, &Badge::label);
127 if (it == std::end(_badges.specs)) return nullptr;
128
129 return &*it;
130}
131
132/**
133 * Get the badge for a badge class index.

Callers 1

FinaliseBadgesFunction · 0.85

Calls 2

findFunction · 0.50
endFunction · 0.50

Tested by

no test coverage detected