Loading

Paste #pfyqwplu1

  1. /**
  2.  * Make a lock section.
  3.  * @param t Tile to place the water lock section.
  4.  * @param lock_owner Owner of the lock.
  5.  * @param canal_owner Owner of the canal (only set if it's placed on canal).
  6.  * @param part Part to place.
  7.  * @param dir Lock orientation
  8.  * @param original_water_class Original water class.
  9.  * @see MakeLock
  10.  */
  11. static inline void MakeLockTile(TileIndex t, Owner lock_owner, Owner canal_owner, LockPart part, DiagDirection dir, WaterClass original_water_class)
  12. {
  13.     SetTileType(t, MP_WATER);
  14.     SetTileOwner(t, lock_owner);
  15.     SetWaterClass(t, original_water_class);
  16.     if (original_water_class == WATER_CLASS_CANAL) SetCanalOwner(t, canal_owner);
  17.     _m[t].m2 = 0;
  18.     _m[t].m3 = 0;
  19.     _m[t].m4 = 0;
  20.     _m[t].m5 = WBL_TYPE_LOCK << WBL_TYPE_BEGIN | part << WBL_LOCK_PART_BEGIN | dir << WBL_LOCK_ORIENT_BEGIN;
  21.     SB(_me[t].m6, 2, 4, 0);
  22.     _me[t].m7 = 0;
  23. }
  24.  
  25. /**
  26. * Make a water lock.
  27. * @param t Tile to place the water lock section.
  28. * @param lo Owner of the lock (also the owner of the canal).
  29. * @param co_lower Original owner of the canal at the lower part.
  30. * @param co_upper Original owner of the canal at the upper part.
  31. * @param d Direction of the water lock.
  32. * @param wc_lower Original water class of the lower part.
  33. * @param wc_upper Original water class of the upper part.
  34. * @param wc_middle Original water class of the middle part.
  35. */
  36. 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)
  37. {
  38.     TileIndexDiff delta = TileOffsByDiagDir(d);
  39.  
  40.     /* Keep the current waterclass and owner for the tiles.
  41.     * It allows to restore them after the lock is deleted */
  42.     MakeLockTile(t, lo, lo, LOCK_PART_MIDDLE, d, wc_middle);
  43.     MakeLockTile(t - delta, lo, co_lower, LOCK_PART_LOWER, d, wc_lower);
  44.     MakeLockTile(t + delta, lo, co_upper, LOCK_PART_UPPER, d, wc_upper);
  45. }

Comments