src/tunnelbridge.h
branchNewGRF_ports
changeset 6877 889301acc299
child 10233 c08376c16fb2
equal deleted inserted replaced
6876:2c40faeef7a5 6877:889301acc299
       
     1 /* $Id$ */
       
     2 
       
     3 /** @file tunnelbridge.h Header file for things common for tunnels and bridges */
       
     4 
       
     5 #ifndef TUNNELBRIDGE_H
       
     6 #define TUNNELBRIDGE_H
       
     7 
       
     8 #include "tile_type.h"
       
     9 #include "map_func.h"
       
    10 #include "tunnelbridge_map.h"
       
    11 
       
    12 /**
       
    13  * Calculates the length of a tunnel or a bridge (without end tiles)
       
    14  * @return length of bridge/tunnel middle
       
    15  */
       
    16 static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
       
    17 {
       
    18 	int x1 = TileX(begin);
       
    19 	int y1 = TileY(begin);
       
    20 	int x2 = TileX(end);
       
    21 	int y2 = TileY(end);
       
    22 
       
    23 	return abs(x2 + y2 - x1 - y1) - 1;
       
    24 }
       
    25 
       
    26 #endif /* TUNNELBRIDGE_H */