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

Function AddCombinedSprite

src/viewport.cpp:623–636  ·  view source on GitHub ↗

* Adds a child sprite to a parent sprite. * In contrast to "AddChildSpriteScreen()" the sprite position is in world coordinates * * @param image the image to draw. * @param pal the provided palette. * @param x position x of the sprite. * @param y position y of the sprite. * @param z position z of the sprite. * @param sub Only draw a part of the sprite. */

Source from the content-addressed store, hash-verified

621 * @param sub Only draw a part of the sprite.
622 */
623static void AddCombinedSprite(SpriteID image, PaletteID pal, int x, int y, int z, const SubSprite *sub)
624{
625 Point pt = RemapCoords(x, y, z);
626 const Sprite *spr = GetSprite(image & SPRITE_MASK, SpriteType::Normal);
627
628 if (pt.x + spr->x_offs >= _vd.dpi.left + _vd.dpi.width ||
629 pt.x + spr->x_offs + spr->width <= _vd.dpi.left ||
630 pt.y + spr->y_offs >= _vd.dpi.top + _vd.dpi.height ||
631 pt.y + spr->y_offs + spr->height <= _vd.dpi.top)
632 return;
633
634 const ParentSpriteToDraw &pstd = _vd.parent_sprites_to_draw.back();
635 AddChildSpriteScreen(image, pal, pt.x - pstd.left, pt.y - pstd.top, false, sub, false);
636}
637
638/**
639 * Draw a (transparent) sprite at given coordinates with a given bounding box.

Callers 1

AddSortableSpriteToDrawFunction · 0.85

Calls 3

RemapCoordsFunction · 0.85
GetSpriteFunction · 0.85
AddChildSpriteScreenFunction · 0.85

Tested by

no test coverage detected