OpenTTD
autoslope.h
Go to the documentation of this file.
1 /* $Id: autoslope.h 23735 2012-01-03 20:26:05Z rubidium $ */
2 
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  */
9 
12 #ifndef AUTOSLOPE_H
13 #define AUTOSLOPE_H
14 
15 #include "company_func.h"
16 #include "depot_func.h"
17 #include "tile_map.h"
18 
33 static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
34 {
35  if (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new)) return false;
36  return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
37 }
38 
46 static inline bool AutoslopeEnabled()
47 {
50  (_current_company == OWNER_NONE && _game_mode == GM_EDITOR)));
51 }
52 
53 #endif /* AUTOSLOPE_H */
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
static int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height) ...
Definition: slope_func.h:162
bool autoslope
allow terraforming under things
a flat tile
Definition: slope_type.h:51
The tile has no ownership.
Definition: company_type.h:27
DiagDirection
Enumeration for diagonal directions.
static bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
Definition: autoslope.h:46
Maximum number of companies.
Definition: company_type.h:25
Functions related to companies.
static bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Find out if the slope of the tile is suitable to build a depot of given direction.
Definition: depot_func.h:28
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
Definition: tile_map.cpp:215
CompanyByte _current_company
Company currently doing an action.
Definition: company_cmd.cpp:47
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
Functions related to depots.
Slope
Enumeration for the slope-type.
Definition: slope_type.h:50
ConstructionSettings construction
construction of things in-game
static bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
Autoslope check for tiles with an entrance on an edge.
Definition: autoslope.h:33
Map writing/reading functions for tiles.