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

Function StationPickerDrawSprite

src/station_cmd.cpp:3517–3566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3515}
3516
3517void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
3518{
3519 int32_t total_offset = 0;
3520 PaletteID pal = GetCompanyPalette(_local_company);
3521 const DrawTileSprites *t = GetStationTileLayout(st, image);
3522 const RailTypeInfo *railtype_info = nullptr;
3523
3524 if (railtype != INVALID_RAILTYPE) {
3525 railtype_info = GetRailTypeInfo(railtype);
3526 total_offset = railtype_info->GetRailtypeSpriteOffset();
3527 }
3528
3529 SpriteID img = t->ground.sprite;
3530 RailTrackOffset overlay_offset;
3531 if (railtype_info != nullptr && railtype_info->UsesOverlay() && SplitGroundSpriteForOverlay(nullptr, &img, &overlay_offset)) {
3532 SpriteID ground = GetCustomRailSprite(railtype_info, INVALID_TILE, RTSG_GROUND);
3533 DrawSprite(img, PAL_NONE, x, y);
3534 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3535 } else {
3536 DrawSprite(img + total_offset, HasBit(img, PALETTE_MODIFIER_COLOUR) ? pal : PAL_NONE, x, y);
3537 }
3538
3539 if (roadtype != INVALID_ROADTYPE) {
3540 const RoadTypeInfo *roadtype_info = GetRoadTypeInfo(roadtype);
3541 if (image >= 4) {
3542 /* Drive-through stop */
3543 uint sprite_offset = 5 - image;
3544
3545 /* Road underlay takes precedence over tram */
3546 if (roadtype_info->UsesOverlay()) {
3547 SpriteID ground = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_GROUND);
3548 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3549
3550 SpriteID overlay = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_OVERLAY);
3551 if (overlay) DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3552 } else if (RoadTypeIsTram(roadtype)) {
3553 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
3554 }
3555 } else {
3556 /* Bay stop */
3557 if (RoadTypeIsRoad(roadtype) && roadtype_info->UsesOverlay()) {
3558 SpriteID ground = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_ROADSTOP);
3559 DrawSprite(ground + image, PAL_NONE, x, y);
3560 }
3561 }
3562 }
3563
3564 /* Default waypoint has no railtype specific sprites */
3565 DrawRailTileSeqInGUI(x, y, t, (st == StationType::RailWaypoint || st == StationType::RoadWaypoint) ? 0 : total_offset, 0, pal);
3566}
3567
3568static int GetSlopePixelZ_Station(TileIndex tile, uint, uint, bool)
3569{

Callers 6

DrawTypeMethod · 0.85
DrawWidgetMethod · 0.85
DrawWaypointSpriteFunction · 0.85
DrawTypeMethod · 0.85
DrawWidgetMethod · 0.85
DrawTypeMethod · 0.85

Calls 14

GetCompanyPaletteFunction · 0.85
GetStationTileLayoutFunction · 0.85
GetRailTypeInfoFunction · 0.85
GetCustomRailSpriteFunction · 0.85
DrawSpriteFunction · 0.85
HasBitFunction · 0.85
GetRoadTypeInfoFunction · 0.85
GetCustomRoadSpriteFunction · 0.85
RoadTypeIsTramFunction · 0.85
RoadTypeIsRoadFunction · 0.85
DrawRailTileSeqInGUIFunction · 0.85

Tested by

no test coverage detected