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

Function OffsetGroundSprite

src/viewport.cpp:591–610  ·  view source on GitHub ↗

* Called when a foundation has been drawn for the current tile. * Successive ground sprites for the current tile will be drawn as child sprites of the "foundation"-ParentSprite, not as TileSprites. * * @param x sprite x-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite. * @param y sprite y-offset (screen coordinates) of ground sprites relative to the "foun

Source from the content-addressed store, hash-verified

589 * @param y sprite y-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite.
590 */
591void OffsetGroundSprite(int x, int y)
592{
593 /* Switch to next foundation part */
594 switch (_vd.foundation_part) {
595 case FOUNDATION_PART_NONE:
596 _vd.foundation_part = FOUNDATION_PART_NORMAL;
597 break;
598 case FOUNDATION_PART_NORMAL:
599 _vd.foundation_part = FOUNDATION_PART_HALFTILE;
600 break;
601 default: NOT_REACHED();
602 }
603
604 /* _vd.last_child is LAST_CHILD_NONE if foundation sprite was clipped by the viewport bounds */
605 if (_vd.last_child != LAST_CHILD_NONE) _vd.foundation[_vd.foundation_part] = static_cast<uint>(_vd.parent_sprites_to_draw.size()) - 1;
606
607 _vd.foundation_offset[_vd.foundation_part].x = x * ZOOM_BASE;
608 _vd.foundation_offset[_vd.foundation_part].y = y * ZOOM_BASE;
609 _vd.last_foundation_child[_vd.foundation_part] = _vd.last_child;
610}
611
612/**
613 * Adds a child sprite to a parent sprite.

Callers 2

DrawFoundationFunction · 0.85

Calls 2

NOT_REACHEDFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected