richk@10242: /* $Id$ */ richk@10242: richk@10242: /** @file depot_func.h Functions related to depots. */ richk@10242: richk@10242: #ifndef DEPOT_FUNC_H richk@10242: #define DEPOT_FUNC_H richk@10242: richk@10242: #include "depot_type.h" richk@10242: #include "tile_type.h" richk@10242: #include "vehicle_type.h" richk@10242: #include "direction_type.h" richk@10242: #include "slope_type.h" richk@10242: richk@10242: void ShowDepotWindow(TileIndex tile, VehicleType type); richk@10242: void InitializeDepots(); richk@10242: richk@10242: void DeleteDepotHighlightOfVehicle(const Vehicle *v); richk@10242: richk@10242: /** richk@10242: * Find out if the slope of the tile is suitable to build a depot of given direction richk@10242: * @param direction The direction in which the depot's exit points richk@10242: * @param tileh The slope of the tile in question richk@10242: * @return true if the construction is possible richk@10242: richk@10242: * This is checked by the ugly 0x4C >> direction magic, which does the following: richk@10242: * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out) richk@10242: * So: for direction (only the significant bits are shown)
richk@10242: * 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100
richk@10242: * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110
richk@10242: * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011
richk@10242: * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001
richk@10242: * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh richk@10242: */ richk@10242: static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh) richk@10242: { richk@10242: return ((0x4C >> direction) & tileh) != 0; richk@10242: } richk@10242: richk@10242: #endif /* DEPOT_FUNC_H */