src/autoslope.h
changeset 8079 037a8b09887c
child 8136 d1a4486be2fd
equal deleted inserted replaced
8078:bdf94bf88568 8079:037a8b09887c
       
     1 /* $Id$ */
       
     2 
       
     3 /** @file autoslope.h */
       
     4 
       
     5 #ifndef AUTOSLOPE_H
       
     6 #define AUTOSLOPE_H
       
     7 
       
     8 #include "depot.h"
       
     9 
       
    10 /**
       
    11  * Autoslope check for tiles with an entrance on an edge.
       
    12  * E.g. depots and non-drive-through-road-stops.
       
    13  *
       
    14  * The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level.
       
    15  *
       
    16  * @note The test does not check if autoslope is enabled at all.
       
    17  *
       
    18  * @param tile The tile.
       
    19  * @param z_new New TileZ.
       
    20  * @param tileh_new New TileSlope.
       
    21  * @param entrance Entrance edge.
       
    22  * @return true iff terraforming is allowed.
       
    23  */
       
    24 static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slope tileh_new, DiagDirection entrance)
       
    25 {
       
    26 	if (IsSteepSlope(tileh_new) || (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new))) return false;
       
    27 	return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
       
    28 }
       
    29 
       
    30 /**
       
    31  * Tests if autoslope is enabled for _current_player.
       
    32  *
       
    33  * Autoslope is disabled for town/industry construction and old ai players.
       
    34  *
       
    35  * @return true iff autoslope is enabled.
       
    36  */
       
    37 static inline bool AutoslopeEnabled()
       
    38 {
       
    39 	return (_patches.autoslope && IsValidPlayer(_current_player) && !_is_old_ai_player);
       
    40 }
       
    41 
       
    42 #endif /* AUTOSLOPE_H */