src/depot.h
changeset 6460 b3017e083031
parent 6451 7baba06b4b85
child 6508 8bd54af67f0b
equal deleted inserted replaced
6459:8c66c58bf6cf 6460:b3017e083031
    83 }
    83 }
    84 
    84 
    85 
    85 
    86 /**
    86 /**
    87  * Find out if the slope of the tile is suitable to build a depot of given direction
    87  * Find out if the slope of the tile is suitable to build a depot of given direction
    88  * @param direction The direction in which the depot's exit points. Starts with 0 as NE and goes Clockwise
    88  * @param direction The direction in which the depot's exit points
    89  * @param tileh The slope of the tile in question
    89  * @param tileh The slope of the tile in question
    90  * @return true if the construction is possible
    90  * @return true if the construction is possible
    91 
    91 
    92  * This is checked by the ugly 0x4C >> direction magic, which does the following:
    92  * This is checked by the ugly 0x4C >> direction magic, which does the following:
    93  * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
    93  * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
    96  * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
    96  * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
    97  * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
    97  * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
    98  * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
    98  * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
    99  * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
    99  * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
   100  */
   100  */
   101 static inline bool CanBuildDepotByTileh(uint32 direction, Slope tileh)
   101 static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
   102 {
   102 {
   103 	return ((0x4C >> direction) & tileh) != 0;
   103 	return ((0x4C >> direction) & tileh) != 0;
   104 }
   104 }
   105 
   105 
   106 Depot *GetDepotByTile(TileIndex tile);
   106 Depot *GetDepotByTile(TileIndex tile);