rubidium@7583: /* $Id$ */ rubidium@7583: rubidium@7583: /** @file autoslope.h */ rubidium@7583: rubidium@7583: #ifndef AUTOSLOPE_H rubidium@7583: #define AUTOSLOPE_H rubidium@7583: rubidium@7583: #include "depot.h" rubidium@8211: #include "settings_type.h" rubidium@8254: #include "player_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@7583: * Tests if autoslope is enabled for _current_player. rubidium@7583: * rubidium@7583: * Autoslope is disabled for town/industry construction and old ai players. rubidium@7583: * rubidium@7583: * @return true iff autoslope is enabled. rubidium@7583: */ rubidium@7583: static inline bool AutoslopeEnabled() rubidium@7583: { rubidium@7640: return (_patches.autoslope && rubidium@7640: ((IsValidPlayer(_current_player) && !_is_old_ai_player) || rubidium@7640: (_current_player == OWNER_NONE && _game_mode == GM_EDITOR))); rubidium@7583: } rubidium@7583: rubidium@7583: #endif /* AUTOSLOPE_H */