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

Function DrawTileSelectionRect

src/viewport.cpp:914–935  ·  view source on GitHub ↗

* Draws a selection rectangle on a tile. * * @param ti TileInfo Tile that is being drawn * @param pal Palette to apply. */

Source from the content-addressed store, hash-verified

912 * @param pal Palette to apply.
913 */
914static void DrawTileSelectionRect(const TileInfo *ti, PaletteID pal)
915{
916 if (!IsValidTile(ti->tile)) return;
917
918 SpriteID sel;
919 if (IsHalftileSlope(ti->tileh)) {
920 Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh);
921 SpriteID sel2 = SPR_HALFTILE_SELECTION_FLAT + halftile_corner;
922 DrawSelectionSprite(sel2, pal, ti, 7 + TILE_HEIGHT, FOUNDATION_PART_HALFTILE);
923
924 Corner opposite_corner = OppositeCorner(halftile_corner);
925 if (IsSteepSlope(ti->tileh)) {
926 sel = SPR_HALFTILE_SELECTION_DOWN;
927 } else {
928 sel = ((ti->tileh & SlopeWithOneCornerRaised(opposite_corner)) != 0 ? SPR_HALFTILE_SELECTION_UP : SPR_HALFTILE_SELECTION_FLAT);
929 }
930 sel += opposite_corner;
931 } else {
932 sel = SPR_SELECT_TILE + SlopeToSpriteOffset(ti->tileh);
933 }
934 DrawSelectionSprite(sel, pal, ti, 7, FOUNDATION_PART_NORMAL);
935}
936
937static bool IsPartOfAutoLine(int px, int py)
938{

Callers 3

DrawTileHighlightTypeFunction · 0.85
DrawTileSelectionFunction · 0.85

Calls 8

IsValidTileFunction · 0.85
IsHalftileSlopeFunction · 0.85
GetHalftileSlopeCornerFunction · 0.85
DrawSelectionSpriteFunction · 0.85
OppositeCornerFunction · 0.85
IsSteepSlopeFunction · 0.85
SlopeWithOneCornerRaisedFunction · 0.85
SlopeToSpriteOffsetFunction · 0.85

Tested by

no test coverage detected