|
@@ -476,49 +476,49 @@ static bool IsWateredTile(TileIndex tile
|
|
|
default: return false;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
|
|
|
case MP_STATION:
|
|
|
if (IsOilRig(tile)) {
|
|
|
/* Do not draw waterborders inside of industries.
|
|
|
* Note: There is no easy way to detect the industry of an oilrig tile. */
|
|
|
TileIndex src_tile = tile + TileOffsByDir(from);
|
|
|
if ((IsTileType(src_tile, MP_STATION) && IsOilRig(src_tile)) ||
|
|
|
(IsTileType(src_tile, MP_INDUSTRY))) return true;
|
|
|
|
|
|
return GetWaterClass(tile) != WATER_CLASS_INVALID;
|
|
|
}
|
|
|
return (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT) || IsBuoy(tile);
|
|
|
|
|
|
case MP_INDUSTRY: {
|
|
|
/* Do not draw waterborders inside of industries.
|
|
|
* Note: There is no easy way to detect the industry of an oilrig tile. */
|
|
|
TileIndex src_tile = tile + TileOffsByDir(from);
|
|
|
if ((IsTileType(src_tile, MP_STATION) && IsOilRig(src_tile)) ||
|
|
|
(IsTileType(src_tile, MP_INDUSTRY) && GetIndustryIndex(src_tile) == GetIndustryIndex(tile))) return true;
|
|
|
|
|
|
return IsIndustryTileOnWater(tile);
|
|
|
return IsTileOnWater(tile);
|
|
|
}
|
|
|
|
|
|
case MP_TUNNELBRIDGE: return GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER && ReverseDiagDir(GetTunnelBridgeDirection(tile)) == DirToDiagDir(from);
|
|
|
|
|
|
default: return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Draw a water sprite, potentially with a NewGRF-modified sprite offset.
|
|
|
* @param base Sprite base.
|
|
|
* @param offset Sprite offset.
|
|
|
* @param feature The type of sprite that is drawn.
|
|
|
* @param tile Tile index to draw.
|
|
|
*/
|
|
|
static void DrawWaterSprite(SpriteID base, uint offset, CanalFeature feature, TileIndex tile)
|
|
|
{
|
|
|
if (base != SPR_FLAT_WATER_TILE) {
|
|
|
/* Only call offset callback if the sprite is NewGRF-provided. */
|
|
|
offset = GetCanalSpriteOffset(feature, tile, offset);
|
|
|
}
|
|
|
DrawGroundSprite(base + offset, PAL_NONE);
|
|
|
}
|
|
|
|
|
@@ -911,70 +911,63 @@ static void FloodVehicles(TileIndex tile
|
|
|
TileIndex end = GetOtherBridgeEnd(tile);
|
|
|
z = GetBridgeHeight(tile);
|
|
|
|
|
|
FindVehicleOnPos(tile, &z, &FloodVehicleProc);
|
|
|
FindVehicleOnPos(end, &z, &FloodVehicleProc);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Returns the behaviour of a tile during flooding.
|
|
|
*
|
|
|
* @return Behaviour of the tile
|
|
|
*/
|
|
|
FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
|
|
|
{
|
|
|
/* FLOOD_ACTIVE: 'single-corner-raised'-coast, sea, sea-shipdepots, sea-buoys, sea-docks (water part), rail with flooded halftile, sea-water-industries, sea-oilrigs
|
|
|
* FLOOD_DRYUP: coast with more than one corner raised, coast with rail-track, coast with trees
|
|
|
* FLOOD_PASSIVE: (not used)
|
|
|
* FLOOD_NONE: canals, rivers, everything else
|
|
|
*/
|
|
|
switch (GetTileType(tile)) {
|
|
|
case MP_WATER:
|
|
|
if (IsCoast(tile)) {
|
|
|
Slope tileh = GetTileSlope(tile, NULL);
|
|
|
return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP);
|
|
|
} else {
|
|
|
}
|
|
|
/* FALL THROUGH */
|
|
|
case MP_STATION:
|
|
|
case MP_INDUSTRY:
|
|
|
return (GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE;
|
|
|
}
|
|
|
|
|
|
case MP_RAILWAY:
|
|
|
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
|
|
|
return (IsSlopeWithOneCornerRaised(GetTileSlope(tile, NULL)) ? FLOOD_ACTIVE : FLOOD_DRYUP);
|
|
|
}
|
|
|
return FLOOD_NONE;
|
|
|
|
|
|
case MP_TREES:
|
|
|
return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE);
|
|
|
|
|
|
case MP_STATION:
|
|
|
if (IsBuoy(tile) || (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT) || IsOilRig(tile)) {
|
|
|
return (GetWaterClass(tile) == WATER_CLASS_SEA ? FLOOD_ACTIVE : FLOOD_NONE);
|
|
|
}
|
|
|
return FLOOD_NONE;
|
|
|
|
|
|
case MP_INDUSTRY:
|
|
|
return ((IsIndustryTileOnWater(tile) && GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE);
|
|
|
|
|
|
default:
|
|
|
return FLOOD_NONE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Floods a tile.
|
|
|
*/
|
|
|
void DoFloodTile(TileIndex target)
|
|
|
{
|
|
|
assert(!IsTileType(target, MP_WATER));
|
|
|
|
|
|
bool flooded = false; // Will be set to true if something is changed.
|
|
|
|
|
|
Backup<CompanyByte> cur_company(_current_company, OWNER_WATER, FILE_LINE);
|
|
|
|
|
|
Slope tileh = GetTileSlope(target, NULL);
|
|
|
if (tileh != SLOPE_FLAT) {
|
|
|
/* make coast.. */
|
|
|
switch (GetTileType(target)) {
|
|
|
case MP_RAILWAY: {
|
|
|
if (!IsPlainRail(target)) break;
|
|
|
FloodVehicles(target);
|
|
|
flooded = FloodHalftile(target);
|