rubidium@8079: /* $Id$ */ rubidium@8079: rubidium@10429: /** @file autoslope.h Functions related to autoslope. */ rubidium@8079: rubidium@8079: #ifndef AUTOSLOPE_H rubidium@8079: #define AUTOSLOPE_H rubidium@8079: rubidium@8707: #include "settings_type.h" rubidium@8750: #include "player_func.h" rubidium@10222: #include "depot_func.h" rubidium@8079: rubidium@8079: /** rubidium@8079: * Autoslope check for tiles with an entrance on an edge. rubidium@8079: * E.g. depots and non-drive-through-road-stops. rubidium@8079: * rubidium@8079: * The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level. rubidium@8079: * rubidium@8079: * @note The test does not check if autoslope is enabled at all. rubidium@8079: * rubidium@8079: * @param tile The tile. rubidium@8079: * @param z_new New TileZ. rubidium@8079: * @param tileh_new New TileSlope. rubidium@8079: * @param entrance Entrance edge. rubidium@8079: * @return true iff terraforming is allowed. rubidium@8079: */ rubidium@8079: static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slope tileh_new, DiagDirection entrance) rubidium@8079: { rubidium@8079: if (IsSteepSlope(tileh_new) || (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new))) return false; rubidium@8079: return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new)); rubidium@8079: } rubidium@8079: rubidium@8079: /** rubidium@8079: * Tests if autoslope is enabled for _current_player. rubidium@8079: * rubidium@8079: * Autoslope is disabled for town/industry construction and old ai players. rubidium@8079: * rubidium@8079: * @return true iff autoslope is enabled. rubidium@8079: */ rubidium@8079: static inline bool AutoslopeEnabled() rubidium@8079: { rubidium@10775: return (_settings_game.construction.autoslope && rubidium@11161: ((IsValidPlayerID(_current_player) && !_is_old_ai_player) || rubidium@8136: (_current_player == OWNER_NONE && _game_mode == GM_EDITOR))); rubidium@8079: } rubidium@8079: rubidium@8079: #endif /* AUTOSLOPE_H */