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