2006-03-01 21:00:44 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 21:21:05 +01:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 16:11:33 +01:00
|
|
|
/** @file water_map.h Map accessors for water tiles. */
|
2007-04-06 05:10:19 +01:00
|
|
|
|
2006-03-01 21:00:44 +00:00
|
|
|
#ifndef WATER_MAP_H
|
|
|
|
#define WATER_MAP_H
|
|
|
|
|
2009-09-10 15:33:07 +01:00
|
|
|
#include "depot_type.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "tile_map.h"
|
2009-05-22 16:13:50 +01:00
|
|
|
|
2010-07-03 19:43:52 +01:00
|
|
|
/** Available water tile types. */
|
2007-03-07 12:11:48 +00:00
|
|
|
enum WaterTileType {
|
2010-07-03 19:43:52 +01:00
|
|
|
WATER_TILE_CLEAR, // Plain water.
|
|
|
|
WATER_TILE_COAST, // Coast.
|
|
|
|
WATER_TILE_LOCK, // Water lock.
|
|
|
|
WATER_TILE_DEPOT, // Water Depot.
|
2008-02-02 09:28:43 +00:00
|
|
|
};
|
|
|
|
|
2010-07-03 19:43:52 +01:00
|
|
|
/** classes of water (for #WATER_TILE_CLEAR water tile type). */
|
2008-02-02 09:28:43 +00:00
|
|
|
enum WaterClass {
|
2010-07-03 19:43:52 +01:00
|
|
|
WATER_CLASS_SEA, ///< Sea.
|
|
|
|
WATER_CLASS_CANAL, ///< Canal.
|
|
|
|
WATER_CLASS_RIVER, ///< River.
|
|
|
|
WATER_CLASS_INVALID, ///< Used for industry tiles on land (also for oilrig if newgrf says so).
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2010-04-18 00:34:00 +01:00
|
|
|
template <> struct EnumPropsT<WaterClass> : MakeEnumPropsT<WaterClass, byte, WATER_CLASS_SEA, WATER_CLASS_INVALID, WATER_CLASS_INVALID, 2> {};
|
2006-03-31 19:36:13 +01:00
|
|
|
|
2010-07-03 19:43:52 +01:00
|
|
|
/** Sections of the water depot. */
|
2007-03-07 12:11:48 +00:00
|
|
|
enum DepotPart {
|
2006-03-30 12:11:35 +01:00
|
|
|
DEPOT_NORTH = 0x80,
|
2006-03-30 12:21:36 +01:00
|
|
|
DEPOT_SOUTH = 0x81,
|
|
|
|
DEPOT_END = 0x84,
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-03-30 12:11:35 +01:00
|
|
|
|
2010-07-03 19:43:52 +01:00
|
|
|
/** Sections of the water lock. */
|
2007-03-07 12:11:48 +00:00
|
|
|
enum LockPart {
|
2006-03-30 12:11:35 +01:00
|
|
|
LOCK_MIDDLE = 0x10,
|
|
|
|
LOCK_LOWER = 0x14,
|
2006-03-31 19:36:13 +01:00
|
|
|
LOCK_UPPER = 0x18,
|
|
|
|
LOCK_END = 0x1C
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-03-30 12:11:35 +01:00
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Get the water tile type at a tile.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return Water tile type at the tile.
|
|
|
|
*/
|
2006-03-31 19:36:13 +01:00
|
|
|
static inline WaterTileType GetWaterTileType(TileIndex t)
|
|
|
|
{
|
2007-10-16 20:48:58 +01:00
|
|
|
assert(IsTileType(t, MP_WATER));
|
|
|
|
|
2007-03-01 13:27:51 +00:00
|
|
|
if (_m[t].m5 == 0) return WATER_TILE_CLEAR;
|
|
|
|
if (_m[t].m5 == 1) return WATER_TILE_COAST;
|
2007-11-24 10:38:43 +00:00
|
|
|
if (IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK;
|
2006-03-31 19:36:13 +01:00
|
|
|
|
2007-11-24 10:38:43 +00:00
|
|
|
assert(IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END));
|
2007-03-01 13:27:51 +00:00
|
|
|
return WATER_TILE_DEPOT;
|
2006-03-31 19:36:13 +01:00
|
|
|
}
|
|
|
|
|
2010-09-05 14:18:26 +01:00
|
|
|
/**
|
|
|
|
* Checks whether the tile has an waterclass associated.
|
|
|
|
* You can then subsequently call GetWaterClass().
|
|
|
|
* @param t Tile to query.
|
|
|
|
* @return True if the tiletype has a waterclass.
|
|
|
|
*/
|
|
|
|
static inline bool HasTileWaterClass(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT);
|
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Get the water class at a tile.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
2010-08-26 20:29:20 +01:00
|
|
|
* @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
|
2010-07-03 19:43:52 +01:00
|
|
|
* @return Water class at the tile.
|
|
|
|
*/
|
2008-02-02 09:28:43 +00:00
|
|
|
static inline WaterClass GetWaterClass(TileIndex t)
|
|
|
|
{
|
2010-09-05 14:18:26 +01:00
|
|
|
assert(HasTileWaterClass(t));
|
2010-08-11 15:14:06 +01:00
|
|
|
return (WaterClass)GB(_m[t].m1, 5, 2);
|
2008-02-02 09:28:43 +00:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Set the water class at a tile.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to change.
|
|
|
|
* @param wc New water class.
|
2010-08-26 20:29:20 +01:00
|
|
|
* @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
|
2010-07-03 19:43:52 +01:00
|
|
|
*/
|
2008-02-02 09:28:43 +00:00
|
|
|
static inline void SetWaterClass(TileIndex t, WaterClass wc)
|
|
|
|
{
|
2010-09-05 14:18:26 +01:00
|
|
|
assert(HasTileWaterClass(t));
|
2010-08-11 15:14:06 +01:00
|
|
|
SB(_m[t].m1, 5, 2, wc);
|
2008-02-02 09:28:43 +00:00
|
|
|
}
|
|
|
|
|
2010-08-26 20:29:20 +01:00
|
|
|
/**
|
|
|
|
* Tests if the tile was built on water.
|
|
|
|
* @param t the tile to check
|
|
|
|
* @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
|
|
|
|
* @return true iff on water
|
|
|
|
*/
|
|
|
|
static inline bool IsTileOnWater(TileIndex t)
|
|
|
|
{
|
|
|
|
return (GetWaterClass(t) != WATER_CLASS_INVALID);
|
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Is it a plain water tile?
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return \c true if any type of clear water like ocean, river, or canal.
|
|
|
|
*/
|
2006-03-31 19:36:13 +01:00
|
|
|
static inline bool IsWater(TileIndex t)
|
|
|
|
{
|
2007-03-01 13:27:51 +00:00
|
|
|
return GetWaterTileType(t) == WATER_TILE_CLEAR;
|
2006-03-31 19:36:13 +01:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Is it a sea water tile?
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return \c true if it is a sea water tile.
|
|
|
|
*/
|
2007-10-16 20:48:58 +01:00
|
|
|
static inline bool IsSea(TileIndex t)
|
|
|
|
{
|
2008-02-02 09:28:43 +00:00
|
|
|
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_SEA;
|
2006-04-03 11:28:16 +01:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Is it a canal tile?
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return \c true if it is a canal tile.
|
|
|
|
*/
|
2007-06-19 22:15:14 +01:00
|
|
|
static inline bool IsCanal(TileIndex t)
|
|
|
|
{
|
2008-02-02 09:28:43 +00:00
|
|
|
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_CANAL;
|
2007-06-19 22:15:14 +01:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Is it a river water tile?
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return \c true if it is a river water tile.
|
|
|
|
*/
|
2008-01-19 17:00:54 +00:00
|
|
|
static inline bool IsRiver(TileIndex t)
|
|
|
|
{
|
2008-02-02 09:28:43 +00:00
|
|
|
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_RIVER;
|
2008-01-19 17:00:54 +00:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Is it a water tile with plain water?
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Tile to query.
|
|
|
|
* @return \c true if it is a plain water tile.
|
|
|
|
*/
|
2007-10-16 20:48:58 +01:00
|
|
|
static inline bool IsWaterTile(TileIndex t)
|
2006-03-30 12:21:36 +01:00
|
|
|
{
|
2007-10-16 20:48:58 +01:00
|
|
|
return IsTileType(t, MP_WATER) && IsWater(t);
|
2006-03-30 12:21:36 +01:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Is it a coast tile?
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return \c true if it is a sea water tile.
|
|
|
|
*/
|
2008-02-02 09:28:43 +00:00
|
|
|
static inline bool IsCoast(TileIndex t)
|
2008-01-22 22:17:28 +00:00
|
|
|
{
|
2008-02-02 09:28:43 +00:00
|
|
|
return GetWaterTileType(t) == WATER_TILE_COAST;
|
2008-01-22 22:17:28 +00:00
|
|
|
}
|
|
|
|
|
2010-10-08 22:08:38 +01:00
|
|
|
/**
|
|
|
|
* Is it a coast tile
|
|
|
|
* @param t Tile to query.
|
|
|
|
* @return \c true if it is a coast.
|
|
|
|
*/
|
|
|
|
static inline bool IsCoastTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_WATER) && IsCoast(t);
|
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Get the other tile of the ship depot.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Tile to query, containing one section of a ship depot.
|
|
|
|
* @return Tile containing the other section of the depot.
|
|
|
|
*/
|
2006-03-30 12:21:36 +01:00
|
|
|
static inline TileIndex GetOtherShipDepotTile(TileIndex t)
|
|
|
|
{
|
2007-11-19 21:02:30 +00:00
|
|
|
return t + (HasBit(_m[t].m5, 0) ? -1 : 1) * (HasBit(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
|
2006-03-30 12:21:36 +01:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Is it a water tile with a ship depot on it?
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return \c true if it is a ship depot tile.
|
|
|
|
*/
|
2008-04-18 02:35:17 +01:00
|
|
|
static inline bool IsShipDepot(TileIndex t)
|
2006-03-30 12:21:36 +01:00
|
|
|
{
|
2007-11-24 10:38:43 +00:00
|
|
|
return IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END);
|
2006-03-30 12:21:36 +01:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Is it a ship depot tile?
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Tile to query.
|
|
|
|
* @return \c true if it is a ship depot tile.
|
|
|
|
*/
|
2008-04-18 02:35:17 +01:00
|
|
|
static inline bool IsShipDepotTile(TileIndex t)
|
2008-04-17 01:44:20 +01:00
|
|
|
{
|
|
|
|
return IsTileType(t, MP_WATER) && IsShipDepot(t);
|
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Get the axis of the ship depot.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return Axis of the depot.
|
|
|
|
*/
|
2006-04-03 11:28:16 +01:00
|
|
|
static inline Axis GetShipDepotAxis(TileIndex t)
|
|
|
|
{
|
|
|
|
return (Axis)GB(_m[t].m5, 1, 1);
|
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Get the direction of the ship depot.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return Direction of the depot.
|
|
|
|
*/
|
2006-06-04 17:04:15 +01:00
|
|
|
static inline DiagDirection GetShipDepotDirection(TileIndex t)
|
|
|
|
{
|
|
|
|
return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1));
|
|
|
|
}
|
|
|
|
|
2010-08-19 14:44:41 +01:00
|
|
|
/**
|
|
|
|
* Get the most northern tile of a ship depot.
|
|
|
|
* @param tile One of the tiles of the ship depot.
|
|
|
|
* @return The northern tile of the depot.
|
|
|
|
*/
|
2010-08-19 15:26:41 +01:00
|
|
|
static inline TileIndex GetShipDepotNorthTile(TileIndex t)
|
2010-08-19 14:44:41 +01:00
|
|
|
{
|
|
|
|
assert(IsShipDepot(t));
|
|
|
|
TileIndex tile2 = GetOtherShipDepotTile(t);
|
|
|
|
|
|
|
|
return t < tile2 ? t : tile2;
|
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Is it a water lock tile?
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return \c true if it is a water lock tile.
|
|
|
|
*/
|
2008-02-06 15:32:06 +00:00
|
|
|
static inline bool IsLock(TileIndex t)
|
2007-12-07 21:14:54 +00:00
|
|
|
{
|
2008-02-06 15:32:06 +00:00
|
|
|
return IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END);
|
2007-12-07 21:14:54 +00:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Get the direction of the water lock.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return Direction of the lock.
|
|
|
|
*/
|
2006-03-30 12:21:36 +01:00
|
|
|
static inline DiagDirection GetLockDirection(TileIndex t)
|
|
|
|
{
|
|
|
|
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Get a section of a depot or a lock.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return The section.
|
|
|
|
*/
|
2006-04-03 11:50:54 +01:00
|
|
|
static inline byte GetSection(TileIndex t)
|
|
|
|
{
|
2007-03-01 13:27:51 +00:00
|
|
|
assert(GetWaterTileType(t) == WATER_TILE_LOCK || GetWaterTileType(t) == WATER_TILE_DEPOT);
|
2006-04-03 11:50:54 +01:00
|
|
|
return GB(_m[t].m5, 0, 4);
|
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Get the random bits of the water tile.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Water tile to query.
|
|
|
|
* @return Random bits of the tile.
|
|
|
|
*/
|
2008-01-20 18:30:53 +00:00
|
|
|
static inline byte GetWaterTileRandomBits(TileIndex t)
|
|
|
|
{
|
|
|
|
return _m[t].m4;
|
|
|
|
}
|
|
|
|
|
2006-03-30 12:21:36 +01:00
|
|
|
|
2010-07-03 19:43:52 +01:00
|
|
|
/**
|
|
|
|
* Helper function to make a coast tile.
|
|
|
|
* @param t The tile to change into water
|
|
|
|
*/
|
2006-03-01 21:00:44 +00:00
|
|
|
static inline void MakeShore(TileIndex t)
|
|
|
|
{
|
|
|
|
SetTileType(t, MP_WATER);
|
|
|
|
SetTileOwner(t, OWNER_WATER);
|
2010-08-11 15:14:06 +01:00
|
|
|
SetWaterClass(t, WATER_CLASS_SEA);
|
2006-03-01 21:00:44 +00:00
|
|
|
_m[t].m2 = 0;
|
|
|
|
_m[t].m3 = 0;
|
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = 1;
|
2009-03-08 16:10:39 +00:00
|
|
|
SB(_m[t].m6, 2, 4, 0);
|
|
|
|
_me[t].m7 = 0;
|
2006-03-01 21:00:44 +00:00
|
|
|
}
|
|
|
|
|
2009-10-20 13:31:11 +01:00
|
|
|
/**
|
|
|
|
* Helper function for making a watery tile.
|
|
|
|
* @param t The tile to change into water
|
|
|
|
* @param o The owner of the water
|
|
|
|
* @param wc The class of water the tile has to be
|
|
|
|
* @param random_bits Eventual random bits to be set for this tile
|
|
|
|
*/
|
|
|
|
static inline void MakeWater(TileIndex t, Owner o, WaterClass wc, uint8 random_bits)
|
2008-01-19 17:00:54 +00:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_WATER);
|
2009-10-20 13:31:11 +01:00
|
|
|
SetTileOwner(t, o);
|
2010-08-11 15:14:06 +01:00
|
|
|
SetWaterClass(t, wc);
|
2008-01-19 17:00:54 +00:00
|
|
|
_m[t].m2 = 0;
|
2010-08-11 15:14:06 +01:00
|
|
|
_m[t].m3 = 0;
|
2008-01-20 18:30:53 +00:00
|
|
|
_m[t].m4 = random_bits;
|
2008-02-02 09:28:43 +00:00
|
|
|
_m[t].m5 = 0;
|
2009-03-08 16:10:39 +00:00
|
|
|
SB(_m[t].m6, 2, 4, 0);
|
|
|
|
_me[t].m7 = 0;
|
2008-01-19 17:00:54 +00:00
|
|
|
}
|
|
|
|
|
2009-10-20 13:31:11 +01:00
|
|
|
/**
|
|
|
|
* Make a sea tile.
|
|
|
|
* @param t The tile to change into sea
|
|
|
|
*/
|
|
|
|
static inline void MakeSea(TileIndex t)
|
|
|
|
{
|
|
|
|
MakeWater(t, OWNER_WATER, WATER_CLASS_SEA, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make a river tile
|
|
|
|
* @param t The tile to change into river
|
|
|
|
* @param random_bits Random bits to be set for this tile
|
|
|
|
*/
|
|
|
|
static inline void MakeRiver(TileIndex t, uint8 random_bits)
|
|
|
|
{
|
|
|
|
MakeWater(t, OWNER_WATER, WATER_CLASS_RIVER, random_bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make a canal tile
|
|
|
|
* @param t The tile to change into canal
|
|
|
|
* @param o The owner of the canal
|
|
|
|
* @param random_bits Random bits to be set for this tile
|
|
|
|
*/
|
2008-01-20 18:30:53 +00:00
|
|
|
static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
|
2006-06-03 16:10:39 +01:00
|
|
|
{
|
2007-10-16 20:48:58 +01:00
|
|
|
assert(o != OWNER_WATER);
|
2009-10-20 13:31:11 +01:00
|
|
|
MakeWater(t, o, WATER_CLASS_CANAL, random_bits);
|
2006-06-03 16:10:39 +01:00
|
|
|
}
|
|
|
|
|
2010-07-03 19:43:52 +01:00
|
|
|
/**
|
|
|
|
* Make a ship depot section.
|
|
|
|
* @param t Tile to place the ship depot section.
|
|
|
|
* @param o Owner of the depot.
|
|
|
|
* @param did Depot ID.
|
|
|
|
* @param base Depot base (either #DEPOT_NORTH or #DEPOT_SOUTH).
|
|
|
|
* @param a Axis of the depot.
|
|
|
|
* @param original_water_class Original water class.
|
|
|
|
*/
|
2009-09-10 15:33:07 +01:00
|
|
|
static inline void MakeShipDepot(TileIndex t, Owner o, DepotID did, DepotPart base, Axis a, WaterClass original_water_class)
|
2006-03-30 12:11:35 +01:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_WATER);
|
|
|
|
SetTileOwner(t, o);
|
2010-08-11 15:14:06 +01:00
|
|
|
SetWaterClass(t, original_water_class);
|
2009-09-10 15:33:07 +01:00
|
|
|
_m[t].m2 = did;
|
2010-08-11 15:14:06 +01:00
|
|
|
_m[t].m3 = 0;
|
2008-02-06 15:32:06 +00:00
|
|
|
_m[t].m4 = 0;
|
2006-03-30 12:11:35 +01:00
|
|
|
_m[t].m5 = base + a * 2;
|
2009-03-08 16:10:39 +00:00
|
|
|
SB(_m[t].m6, 2, 4, 0);
|
|
|
|
_me[t].m7 = 0;
|
2006-03-30 12:11:35 +01:00
|
|
|
}
|
|
|
|
|
2010-08-01 20:22:34 +01:00
|
|
|
/**
|
|
|
|
* Make a lock section.
|
2010-07-03 19:43:52 +01:00
|
|
|
* @param t Tile to place the water lock section.
|
|
|
|
* @param o Owner of the lock.
|
|
|
|
* @param section Section to place.
|
|
|
|
* @param original_water_class Original water class.
|
|
|
|
* @see MakeLock
|
|
|
|
*/
|
2008-02-02 09:28:43 +00:00
|
|
|
static inline void MakeLockTile(TileIndex t, Owner o, byte section, WaterClass original_water_class)
|
2006-03-30 12:11:35 +01:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_WATER);
|
2006-06-03 16:10:39 +01:00
|
|
|
SetTileOwner(t, o);
|
2010-08-11 15:14:06 +01:00
|
|
|
SetWaterClass(t, original_water_class);
|
2006-03-30 12:11:35 +01:00
|
|
|
_m[t].m2 = 0;
|
2010-08-11 15:14:06 +01:00
|
|
|
_m[t].m3 = 0;
|
2006-03-30 12:11:35 +01:00
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = section;
|
2009-03-08 16:10:39 +00:00
|
|
|
SB(_m[t].m6, 2, 4, 0);
|
|
|
|
_me[t].m7 = 0;
|
2006-03-30 12:11:35 +01:00
|
|
|
}
|
|
|
|
|
2010-07-03 19:43:52 +01:00
|
|
|
/**
|
|
|
|
* Make a water lock.
|
|
|
|
* @param t Tile to place the water lock section.
|
|
|
|
* @param o Owner of the lock.
|
|
|
|
* @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.
|
|
|
|
*/
|
2008-02-02 09:28:43 +00:00
|
|
|
static inline void MakeLock(TileIndex t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper)
|
2006-03-30 12:11:35 +01:00
|
|
|
{
|
2006-09-06 00:21:41 +01:00
|
|
|
TileIndexDiff delta = TileOffsByDiagDir(d);
|
2006-03-30 12:11:35 +01:00
|
|
|
|
2008-02-02 09:28:43 +00:00
|
|
|
MakeLockTile(t, o, LOCK_MIDDLE + d, WATER_CLASS_CANAL);
|
|
|
|
MakeLockTile(t - delta, o, LOCK_LOWER + d, wc_lower);
|
|
|
|
MakeLockTile(t + delta, o, LOCK_UPPER + d, wc_upper);
|
2006-03-30 12:11:35 +01:00
|
|
|
}
|
|
|
|
|
2006-09-28 19:42:35 +01:00
|
|
|
#endif /* WATER_MAP_H */
|