/* The tile owner of LOCK_PART_LOWER and LOCK_PART_UPPER was either * the owner of the water or the owner of the lock. The tile owner of * LOCK_PART_MIDDLE was the real owner of the lock. */ if (IsTileType(t, MP_WATER) && IsLock(t)) { if (GetWaterClass(t) == WATER_CLASS_CANAL) { /* First, set the canal owner for every lock part to be the same as the tile owner. */ SetCanalOwner(t, GetTileOwner(t)); } /* Then, set the tile owner of LOCK_PART_LOWER and LOCK_PART_UPPER to be the same * as the owner of the LOCK_PART_MIDDLE. */ static const TileIndexDiffC _lock_tomiddle_offs[][DIAGDIR_END] = { /* NE SE SW NW */ { { 0, 0}, {0, 0}, { 0, 0}, {0, 0} }, // LOCK_PART_MIDDLE { {-1, 0}, {0, 1}, { 1, 0}, {0, -1} }, // LOCK_PART_LOWER { { 1, 0}, {0, -1}, {-1, 0}, {0, 1} }, // LOCK_PART_UPPER }; if (GetLockPart(t) != LOCK_PART_MIDDLE) { SetTileOwner(t, GetTileOwner(t + ToTileIndexDiff(_lock_tomiddle_offs[GetLockPart(t)][GetLockDirection(t)]))); } }