2007-09-14 22:35:39 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file autoslope.h Functions related to autoslope. */
|
2007-09-14 22:35:39 +00:00
|
|
|
|
|
|
|
#ifndef AUTOSLOPE_H
|
|
|
|
#define AUTOSLOPE_H
|
|
|
|
|
2008-01-07 00:57:19 +00:00
|
|
|
#include "settings_type.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_func.h"
|
2008-04-17 19:10:30 +00:00
|
|
|
#include "depot_func.h"
|
2007-09-14 22:35:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Autoslope check for tiles with an entrance on an edge.
|
|
|
|
* E.g. depots and non-drive-through-road-stops.
|
|
|
|
*
|
|
|
|
* The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level.
|
|
|
|
*
|
|
|
|
* @note The test does not check if autoslope is enabled at all.
|
|
|
|
*
|
|
|
|
* @param tile The tile.
|
|
|
|
* @param z_new New TileZ.
|
|
|
|
* @param tileh_new New TileSlope.
|
|
|
|
* @param entrance Entrance edge.
|
|
|
|
* @return true iff terraforming is allowed.
|
|
|
|
*/
|
|
|
|
static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slope tileh_new, DiagDirection entrance)
|
|
|
|
{
|
|
|
|
if (IsSteepSlope(tileh_new) || (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new))) return false;
|
|
|
|
return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* Tests if autoslope is enabled for _current_company.
|
2007-09-14 22:35:39 +00:00
|
|
|
*
|
2009-01-12 17:11:45 +00:00
|
|
|
* Autoslope is disabled for town/industry construction.
|
2007-09-14 22:35:39 +00:00
|
|
|
*
|
|
|
|
* @return true iff autoslope is enabled.
|
|
|
|
*/
|
|
|
|
static inline bool AutoslopeEnabled()
|
|
|
|
{
|
2008-05-29 15:13:28 +00:00
|
|
|
return (_settings_game.construction.autoslope &&
|
2009-01-12 17:11:45 +00:00
|
|
|
(_current_company < MAX_COMPANIES ||
|
2008-09-30 20:39:50 +00:00
|
|
|
(_current_company == OWNER_NONE && _game_mode == GM_EDITOR)));
|
2007-09-14 22:35:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* AUTOSLOPE_H */
|