OpenTTD Source: src/water.h Source File

OpenTTD Source 15.0-RC2

water.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef WATER_H
11#define WATER_H
12
13#include "water_map.h"
14#include "economy_func.h"
15
19 enum FloodingBehaviour : uint8_t {
20 FLOOD_NONE,
21 FLOOD_ACTIVE,
22 FLOOD_PASSIVE,
23 FLOOD_DRYUP,
24};
25
26 FloodingBehaviour GetFloodingBehaviour(TileIndex tile);
27void ClearNeighbourNonFloodingStates(TileIndex tile);
28
29void TileLoop_Water(TileIndex tile);
30bool FloodHalftile(TileIndex t);
31
32void ConvertGroundTilesIntoWaterTiles();
33
34void DrawShipDepotSprite(int x, int y, Axis axis, DepotPart part);
35void DrawWaterClassGround(const struct TileInfo *ti);
36void DrawShoreTile(Slope tileh);
37
38void MakeWaterKeepingClass(TileIndex tile, Owner o);
39void CheckForDockingTile(TileIndex t);
40
41void MakeRiverAndModifyDesertZoneAround(TileIndex tile);
42void RiverMakeWider(TileIndex tile, TileIndex origin_tile);
43bool RiverFlowsDown(TileIndex begin, TileIndex end);
44 static const uint RIVER_OFFSET_DESERT_DISTANCE = 5;
45
46bool IsWateredTile(TileIndex tile, Direction from);
47
53 inline Money CanalMaintenanceCost(uint32_t num)
54{
55 return (_price[PR_INFRASTRUCTURE_WATER] * num * (1 + IntSqrt(num))) >> 6; // 6 bits scaling.
56}
57
58#endif /* WATER_H */
OverflowSafeInt< int64_t >
IntSqrt
uint32_t IntSqrt(uint32_t num)
Compute the integer square root.
Definition math_func.cpp:42
Direction
Direction
Defines the 8 directions on the map.
Definition direction_type.h:24
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition direction_type.h:123
economy_func.h
Functions related to the economy.
Slope
Slope
Enumeration for the slope-type.
Definition slope_type.h:48
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
TileInfo
Tile information, used while rendering the tile.
Definition tile_cmd.h:30
TileLoop_Water
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...
Definition water_cmd.cpp:1269
FloodHalftile
bool FloodHalftile(TileIndex t)
Called from water_cmd if a non-flat rail-tile gets flooded and should be converted to shore.
Definition rail_cmd.cpp:759
FloodingBehaviour
FloodingBehaviour
Describes the behaviour of a tile during flooding.
Definition water.h:19
FLOOD_NONE
@ FLOOD_NONE
The tile does not flood neighboured tiles.
Definition water.h:20
FLOOD_ACTIVE
@ FLOOD_ACTIVE
The tile floods neighboured tiles.
Definition water.h:21
FLOOD_DRYUP
@ FLOOD_DRYUP
The tile drys up if it is not constantly flooded from neighboured tiles.
Definition water.h:23
FLOOD_PASSIVE
@ FLOOD_PASSIVE
The tile does not actively flood neighboured tiles, but it prevents them from drying up.
Definition water.h:22
RiverFlowsDown
bool RiverFlowsDown(TileIndex begin, TileIndex end)
Check whether a river at begin could (logically) flow down to end.
Definition landscape.cpp:1308
ClearNeighbourNonFloodingStates
void ClearNeighbourNonFloodingStates(TileIndex tile)
Clear non-flooding state of the tiles around a tile.
Definition water_cmd.cpp:97
GetFloodingBehaviour
FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
Returns the behaviour of a tile during flooding.
Definition water_cmd.cpp:1115
CheckForDockingTile
void CheckForDockingTile(TileIndex t)
Mark the supplied tile as a docking tile if it is suitable for docking.
Definition water_cmd.cpp:194
RIVER_OFFSET_DESERT_DISTANCE
static const uint RIVER_OFFSET_DESERT_DISTANCE
Circular tile search diameter to create non-desert around a river tile.
Definition water.h:44
MakeRiverAndModifyDesertZoneAround
void MakeRiverAndModifyDesertZoneAround(TileIndex tile)
Make a river tile and remove desert directly around it.
Definition water_cmd.cpp:472
IsWateredTile
bool IsWateredTile(TileIndex tile, Direction from)
return true if a tile is a water tile wrt.
Definition water_cmd.cpp:658
CanalMaintenanceCost
Money CanalMaintenanceCost(uint32_t num)
Calculates the maintenance cost of a number of canal tiles.
Definition water.h:53
RiverMakeWider
void RiverMakeWider(TileIndex tile, TileIndex origin_tile)
Widen a river by expanding into adjacent tiles via circular tile search.
Definition landscape.cpp:1165
water_map.h
Map accessors for water tiles.
DepotPart
DepotPart
Sections of the water depot.
Definition water_map.h:58