tron@2186: /* $Id$ */ tron@2186: rubidium@8962: /** @file depot_func.h Functions related to depots. */ truelight@1313: rubidium@8962: #ifndef DEPOT_FUNC_H rubidium@8962: #define DEPOT_FUNC_H truelight@4346: rubidium@8962: #include "depot_type.h" rubidium@8962: #include "tile_type.h" rubidium@8962: #include "vehicle_type.h" rubidium@8962: #include "direction_type.h" rubidium@8962: #include "slope_type.h" truelight@4388: rubidium@6638: void ShowDepotWindow(TileIndex tile, VehicleType type); rubidium@8962: void InitializeDepots(); tron@1959: rubidium@8962: void DeleteDepotHighlightOfVehicle(const Vehicle *v); matthijs@1650: celestar@2085: /** tron@4077: * Find out if the slope of the tile is suitable to build a depot of given direction tron@6134: * @param direction The direction in which the depot's exit points tron@4077: * @param tileh The slope of the tile in question tron@4077: * @return true if the construction is possible celestar@2085: tron@4077: * This is checked by the ugly 0x4C >> direction magic, which does the following: tron@4077: * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out) tron@4077: * So: for direction (only the significant bits are shown)

tron@4077: * 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100

tron@4077: * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110

tron@4077: * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011

tron@4077: * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001

tron@4077: * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh tron@4077: */ tron@6134: static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh) celestar@2085: { KUDr@3900: return ((0x4C >> direction) & tileh) != 0; celestar@2085: } celestar@2085: rubidium@8962: #endif /* DEPOT_FUNC_H */