Files
@ r7810:36ef334ff30e
Branch filter:
Location: cpp/openttd-patchpack/source/src/depot.h - annotation
r7810:36ef334ff30e
3.7 KiB
text/x-c
(svn r11360) -Fix [FS#1375]: do not crash when trying to "draw" an invalid string, just draw a message saying it is invalid.
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 | r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6125:eb40461cb765 r6125:eb40461cb765 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6182:367cfd19b5ec r6182:367cfd19b5ec r6182:367cfd19b5ec r7512:0abe410ba86d r5475:3f5cd13d1b63 r7389:43e81eaed707 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7389:43e81eaed707 r7389:43e81eaed707 r7389:43e81eaed707 r5475:3f5cd13d1b63 r7389:43e81eaed707 r7389:43e81eaed707 r7389:43e81eaed707 r7496:599894acf9bc r7389:43e81eaed707 r7389:43e81eaed707 r7389:43e81eaed707 r5475:3f5cd13d1b63 r7389:43e81eaed707 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6638:3cf9aa498970 r5475:3f5cd13d1b63 r7389:43e81eaed707 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6125:eb40461cb765 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6182:367cfd19b5ec r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7512:0abe410ba86d r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6182:367cfd19b5ec r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6182:367cfd19b5ec r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r7512:0abe410ba86d r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6134:aa2aee9f9144 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6134:aa2aee9f9144 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6247:96e840dbefcc r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 | /* $Id$ */
/** @file depot.h Header files for depots (not hangars) */
#ifndef DEPOT_H
#define DEPOT_H
#include "direction.h"
#include "oldpool.h"
#include "tile.h"
#include "variables.h"
#include "road_map.h"
#include "rail_map.h"
#include "water_map.h"
#include "station_map.h"
struct Depot;
DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
TileIndex xy;
TownID town_index;
Depot(TileIndex xy = 0) : xy(xy) {}
~Depot();
inline bool IsValid() const { return this->xy != 0; }
};
static inline bool IsValidDepotID(DepotID index)
{
return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
}
void ShowDepotWindow(TileIndex tile, VehicleType type);
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
#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
* @return service interval
*/
static inline Date GetServiceIntervalClamped(uint index)
{
return (_patches.servint_ispercent) ? clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
}
/**
* 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) && GetRailTileType(tile) == RAIL_TILE_DEPOT;
case TRANSPORT_ROAD:
return IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_DEPOT;
case TRANSPORT_WATER:
return IsTileType(tile, MP_WATER) && GetWaterTileType(tile) == WATER_TILE_DEPOT;
default:
NOT_REACHED();
return false;
}
}
/**
* Is the given tile a tile with a depot on it?
* @param tile the tile to check
* @return true if and only if there is a depot on the tile.
*/
static inline bool IsDepotTile(TileIndex tile)
{
switch (GetTileType(tile)) {
case MP_ROAD: return GetRoadTileType(tile) == ROAD_TILE_DEPOT;
case MP_WATER: return GetWaterTileType(tile) == WATER_TILE_DEPOT;
case MP_RAILWAY: return GetRailTileType(tile) == RAIL_TILE_DEPOT;
case MP_STATION: return IsHangar(tile);
default: return false;
}
}
/**
* 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
* @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 >> direction) & tileh) determines whether the depot can be built on the current tileh
*/
static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
{
return ((0x4C >> direction) & tileh) != 0;
}
Depot *GetDepotByTile(TileIndex tile);
void InitializeDepots();
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
#endif /* DEPOT_H */
|