depot.h
author tron
Sun, 04 Jun 2006 16:04:15 +0000
changeset 3953 e64bbd8598e2
parent 3900 2c84ed52709d
child 3957 25f4a4f22e05
permissions -rw-r--r--
(svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
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
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
     3
#ifndef DEPOT_H
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
     4
#define DEPOT_H
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
     5
2085
876f20a0e843 (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)
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
     7
  * @see depot.c */
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
     8
3147
fc76d566a68e (svn r3767) Move all direction related enums and functions to a separate header
tron
parents: 2952
diff changeset
     9
#include "direction.h"
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    10
#include "pool.h"
3185
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3179
diff changeset
    11
#include "rail_map.h"
3179
8ef3e8028af5 (svn r3816) Use existing accessors
tron
parents: 3147
diff changeset
    12
#include "road_map.h"
1330
5d76a0522a11 (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
    13
#include "tile.h"
2153
ecfc674410b4 (svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents: 2085
diff changeset
    14
#include "variables.h"
3953
e64bbd8598e2 (svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents: 3900
diff changeset
    15
#include "water_map.h"
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    16
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    17
struct Depot {
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    18
	TileIndex xy;
3346
a0d4def7d934 (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
    19
	TownID town_index;
3347
0ddacd451b81 (svn r4131) - CodeChange: Add proper semantics for StationID for such variables instead of using the general uint16-type. StationID was added for depots, waypoints and stations where necessary. We probably need to change GetDepot(), IsDepotIndex(), IsStationIndex(), GetWaypoint() and IsWaypointIndex() as well to use StationID.
Darkvater
parents: 3346
diff changeset
    20
	StationID index;
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    21
};
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    22
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    23
extern MemoryPool _depot_pool;
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    24
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    25
/**
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    26
 * Get the pointer to the depot with index 'index'
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    27
 */
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    28
static inline Depot *GetDepot(uint index)
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    29
{
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    30
	return (Depot*)GetItemFromPool(&_depot_pool, index);
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    31
}
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    32
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    33
/**
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    34
 * Get the current size of the DepotPool
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    35
 */
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    36
static inline uint16 GetDepotPoolSize(void)
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    37
{
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    38
	return _depot_pool.total_items;
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    39
}
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    40
1718
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1650
diff changeset
    41
static inline bool IsDepotIndex(uint index)
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1650
diff changeset
    42
{
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1650
diff changeset
    43
	return index < GetDepotPoolSize();
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1650
diff changeset
    44
}
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1650
diff changeset
    45
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    46
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1 < GetDepotPoolSize()) ? GetDepot(d->index + 1) : NULL)
f1013ec3d318 (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)
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    48
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    49
#define MIN_SERVINT_PERCENT  5
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    50
#define MAX_SERVINT_PERCENT 90
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    51
#define MIN_SERVINT_DAYS    30
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    52
#define MAX_SERVINT_DAYS   800
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    53
1790
47963a0cfca3 (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
    54
/** Get the service interval domain.
47963a0cfca3 (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
    55
 * Get the new proposed service interval for the vehicle is indeed, clamped
47963a0cfca3 (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
 * within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
47963a0cfca3 (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
 * @param index proposed service interval
47963a0cfca3 (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
 */
47963a0cfca3 (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
static inline uint16 GetServiceIntervalClamped(uint index)
47963a0cfca3 (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
    60
{
47963a0cfca3 (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
	return (_patches.servint_ispercent) ? clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
47963a0cfca3 (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
}
47963a0cfca3 (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
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
    64
1330
5d76a0522a11 (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
/**
5d76a0522a11 (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 depot really exists.
5d76a0522a11 (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
 */
1718
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1650
diff changeset
    68
static inline bool IsValidDepot(const Depot* depot)
1330
5d76a0522a11 (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
{
5d76a0522a11 (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
    70
	return depot->xy != 0; /* XXX: Replace by INVALID_TILE someday */
5d76a0522a11 (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
}
5d76a0522a11 (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
    72
5d76a0522a11 (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
    73
/**
5d76a0522a11 (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
 * Check if a tile is a depot of the given type.
5d76a0522a11 (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
    75
 */
5d76a0522a11 (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
    76
static inline bool IsTileDepotType(TileIndex tile, TransportType type)
5d76a0522a11 (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
{
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2493
diff changeset
    78
	switch (type)
1330
5d76a0522a11 (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
    79
	{
5d76a0522a11 (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
		case TRANSPORT_RAIL:
2049
538e73c53f54 (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
    81
			return IsTileType(tile, MP_RAILWAY) && (_m[tile].m5 & 0xFC) == 0xC0;
1959
c2c3a9850c2e (svn r2465) Remove some unreachable code
tron
parents: 1944
diff changeset
    82
1330
5d76a0522a11 (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
		case TRANSPORT_ROAD:
2049
538e73c53f54 (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
    84
			return IsTileType(tile, MP_STREET) && (_m[tile].m5 & 0xF0) == 0x20;
1959
c2c3a9850c2e (svn r2465) Remove some unreachable code
tron
parents: 1944
diff changeset
    85
1330
5d76a0522a11 (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
    86
		case TRANSPORT_WATER:
2049
538e73c53f54 (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
    87
			return IsTileType(tile, MP_WATER) && (_m[tile].m5 & ~3) == 0x80;
1959
c2c3a9850c2e (svn r2465) Remove some unreachable code
tron
parents: 1944
diff changeset
    88
1330
5d76a0522a11 (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
    89
		default:
5d76a0522a11 (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
    90
			assert(0);
5d76a0522a11 (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
    91
			return false;
5d76a0522a11 (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
    92
	}
5d76a0522a11 (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
    93
}
5d76a0522a11 (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
    94
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
    95
/**
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
    96
 * Returns the direction the exit of the depot on the given tile is facing.
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
    97
 */
1942
c5d5cf5b0263 (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents: 1790
diff changeset
    98
static inline DiagDirection GetDepotDirection(TileIndex tile, TransportType type)
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
    99
{
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
   100
	assert(IsTileDepotType(tile, type));
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
   101
3953
e64bbd8598e2 (svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents: 3900
diff changeset
   102
	switch (type) {
e64bbd8598e2 (svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents: 3900
diff changeset
   103
		case TRANSPORT_RAIL:  return GetRailDepotDirection(tile);
e64bbd8598e2 (svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents: 3900
diff changeset
   104
		case TRANSPORT_ROAD:  return GetRoadDepotDirection(tile);
e64bbd8598e2 (svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents: 3900
diff changeset
   105
		case TRANSPORT_WATER: return GetShipDepotDirection(tile);
e64bbd8598e2 (svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents: 3900
diff changeset
   106
		default: return INVALID_DIAGDIR; /* Not reached */
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
   107
	}
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
   108
}
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
   109
2085
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   110
/**
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   111
	Find out if the slope of the tile is suitable to build a depot of given direction
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   112
	@param direction The direction in which the depot's exit points. Starts with 0 as NE and goes Clockwise
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   113
	@param tileh The slope of the tile in question
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   114
	@return true if the construction is possible
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   115
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   116
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   117
    This is checked by the ugly 0x4C >> direction magic, which does the following:
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   118
      0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   119
      So: for direction (only the significant bits are shown)<p>
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   120
      00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   121
      01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   122
      02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   123
      03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   124
      So ((0x4C >> p2) & tileh) determines whether the depot can be built on the current tileh
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   125
*/
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3347
diff changeset
   126
static inline bool CanBuildDepotByTileh(uint32 direction, Slope tileh)
2085
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   127
{
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   128
	return ((0x4C >> direction) & tileh) != 0;
2085
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   129
}
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   130
876f20a0e843 (svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents: 2049
diff changeset
   131
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1959
diff changeset
   132
Depot *GetDepotByTile(TileIndex tile);
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
   133
void InitializeDepot(void);
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
   134
Depot *AllocateDepot(void);
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1959
diff changeset
   135
void DoDeleteDepot(TileIndex tile);
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
   136
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
diff changeset
   137
#endif /* DEPOT_H */