MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetFloodingBehaviour

Function GetFloodingBehaviour

src/water_cmd.cpp:1115–1149  ·  view source on GitHub ↗

* Returns the behaviour of a tile during flooding. * * @return Behaviour of the tile */

Source from the content-addressed store, hash-verified

1113 * @return Behaviour of the tile
1114 */
1115FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
1116{
1117 /* FLOOD_ACTIVE: 'single-corner-raised'-coast, sea, sea-shipdepots, sea-buoys, sea-docks (water part), rail with flooded halftile, sea-water-industries, sea-oilrigs
1118 * FLOOD_DRYUP: coast with more than one corner raised, coast with rail-track, coast with trees
1119 * FLOOD_PASSIVE: (not used)
1120 * FLOOD_NONE: canals, rivers, everything else
1121 */
1122 switch (GetTileType(tile)) {
1123 case MP_WATER:
1124 if (IsCoast(tile)) {
1125 Slope tileh = GetTileSlope(tile);
1126 return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP);
1127 }
1128 [[fallthrough]];
1129 case MP_STATION:
1130 case MP_INDUSTRY:
1131 case MP_OBJECT:
1132 return (GetWaterClass(tile) == WaterClass::Sea) ? FLOOD_ACTIVE : FLOOD_NONE;
1133
1134 case MP_RAILWAY:
1135 if (GetRailGroundType(tile) == RailGroundType::HalfTileWater) {
1136 return (IsSlopeWithOneCornerRaised(GetTileSlope(tile)) ? FLOOD_ACTIVE : FLOOD_DRYUP);
1137 }
1138 return FLOOD_NONE;
1139
1140 case MP_TREES:
1141 return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE);
1142
1143 case MP_VOID:
1144 return FLOOD_ACTIVE;
1145
1146 default:
1147 return FLOOD_NONE;
1148 }
1149}
1150
1151/**
1152 * Floods a tile.

Callers 2

TileLoop_WaterFunction · 0.85
CheckRailSlopeFunction · 0.85

Calls 7

GetTileTypeFunction · 0.85
IsCoastFunction · 0.85
GetTileSlopeFunction · 0.85
GetWaterClassFunction · 0.85
GetRailGroundTypeFunction · 0.85
GetTreeGroundFunction · 0.85

Tested by

no test coverage detected