rubidium@9703: /* $Id$ */ rubidium@9703: rubidium@9703: /** @file autoslope.h */ rubidium@9703: rubidium@9703: #ifndef AUTOSLOPE_H rubidium@9703: #define AUTOSLOPE_H rubidium@9703: rubidium@9703: #include "depot.h" rubidium@9723: #include "settings_type.h" rubidium@9724: #include "player_func.h" rubidium@9703: rubidium@9703: /** rubidium@9703: * Autoslope check for tiles with an entrance on an edge. rubidium@9703: * E.g. depots and non-drive-through-road-stops. rubidium@9703: * rubidium@9703: * The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level. rubidium@9703: * rubidium@9703: * @note The test does not check if autoslope is enabled at all. rubidium@9703: * rubidium@9703: * @param tile The tile. rubidium@9703: * @param z_new New TileZ. rubidium@9703: * @param tileh_new New TileSlope. rubidium@9703: * @param entrance Entrance edge. rubidium@9703: * @return true iff terraforming is allowed. rubidium@9703: */ rubidium@9703: static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slope tileh_new, DiagDirection entrance) rubidium@9703: { rubidium@9703: if (IsSteepSlope(tileh_new) || (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new))) return false; rubidium@9703: return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new)); rubidium@9703: } rubidium@9703: rubidium@9703: /** rubidium@9703: * Tests if autoslope is enabled for _current_player. rubidium@9703: * rubidium@9703: * Autoslope is disabled for town/industry construction. rubidium@9703: * rubidium@9703: * @return true iff autoslope is enabled. rubidium@9703: */ rubidium@9703: static inline bool AutoslopeEnabled() rubidium@9703: { glx@9704: return (_patches.autoslope && glx@9704: (IsValidPlayer(_current_player) || glx@9705: (_current_player == OWNER_NONE && _game_mode == GM_EDITOR))); rubidium@9703: } rubidium@9703: rubidium@9703: #endif /* AUTOSLOPE_H */