10249
|
1 |
/* $Id$ */
|
|
2 |
|
|
3 |
/** @file depot_func.h Functions related to depots. */
|
|
4 |
|
|
5 |
#ifndef DEPOT_FUNC_H
|
|
6 |
#define DEPOT_FUNC_H
|
|
7 |
|
|
8 |
#include "depot_type.h"
|
|
9 |
#include "tile_type.h"
|
|
10 |
#include "vehicle_type.h"
|
|
11 |
#include "direction_type.h"
|
|
12 |
#include "slope_type.h"
|
|
13 |
|
|
14 |
void ShowDepotWindow(TileIndex tile, VehicleType type);
|
|
15 |
void InitializeDepots();
|
|
16 |
|
|
17 |
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
|
|
18 |
|
|
19 |
/**
|
|
20 |
* Find out if the slope of the tile is suitable to build a depot of given direction
|
|
21 |
* @param direction The direction in which the depot's exit points
|
|
22 |
* @param tileh The slope of the tile in question
|
|
23 |
* @return true if the construction is possible
|
|
24 |
|
|
25 |
* This is checked by the ugly 0x4C >> direction magic, which does the following:
|
|
26 |
* 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
|
|
27 |
* So: for direction (only the significant bits are shown)<p>
|
|
28 |
* 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
|
|
29 |
* 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
|
|
30 |
* 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
|
|
31 |
* 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
|
|
32 |
* So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
|
|
33 |
*/
|
|
34 |
static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
|
|
35 |
{
|
|
36 |
return ((0x4C >> direction) & tileh) != 0;
|
|
37 |
}
|
|
38 |
|
|
39 |
#endif /* DEPOT_FUNC_H */
|