Rework the way the ReinitSeparation command is called. The old way was way too danger...
[openttd-joker.git] / src / autoslope.h
blobe504610c397f8fa219ab6528879f0b401826798c
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file autoslope.h Functions related to autoslope. */
12 #ifndef AUTOSLOPE_H
13 #define AUTOSLOPE_H
15 #include "company_func.h"
16 #include "depot_func.h"
17 #include "tile_map.h"
19 /**
20 * Autoslope check for tiles with an entrance on an edge.
21 * E.g. depots and non-drive-through-road-stops.
23 * The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level.
25 * @note The test does not check if autoslope is enabled at all.
27 * @param tile The tile.
28 * @param z_new New TileZ.
29 * @param tileh_new New TileSlope.
30 * @param entrance Entrance edge.
31 * @return true iff terraforming is allowed.
33 static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
35 if (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new)) return false;
36 return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
39 /**
40 * Tests if autoslope is enabled for _current_company.
42 * Autoslope is disabled for town/industry construction.
44 * @return true iff autoslope is enabled.
46 static inline bool AutoslopeEnabled()
48 return (_settings_game.construction.autoslope &&
49 (_current_company < MAX_COMPANIES ||
50 (_current_company == OWNER_NONE && _game_mode == GM_EDITOR)));
53 #endif /* AUTOSLOPE_H */