depot.h
author rubidium
Sun, 09 Sep 2007 20:36:15 +0000
branch0.5
changeset 5541 08e4afe5e927
parent 5255 b8445fda3fe2
permissions -rw-r--r--
(svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
- Fix: Underflow that caused overflows in the performance rating [FS#1179] (r11039)
- Fix [Windows]: MIDI does not stop when closing openttd [FS#1164] (r11029)
- Fix: Do not unconditionally assume that a tile has a depot (r11027)
- Fix: Give a more correct error when building some things on tile 0 [FS#1173] (r11024)
- Fix: Do not display income/expenses when they do not belong to a "valid" tile, like the money cheat and giving money [FS#1175] (r11021)
- Fix: One could not give money when (s)he had too much money [FS#1174] (r11020)
- Fix: Disallow buying/selling shares in your own company or a bankrupt company [FS#1169] (r11018)
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2153
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2153
diff changeset
     2
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
     3
#ifndef DEPOT_H
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
     4
#define DEPOT_H
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
     5
2085
ae9e92ffe168 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
     6
/** @file depot.h Header files for depots (not hangars)
4549
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4388
diff changeset
     7
 *  @see depot.c */
2085
ae9e92ffe168 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
     8
3147
0a09ce6d651a (svn r3767) Move all direction related enums and functions to a separate header
tron
parents: 2952
diff changeset
     9
#include "direction.h"
5216
d581e4db95b6 (svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents: 5081
diff changeset
    10
#include "oldpool.h"
1330
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    11
#include "tile.h"
2153
91e89aa8c299 (svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents: 2085
diff changeset
    12
#include "variables.h"
5541
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    13
#include "station_map.h"
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    14
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    15
struct Depot {
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    16
	TileIndex xy;
3346
96c5db77aa83 (svn r4130) - CodeChange: Add proper semantics for TownID for such variables instead of using the general uint16-type. We probably need to change GetTown() and IsTownIndex() as well to use TownID.
Darkvater
parents: 3185
diff changeset
    17
	TownID town_index;
4388
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    18
	DepotID index;
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    19
};
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    20
5216
d581e4db95b6 (svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents: 5081
diff changeset
    21
DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    22
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4297
diff changeset
    23
/**
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4297
diff changeset
    24
 * Check if a depot really exists.
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4297
diff changeset
    25
 */
4388
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    26
static inline bool IsValidDepot(const Depot *depot)
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4297
diff changeset
    27
{
4388
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    28
	return depot != NULL && depot->xy != 0;
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4297
diff changeset
    29
}
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4297
diff changeset
    30
4352
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4347
diff changeset
    31
static inline bool IsValidDepotID(uint index)
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4347
diff changeset
    32
{
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4347
diff changeset
    33
	return index < GetDepotPoolSize() && IsValidDepot(GetDepot(index));
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4347
diff changeset
    34
}
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4347
diff changeset
    35
4388
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    36
void DestroyDepot(Depot *depot);
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    37
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    38
static inline void DeleteDepot(Depot *depot)
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    39
{
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    40
	DestroyDepot(depot);
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    41
	depot->xy = 0;
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    42
}
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    43
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents: 4549
diff changeset
    44
void ShowDepotWindow(TileIndex tile, byte type);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents: 4549
diff changeset
    45
4973
415bf67206dd (svn r6976) Use the pool macros for the Depot pool
tron
parents: 4638
diff changeset
    46
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (IsValidDepot(d))
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    47
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    48
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    49
#define MIN_SERVINT_PERCENT  5
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    50
#define MAX_SERVINT_PERCENT 90
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    51
#define MIN_SERVINT_DAYS    30
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    52
#define MAX_SERVINT_DAYS   800
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    53
4388
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    54
/**
e5a166837162 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4352
diff changeset
    55
 * Get the service interval domain.
1790
4afb4b4e4278 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1718
diff changeset
    56
 * Get the new proposed service interval for the vehicle is indeed, clamped
4afb4b4e4278 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1718
diff changeset
    57
 * within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
4afb4b4e4278 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1718
diff changeset
    58
 * @param index proposed service interval
4afb4b4e4278 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1718
diff changeset
    59
 */
4297
47ce9665b4af (svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents: 4077
diff changeset
    60
static inline Date GetServiceIntervalClamped(uint index)
1790
4afb4b4e4278 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1718
diff changeset
    61
{
4afb4b4e4278 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1718
diff changeset
    62
	return (_patches.servint_ispercent) ? clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
4afb4b4e4278 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1718
diff changeset
    63
}
4afb4b4e4278 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1718
diff changeset
    64
1330
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    65
/**
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    66
 * Check if a tile is a depot of the given type.
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    67
 */
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    68
static inline bool IsTileDepotType(TileIndex tile, TransportType type)
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    69
{
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3957
diff changeset
    70
	switch (type) {
1330
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    71
		case TRANSPORT_RAIL:
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1977
diff changeset
    72
			return IsTileType(tile, MP_RAILWAY) && (_m[tile].m5 & 0xFC) == 0xC0;
1959
fc150d5a23cf (svn r2465) Remove some unreachable code
tron
parents: 1944
diff changeset
    73
1330
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    74
		case TRANSPORT_ROAD:
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1977
diff changeset
    75
			return IsTileType(tile, MP_STREET) && (_m[tile].m5 & 0xF0) == 0x20;
1959
fc150d5a23cf (svn r2465) Remove some unreachable code
tron
parents: 1944
diff changeset
    76
1330
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    77
		case TRANSPORT_WATER:
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1977
diff changeset
    78
			return IsTileType(tile, MP_WATER) && (_m[tile].m5 & ~3) == 0x80;
1959
fc150d5a23cf (svn r2465) Remove some unreachable code
tron
parents: 1944
diff changeset
    79
1330
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    80
		default:
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    81
			assert(0);
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    82
			return false;
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    83
	}
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    84
}
8a67d04016ce (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1313
diff changeset
    85
5541
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    86
/**
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    87
 * Is the given tile a tile with a depot on it?
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    88
 * @param tile the tile to check
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    89
 * @return true if and only if there is a depot on the tile.
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    90
 */
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    91
static inline bool IsDepotTile(TileIndex tile)
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    92
{
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    93
	switch (GetTileType(tile)) {
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    94
		case MP_STREET:  return (_m[tile].m5 & 0xF0) == 0x20;
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    95
		case MP_WATER:   return (_m[tile].m5 &   ~3) == 0x80;
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    96
		case MP_RAILWAY: return (_m[tile].m5 & 0xFC) == 0xC0;
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    97
		case MP_STATION: return IsHangar(tile);
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    98
		default:         return false;
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
    99
	}
08e4afe5e927 (svn r11073) [0.5] -Backport from trunk (r11039, r11029, r11027, r11024, r11021, r11020, r11018):
rubidium
parents: 5255
diff changeset
   100
}
1650
12a20779af79 (svn r2154) - Fix: [NPF] Vehicles should no longer try to drive through the back of depots and road stations.
matthijs
parents: 1330
diff changeset
   101
2085
ae9e92ffe168 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   102
/**
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   103
 * Find out if the slope of the tile is suitable to build a depot of given direction
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   104
 * @param direction The direction in which the depot's exit points. Starts with 0 as NE and goes Clockwise
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   105
 * @param tileh The slope of the tile in question
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   106
 * @return true if the construction is possible
2085
ae9e92ffe168 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   107
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   108
 * This is checked by the ugly 0x4C >> direction magic, which does the following:
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   109
 * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   110
 * So: for direction (only the significant bits are shown)<p>
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   111
 * 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   112
 * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   113
 * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   114
 * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   115
 * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4000
diff changeset
   116
 */
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3347
diff changeset
   117
static inline bool CanBuildDepotByTileh(uint32 direction, Slope tileh)
2085
ae9e92ffe168 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   118
{
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   119
	return ((0x4C >> direction) & tileh) != 0;
2085
ae9e92ffe168 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   120
}
ae9e92ffe168 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   121
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1959
diff changeset
   122
Depot *GetDepotByTile(TileIndex tile);
4347
79b04c2cef95 (svn r6048) -Codechange: all InitializeXXX are plural, just not Depot
truelight
parents: 4346
diff changeset
   123
void InitializeDepots(void);
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
   124
Depot *AllocateDepot(void);
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
   125
5255
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5216
diff changeset
   126
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5216
diff changeset
   127
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
   128
#endif /* DEPOT_H */