Files
@ r3478:523ece58cb16
Branch filter:
Location: cpp/openttd-patchpack/source/depot.h - annotation
r3478:523ece58cb16
4.1 KiB
text/x-c
(svn r4323) -Regression: Clear the slot assignments of all vehicles heading twoards a road stop if that road stop gets removed
This issue was fixed in r2210 and reintroduced in r4259 when the multistop handling was overhauled.
This issue was fixed in r2210 and reintroduced in r4259 when the multistop handling was overhauled.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | r2186:5ee653b1b5e1 r2186:5ee653b1b5e1 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r3147:5edf25fbd66a r1313:da473558c9d7 r3185:dbb100efa51f r3179:755ee14a834d r1330:62eaa061ec97 r2153:b45e3461c6c4 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r3346:134319cc6f99 r3347:b0be9ba36dd3 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1718:0c13f342c6f1 r1718:0c13f342c6f1 r1718:0c13f342c6f1 r1718:0c13f342c6f1 r1718:0c13f342c6f1 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1790:aafbb2ff1ae7 r1790:aafbb2ff1ae7 r1790:aafbb2ff1ae7 r1790:aafbb2ff1ae7 r1790:aafbb2ff1ae7 r1790:aafbb2ff1ae7 r1790:aafbb2ff1ae7 r1790:aafbb2ff1ae7 r1790:aafbb2ff1ae7 r1790:aafbb2ff1ae7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1313:da473558c9d7 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1718:0c13f342c6f1 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r2952:e97f823d2dbe r1330:62eaa061ec97 r1330:62eaa061ec97 r2049:7e26d55f0f4c r1959:c5a6f024dd5d r1330:62eaa061ec97 r2049:7e26d55f0f4c r1959:c5a6f024dd5d r1330:62eaa061ec97 r2049:7e26d55f0f4c r1959:c5a6f024dd5d r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1330:62eaa061ec97 r1650:67d8c926c00b r1650:67d8c926c00b r1650:67d8c926c00b r1942:ea8e39498c72 r1650:67d8c926c00b r1650:67d8c926c00b r1650:67d8c926c00b r1650:67d8c926c00b r1650:67d8c926c00b r3185:dbb100efa51f r3179:755ee14a834d r1650:67d8c926c00b r1650:67d8c926c00b r2493:a844eec5cb6b r1942:ea8e39498c72 r1942:ea8e39498c72 r1942:ea8e39498c72 r1942:ea8e39498c72 r1650:67d8c926c00b r1650:67d8c926c00b r1942:ea8e39498c72 r1650:67d8c926c00b r1650:67d8c926c00b r1650:67d8c926c00b r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r2085:757cdc338c24 r1977:1f8b99c96041 r1313:da473558c9d7 r1313:da473558c9d7 r1977:1f8b99c96041 r1313:da473558c9d7 r1313:da473558c9d7 | /* $Id$ */
#ifndef DEPOT_H
#define DEPOT_H
/** @file depot.h Header files for depots (not hangars)
* @see depot.c */
#include "direction.h"
#include "pool.h"
#include "rail_map.h"
#include "road_map.h"
#include "tile.h"
#include "variables.h"
struct Depot {
TileIndex xy;
TownID town_index;
StationID index;
};
extern MemoryPool _depot_pool;
/**
* Get the pointer to the depot with index 'index'
*/
static inline Depot *GetDepot(uint index)
{
return (Depot*)GetItemFromPool(&_depot_pool, index);
}
/**
* Get the current size of the DepotPool
*/
static inline uint16 GetDepotPoolSize(void)
{
return _depot_pool.total_items;
}
static inline bool IsDepotIndex(uint index)
{
return index < GetDepotPoolSize();
}
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1 < GetDepotPoolSize()) ? GetDepot(d->index + 1) : NULL)
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
#define MIN_SERVINT_PERCENT 5
#define MAX_SERVINT_PERCENT 90
#define MIN_SERVINT_DAYS 30
#define MAX_SERVINT_DAYS 800
/** Get the service interval domain.
* Get the new proposed service interval for the vehicle is indeed, clamped
* within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
* @param index proposed service interval
*/
static inline uint16 GetServiceIntervalClamped(uint index)
{
return (_patches.servint_ispercent) ? clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
}
VARDEF TileIndex _last_built_train_depot_tile;
VARDEF TileIndex _last_built_road_depot_tile;
VARDEF TileIndex _last_built_aircraft_depot_tile;
VARDEF TileIndex _last_built_ship_depot_tile;
/**
* Check if a depot really exists.
*/
static inline bool IsValidDepot(const Depot* depot)
{
return depot->xy != 0; /* XXX: Replace by INVALID_TILE someday */
}
/**
* Check if a tile is a depot of the given type.
*/
static inline bool IsTileDepotType(TileIndex tile, TransportType type)
{
switch (type)
{
case TRANSPORT_RAIL:
return IsTileType(tile, MP_RAILWAY) && (_m[tile].m5 & 0xFC) == 0xC0;
case TRANSPORT_ROAD:
return IsTileType(tile, MP_STREET) && (_m[tile].m5 & 0xF0) == 0x20;
case TRANSPORT_WATER:
return IsTileType(tile, MP_WATER) && (_m[tile].m5 & ~3) == 0x80;
default:
assert(0);
return false;
}
}
/**
* Returns the direction the exit of the depot on the given tile is facing.
*/
static inline DiagDirection GetDepotDirection(TileIndex tile, TransportType type)
{
assert(IsTileDepotType(tile, type));
switch (type)
{
case TRANSPORT_RAIL: return GetRailDepotDirection(tile);
case TRANSPORT_ROAD: return GetRoadDepotDirection(tile);
case TRANSPORT_WATER:
/* Water is stubborn, it stores the directions in a different order. */
switch (GB(_m[tile].m5, 0, 2)) {
case 0: return DIAGDIR_NE;
case 1: return DIAGDIR_SW;
case 2: return DIAGDIR_NW;
case 3: return DIAGDIR_SE;
}
default:
return INVALID_DIAGDIR; /* Not reached */
}
}
/**
Find out if the slope of the tile is suitable to build a depot of given direction
@param direction The direction in which the depot's exit points. Starts with 0 as NE and goes Clockwise
@param tileh The slope of the tile in question
@return true if the construction is possible
This is checked by the ugly 0x4C >> direction magic, which does the following:
0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
So: for direction (only the significant bits are shown)<p>
00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
So ((0x4C >> p2) & tileh) determines whether the depot can be built on the current tileh
*/
static inline bool CanBuildDepotByTileh(uint32 direction, uint tileh)
{
return (0x4C >> direction) & tileh;
}
Depot *GetDepotByTile(TileIndex tile);
void InitializeDepot(void);
Depot *AllocateDepot(void);
void DoDeleteDepot(TileIndex tile);
#endif /* DEPOT_H */
|