src/depot_func.h
author rubidium
Wed, 17 Dec 2008 23:08:11 +0000
changeset 10434 3659467c844c
parent 8962 1b263c69799d
permissions -rw-r--r--
(svn r14687) -Change: log all configure errors to config.log
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2153
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2153
diff changeset
     2
8962
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
     3
/** @file depot_func.h Functions related to depots. */
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
     4
8962
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
     5
#ifndef DEPOT_FUNC_H
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
     6
#define DEPOT_FUNC_H
4346
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4297
diff changeset
     7
8962
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
     8
#include "depot_type.h"
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
     9
#include "tile_type.h"
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
    10
#include "vehicle_type.h"
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
    11
#include "direction_type.h"
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
    12
#include "slope_type.h"
4388
c8a66d26e146 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    13
6638
09c5d7bf69a5 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 6247
diff changeset
    14
void ShowDepotWindow(TileIndex tile, VehicleType type);
8962
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
    15
void InitializeDepots();
1959
c2c3a9850c2e (svn r2465) Remove some unreachable code
tron
parents: 1944
diff changeset
    16
8962
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
    17
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
1650
4a5141e10b72 (svn r2154) - Fix: [NPF] Vehicles should no longer try to drive through the back of depots and road stations.
matthijs
parents: 1330
diff changeset
    18
2085
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
    19
/**
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    20
 * Find out if the slope of the tile is suitable to build a depot of given direction
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents: 6125
diff changeset
    21
 * @param direction The direction in which the depot's exit points
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    22
 * @param tileh The slope of the tile in question
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    23
 * @return true if the construction is possible
2085
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
    24
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    25
 * This is checked by the ugly 0x4C >> direction magic, which does the following:
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    26
 * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    27
 * So: for direction (only the significant bits are shown)<p>
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    28
 * 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    29
 * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    30
 * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    31
 * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    32
 * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
    33
 */
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents: 6125
diff changeset
    34
static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
2085
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
    35
{
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
    36
	return ((0x4C >> direction) & tileh) != 0;
2085
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
    37
}
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
    38
8962
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8954
diff changeset
    39
#endif /* DEPOT_FUNC_H */