Fix: Data races on cursor state in OpenGL backends
[openttd-github.git] / src / autoslope.h
blob83d775b1fb7a464cab64aa34e3d0fad5584d4f5c
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 <http://www.gnu.org/licenses/>.
6 */
8 /** @file autoslope.h Functions related to autoslope. */
10 #ifndef AUTOSLOPE_H
11 #define AUTOSLOPE_H
13 #include "company_func.h"
14 #include "depot_func.h"
15 #include "tile_map.h"
17 /**
18 * Autoslope check for tiles with an entrance on an edge.
19 * E.g. depots and non-drive-through-road-stops.
21 * The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level.
23 * @note The test does not check if autoslope is enabled at all.
25 * @param tile The tile.
26 * @param z_new New TileZ.
27 * @param tileh_new New TileSlope.
28 * @param entrance Entrance edge.
29 * @return true iff terraforming is allowed.
31 static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
33 if (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new)) return false;
34 return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
37 /**
38 * Tests if autoslope is enabled for _current_company.
40 * Autoslope is disabled for town/industry construction.
42 * @return true iff autoslope is enabled.
44 static inline bool AutoslopeEnabled()
46 return (_settings_game.construction.autoslope &&
47 (_current_company < MAX_COMPANIES ||
48 (_current_company == OWNER_NONE && _game_mode == GM_EDITOR)));
51 #endif /* AUTOSLOPE_H */