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

Function DrawClearLandFence

src/clear_cmd.cpp:67–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67static void DrawClearLandFence(const TileInfo *ti)
68{
69 /* combine fences into one sprite object */
70 StartSpriteCombine();
71
72 SpriteBounds bounds{{}, {TILE_SIZE, TILE_SIZE, 4}, {}};
73
74 bounds.extent.z += GetSlopeMaxPixelZ(ti->tileh);
75
76 uint fence_nw = GetFence(ti->tile, DIAGDIR_NW);
77 if (fence_nw != 0) {
78 bounds.offset.x = 0;
79 bounds.offset.y = -static_cast<int>(TILE_SIZE);
80 bounds.offset.z = GetSlopePixelZInCorner(ti->tileh, CORNER_W);
81 SpriteID sprite = _clear_land_fence_sprites[fence_nw - 1] + _fence_mod_by_tileh_nw[ti->tileh];
82 AddSortableSpriteToDraw(sprite, PAL_NONE, *ti, bounds, false);
83 }
84
85 uint fence_ne = GetFence(ti->tile, DIAGDIR_NE);
86 if (fence_ne != 0) {
87 bounds.offset.x = -static_cast<int>(TILE_SIZE);
88 bounds.offset.y = 0;
89 bounds.offset.z = GetSlopePixelZInCorner(ti->tileh, CORNER_E);
90 SpriteID sprite = _clear_land_fence_sprites[fence_ne - 1] + _fence_mod_by_tileh_ne[ti->tileh];
91 AddSortableSpriteToDraw(sprite, PAL_NONE, *ti, bounds, false);
92 }
93
94 uint fence_sw = GetFence(ti->tile, DIAGDIR_SW);
95 uint fence_se = GetFence(ti->tile, DIAGDIR_SE);
96
97 if (fence_sw != 0 || fence_se != 0) {
98 bounds.offset.x = 0;
99 bounds.offset.y = 0;
100 bounds.offset.z = GetSlopePixelZInCorner(ti->tileh, CORNER_S);
101
102 if (fence_sw != 0) {
103 SpriteID sprite = _clear_land_fence_sprites[fence_sw - 1] + _fence_mod_by_tileh_sw[ti->tileh];
104 AddSortableSpriteToDraw(sprite, PAL_NONE, *ti, bounds, false);
105 }
106
107 if (fence_se != 0) {
108 SpriteID sprite = _clear_land_fence_sprites[fence_se - 1] + _fence_mod_by_tileh_se[ti->tileh];
109 AddSortableSpriteToDraw(sprite, PAL_NONE, *ti, bounds, false);
110
111 }
112 }
113 EndSpriteCombine();
114}
115
116static void DrawTile_Clear(TileInfo *ti)
117{

Callers 1

DrawTile_ClearFunction · 0.85

Calls 6

StartSpriteCombineFunction · 0.85
GetSlopeMaxPixelZFunction · 0.85
GetFenceFunction · 0.85
GetSlopePixelZInCornerFunction · 0.85
EndSpriteCombineFunction · 0.85
AddSortableSpriteToDrawFunction · 0.70

Tested by

no test coverage detected