src/water_map.h
branchNewGRF_ports
changeset 6871 5a9dc001e1ad
parent 6720 35756db7e577
child 6872 1c4a4a609f85
equal deleted inserted replaced
6870:ca3fd1fbe311 6871:5a9dc001e1ad
    25 	LOCK_END    = 0x1C
    25 	LOCK_END    = 0x1C
    26 };
    26 };
    27 
    27 
    28 static inline WaterTileType GetWaterTileType(TileIndex t)
    28 static inline WaterTileType GetWaterTileType(TileIndex t)
    29 {
    29 {
       
    30 	assert(IsTileType(t, MP_WATER));
       
    31 
    30 	if (_m[t].m5 == 0) return WATER_TILE_CLEAR;
    32 	if (_m[t].m5 == 0) return WATER_TILE_CLEAR;
    31 	if (_m[t].m5 == 1) return WATER_TILE_COAST;
    33 	if (_m[t].m5 == 1) return WATER_TILE_COAST;
    32 	if (IS_INT_INSIDE(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK;
    34 	if (IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK;
    33 
    35 
    34 	assert(IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END));
    36 	assert(IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END));
    35 	return WATER_TILE_DEPOT;
    37 	return WATER_TILE_DEPOT;
    36 }
    38 }
    37 
    39 
       
    40 /** IsWater return true if any type of clear water like ocean, river, canal */
    38 static inline bool IsWater(TileIndex t)
    41 static inline bool IsWater(TileIndex t)
    39 {
    42 {
    40 	return GetWaterTileType(t) == WATER_TILE_CLEAR;
    43 	return GetWaterTileType(t) == WATER_TILE_CLEAR;
       
    44 }
       
    45 
       
    46 static inline bool IsSea(TileIndex t)
       
    47 {
       
    48 	if (GetWaterTileType(t) != WATER_TILE_CLEAR) return false;
       
    49 	if (!IsTileOwner(t, OWNER_WATER)) return false; // 'Human' built water = canal, not sea
       
    50 	return true;
    41 }
    51 }
    42 
    52 
    43 static inline bool IsCoast(TileIndex t)
    53 static inline bool IsCoast(TileIndex t)
    44 {
    54 {
    45 	return GetWaterTileType(t) == WATER_TILE_COAST;
    55 	return GetWaterTileType(t) == WATER_TILE_COAST;
    48 static inline bool IsCanal(TileIndex t)
    58 static inline bool IsCanal(TileIndex t)
    49 {
    59 {
    50 	return GetWaterTileType(t) == WATER_TILE_CLEAR && GetTileOwner(t) != OWNER_WATER;
    60 	return GetWaterTileType(t) == WATER_TILE_CLEAR && GetTileOwner(t) != OWNER_WATER;
    51 }
    61 }
    52 
    62 
    53 static inline bool IsClearWaterTile(TileIndex t)
    63 static inline bool IsWaterTile(TileIndex t)
    54 {
    64 {
    55 	return IsTileType(t, MP_WATER) && IsWater(t) && GetTileSlope(t, NULL) == SLOPE_FLAT;
    65 	return IsTileType(t, MP_WATER) && IsWater(t);
    56 }
    66 }
    57 
    67 
    58 static inline TileIndex GetOtherShipDepotTile(TileIndex t)
    68 static inline TileIndex GetOtherShipDepotTile(TileIndex t)
    59 {
    69 {
    60 	return t + (HASBIT(_m[t].m5, 0) ? -1 : 1) * (HASBIT(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
    70 	return t + (HasBit(_m[t].m5, 0) ? -1 : 1) * (HasBit(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
    61 }
    71 }
    62 
    72 
    63 static inline TileIndex IsShipDepot(TileIndex t)
    73 static inline TileIndex IsShipDepot(TileIndex t)
    64 {
    74 {
    65 	return IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END);
    75 	return IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END);
    66 }
    76 }
    67 
    77 
    68 static inline Axis GetShipDepotAxis(TileIndex t)
    78 static inline Axis GetShipDepotAxis(TileIndex t)
    69 {
    79 {
    70 	return (Axis)GB(_m[t].m5, 1, 1);
    80 	return (Axis)GB(_m[t].m5, 1, 1);
   107 	_m[t].m5 = 1;
   117 	_m[t].m5 = 1;
   108 }
   118 }
   109 
   119 
   110 static inline void MakeCanal(TileIndex t, Owner o)
   120 static inline void MakeCanal(TileIndex t, Owner o)
   111 {
   121 {
       
   122 	assert(o != OWNER_WATER);
   112 	SetTileType(t, MP_WATER);
   123 	SetTileType(t, MP_WATER);
   113 	SetTileOwner(t, o);
   124 	SetTileOwner(t, o);
   114 	_m[t].m2 = 0;
   125 	_m[t].m2 = 0;
   115 	_m[t].m3 = 0;
   126 	_m[t].m3 = 0;
   116 	_m[t].m4 = 0;
   127 	_m[t].m4 = 0;