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

Function GetCustomSignalSprite

src/newgrf_railtype.cpp:131–143  ·  view source on GitHub ↗

* Get the sprite to draw for a given signal. * @param rti The rail type data (spec). * @param tile The tile to get the sprite for. * @param type Signal type. * @param var Signal variant. * @param state Signal state. * @param gui Is the sprite being used on the map or in the GUI? * @return The sprite to draw. */

Source from the content-addressed store, hash-verified

129 * @return The sprite to draw.
130 */
131SpriteID GetCustomSignalSprite(const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui)
132{
133 if (rti->group[RTSG_SIGNALS] == nullptr) return 0;
134
135 uint32_t param1 = gui ? 0x10 : 0x00;
136 uint32_t param2 = (type << 16) | (var << 8) | state;
137 RailTypeResolverObject object(rti, tile, TCX_NORMAL, RTSG_SIGNALS, param1, param2);
138
139 const auto *group = object.Resolve<ResultSpriteGroup>();
140 if (group == nullptr || group->num_sprites == 0) return 0;
141
142 return group->sprite;
143}
144
145/**
146 * Translate an index to the GRF-local railtype-translation table into a RailType.

Callers 2

DrawSingleSignalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected