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

Function DrawWaterLock

src/water_cmd.cpp:840–876  ·  view source on GitHub ↗

Draw a lock tile. */

Source from the content-addressed store, hash-verified

838
839/** Draw a lock tile. */
840static void DrawWaterLock(const TileInfo *ti)
841{
842 LockPart part = GetLockPart(ti->tile);
843 const DrawTileSprites &dts = _lock_display_data[to_underlying(part)][GetLockDirection(ti->tile)];
844
845 /* Draw ground sprite. */
846 SpriteID image = dts.ground.sprite;
847
848 SpriteID water_base = GetCanalSprite(CF_WATERSLOPE, ti->tile);
849 if (water_base == 0) {
850 /* Use default sprites. */
851 water_base = SPR_CANALS_BASE;
852 } else if (HasBit(_water_feature[CF_WATERSLOPE].flags, CFF_HAS_FLAT_SPRITE)) {
853 /* NewGRF supplies a flat sprite as first sprite. */
854 if (image == SPR_FLAT_WATER_TILE) {
855 image = water_base;
856 } else {
857 image++;
858 }
859 }
860
861 if (image < 5) image += water_base;
862 DrawGroundSprite(image, PAL_NONE);
863
864 /* Draw structures. */
865 uint zoffs = 0;
866 SpriteID base = GetCanalSprite(CF_LOCKS, ti->tile);
867
868 if (base == 0) {
869 /* If no custom graphics, use defaults. */
870 base = SPR_LOCK_BASE;
871 uint8_t z_threshold = part == LockPart::Upper ? 8 : 0;
872 zoffs = ti->z > z_threshold ? 24 : 0;
873 }
874
875 DrawWaterTileStruct(ti, dts.GetSequence(), base, zoffs, PAL_NONE, CF_LOCKS);
876}
877
878/** Draw a ship depot tile. */
879static void DrawWaterDepot(const TileInfo *ti)

Callers 1

DrawTile_WaterFunction · 0.85

Calls 8

GetLockPartFunction · 0.85
to_underlyingFunction · 0.85
GetLockDirectionFunction · 0.85
GetCanalSpriteFunction · 0.85
HasBitFunction · 0.85
DrawGroundSpriteFunction · 0.85
DrawWaterTileStructFunction · 0.85
GetSequenceMethod · 0.45

Tested by

no test coverage detected