/**
* Make a lock section.
* @param t Tile to place the water lock section.
* @param lock_owner Owner of the lock.
* @param canal_owner Owner of the canal (only set if it's placed on canal).
* @param part Part to place.
* @param dir Lock orientation
* @param original_water_class Original water class.
* @see MakeLock
*/
static inline void MakeLockTile(TileIndex t, Owner lock_owner, Owner canal_owner, LockPart part, DiagDirection dir, WaterClass original_water_class)
{
SetTileType(t, MP_WATER);
SetTileOwner(t, lock_owner);
SetWaterClass(t, original_water_class);
if (original_water_class == WATER_CLASS_CANAL) SetCanalOwner(t, canal_owner);
_m[t].m2 = 0;
_m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = WBL_TYPE_LOCK << WBL_TYPE_BEGIN | part << WBL_LOCK_PART_BEGIN | dir << WBL_LOCK_ORIENT_BEGIN;
SB(_me[t].m6, 2, 4, 0);
_me[t].m7 = 0;
}
/**
* Make a water lock.
* @param t Tile to place the water lock section.
* @param lo Owner of the lock (also the owner of the canal at the middle part).
* @param co_lower Original owner of the canal at the lower part.
* @param co_upper Original owner of the canal at the upper part.
* @param d Direction of the water lock.
* @param wc_lower Original water class of the lower part.
* @param wc_upper Original water class of the upper part.
* @param wc_middle Original water class of the middle part.
*/
static inline void MakeLock(TileIndex t, Owner lo, Owner co_lower, Owner co_upper, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper, WaterClass wc_middle)
{
TileIndexDiff delta = TileOffsByDiagDir(d);
/* Keep the current waterclass and owner for the tiles.
* It allows to restore them after the lock is deleted */
MakeLockTile(t, lo, lo, LOCK_PART_MIDDLE, d, wc_middle);
MakeLockTile(t - delta, lo, co_lower, LOCK_PART_LOWER, d, wc_lower);
MakeLockTile(t + delta, lo, co_upper, LOCK_PART_UPPER, d, wc_upper);
}