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