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

Function IsValidConsoleColour

src/console_gui.cpp:538–551  ·  view source on GitHub ↗

* Check whether the given TextColour is valid for console usage. * @param c The text colour to compare to. * @return true iff the TextColour is valid for console usage. */

Source from the content-addressed store, hash-verified

536 * @return true iff the TextColour is valid for console usage.
537 */
538bool IsValidConsoleColour(TextColour c)
539{
540 /* A normal text colour is used. */
541 if (!(c & TC_IS_PALETTE_COLOUR)) return TC_BEGIN <= c && c < TC_END;
542
543 /* A text colour from the palette is used; must be the company
544 * colour gradient, so it must be one of those. */
545 c &= ~TC_IS_PALETTE_COLOUR;
546 for (Colours i = COLOUR_BEGIN; i < COLOUR_END; i++) {
547 if (GetColourGradient(i, SHADE_NORMAL).p == c) return true;
548 }
549
550 return false;
551}

Callers 4

IConsolePrintFunction · 0.85
Receive_SERVER_RCONMethod · 0.85

Calls 1

GetColourGradientFunction · 0.85

Tested by

no test coverage detected