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

Method IsVariantHidden

src/engine.cpp:486–503  ·  view source on GitHub ↗

* Check whether the engine variant chain is hidden in the GUI for the given company. * @param c Company to check. * @return \c true iff the engine variant chain is hidden in the GUI for the given company. */

Source from the content-addressed store, hash-verified

484 * @return \c true iff the engine variant chain is hidden in the GUI for the given company.
485 */
486bool Engine::IsVariantHidden(CompanyID c) const
487{
488 /* In case company is spectator. */
489 if (c >= MAX_COMPANIES) return false;
490
491 /* Shortcut if this engine is explicitly hidden. */
492 if (this->IsHidden(c)) return true;
493
494 /* Check for hidden parent variants. This is a bit convoluted as we must check hidden status of
495 * the last display variant rather than the actual parent variant. */
496 const Engine *re = this;
497 const Engine *ve = re->GetDisplayVariant();
498 while (!(ve->IsHidden(c)) && re->info.variant_id != EngineID::Invalid()) {
499 re = Engine::Get(re->info.variant_id);
500 ve = re->GetDisplayVariant();
501 }
502 return ve->IsHidden(c);
503}
504
505/**
506 * Initializes the #EngineOverrideManager with the default engines.

Callers 5

GenerateBuildShipListMethod · 0.80

Calls 3

IsHiddenMethod · 0.95
InvalidFunction · 0.85
GetDisplayVariantMethod · 0.80

Tested by

no test coverage detected