2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2005-08-01 20:23:38 +00:00
|
|
|
/** @file bridge.h Header file for bridges */
|
|
|
|
|
|
|
|
#ifndef BRIDGE_H
|
|
|
|
#define BRIDGE_H
|
|
|
|
|
2007-12-23 10:56:02 +00:00
|
|
|
#include "gfx_type.h"
|
2007-12-25 23:42:52 +00:00
|
|
|
#include "tile_cmd.h"
|
2007-12-23 10:56:02 +00:00
|
|
|
|
2010-08-01 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* This enum is related to the definition of bridge pieces,
|
2008-07-15 00:34:34 +00:00
|
|
|
* which is used to determine the proper sprite table to use
|
|
|
|
* while drawing a given bridge part.
|
|
|
|
*/
|
|
|
|
enum BridgePieces {
|
|
|
|
BRIDGE_PIECE_NORTH = 0,
|
|
|
|
BRIDGE_PIECE_SOUTH,
|
|
|
|
BRIDGE_PIECE_INNER_NORTH,
|
|
|
|
BRIDGE_PIECE_INNER_SOUTH,
|
|
|
|
BRIDGE_PIECE_MIDDLE_ODD,
|
|
|
|
BRIDGE_PIECE_MIDDLE_EVEN,
|
|
|
|
BRIDGE_PIECE_HEAD,
|
|
|
|
BRIDGE_PIECE_INVALID,
|
|
|
|
};
|
|
|
|
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_POSTFIX_INCREMENT(BridgePieces)
|
2008-07-15 00:34:34 +00:00
|
|
|
|
2016-06-05 09:56:16 +00:00
|
|
|
static const uint MAX_BRIDGES = 16; ///< Number of available bridge specs.
|
2006-03-29 19:03:47 +00:00
|
|
|
|
2010-11-20 14:15:02 +00:00
|
|
|
typedef uint BridgeType; ///< Bridge spec number.
|
2008-02-11 04:12:30 +00:00
|
|
|
|
2018-11-17 19:49:05 +00:00
|
|
|
/**
|
|
|
|
* Actions that can be performed when the vehicle enters the depot.
|
|
|
|
*/
|
|
|
|
enum BridgePiecePillarFlags {
|
|
|
|
BPPF_CORNER_W = 1 << 0,
|
|
|
|
BPPF_CORNER_S = 1 << 1,
|
|
|
|
BPPF_CORNER_E = 1 << 2,
|
|
|
|
BPPF_CORNER_N = 1 << 3,
|
|
|
|
BPPF_ALL_CORNERS = 0xF,
|
|
|
|
BPPF_EDGE_NE = 1 << 4,
|
|
|
|
BPPF_EDGE_SE = 1 << 5,
|
|
|
|
BPPF_EDGE_SW = 1 << 6,
|
|
|
|
BPPF_EDGE_NW = 1 << 7,
|
|
|
|
};
|
|
|
|
DECLARE_ENUM_AS_BIT_SET(BridgePiecePillarFlags)
|
|
|
|
|
|
|
|
enum BridgeSpecCtrlFlags {
|
|
|
|
BSCF_CUSTOM_PILLAR_FLAGS,
|
|
|
|
BSCF_INVALID_PILLAR_FLAGS,
|
2020-10-14 18:53:06 +00:00
|
|
|
BSCF_NOT_AVAILABLE_TOWN,
|
|
|
|
BSCF_NOT_AVAILABLE_AI_GS,
|
2018-11-17 19:49:05 +00:00
|
|
|
};
|
|
|
|
|
2010-08-01 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* Struct containing information about a single bridge type
|
2005-08-01 20:23:38 +00:00
|
|
|
*/
|
2008-02-11 17:35:15 +00:00
|
|
|
struct BridgeSpec {
|
2008-02-12 03:05:27 +00:00
|
|
|
Year avail_year; ///< the year where it becomes available
|
|
|
|
byte min_length; ///< the minimum length (not counting start and end tile)
|
2011-02-04 15:37:23 +00:00
|
|
|
uint16 max_length; ///< the maximum length (not counting start and end tile)
|
2008-02-12 03:05:27 +00:00
|
|
|
uint16 price; ///< the price multiplier
|
2010-06-08 20:16:51 +00:00
|
|
|
uint16 speed; ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
|
2008-02-12 03:05:27 +00:00
|
|
|
SpriteID sprite; ///< the sprite which is used in the GUI
|
2010-01-21 01:38:13 +00:00
|
|
|
PaletteID pal; ///< the palette which is used in the GUI
|
2008-02-12 03:05:27 +00:00
|
|
|
StringID material; ///< the string that contains the bridge description
|
|
|
|
StringID transport_name[2]; ///< description of the bridge, when built for road or rail
|
|
|
|
PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge
|
|
|
|
byte flags; ///< bit 0 set: disable drawing of far pillars.
|
2018-11-17 19:49:05 +00:00
|
|
|
byte ctrl_flags; ///< control flags
|
|
|
|
byte pillar_flags[12]; ///< bridge pillar flags: 6 x pairs of x and y flags
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2005-08-01 20:23:38 +00:00
|
|
|
|
2008-02-11 17:35:15 +00:00
|
|
|
extern BridgeSpec _bridge[MAX_BRIDGES];
|
2005-08-01 20:23:38 +00:00
|
|
|
|
2007-07-26 16:51:10 +00:00
|
|
|
Foundation GetBridgeFoundation(Slope tileh, Axis axis);
|
2008-01-22 16:08:17 +00:00
|
|
|
bool HasBridgeFlatRamp(Slope tileh, Axis axis);
|
2007-02-24 18:44:30 +00:00
|
|
|
|
2011-05-02 20:59:54 +00:00
|
|
|
/**
|
|
|
|
* Get the specification of a bridge type.
|
|
|
|
* @param i The type of bridge to get the specification for.
|
|
|
|
* @return The specification.
|
|
|
|
*/
|
2008-02-11 17:35:15 +00:00
|
|
|
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
|
2007-02-24 18:44:30 +00:00
|
|
|
{
|
|
|
|
assert(i < lengthof(_bridge));
|
|
|
|
return &_bridge[i];
|
|
|
|
}
|
2006-03-29 16:30:26 +00:00
|
|
|
|
2007-07-24 17:01:23 +00:00
|
|
|
void DrawBridgeMiddle(const TileInfo *ti);
|
2007-02-26 18:25:03 +00:00
|
|
|
|
2010-04-04 14:22:55 +00:00
|
|
|
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
|
2020-10-14 18:53:06 +00:00
|
|
|
bool MayTownBuildBridgeType(BridgeType bridge_type);
|
2007-12-21 22:50:51 +00:00
|
|
|
int CalcBridgeLenCostFactor(int x);
|
2018-11-17 19:49:05 +00:00
|
|
|
BridgePiecePillarFlags GetBridgeTilePillarFlags(TileIndex tile, TileIndex northern_bridge_end, TileIndex southern_bridge_end, BridgeType bridge_type, TransportType bridge_transport_type);
|
2007-12-21 22:50:51 +00:00
|
|
|
|
2020-10-15 17:27:23 +00:00
|
|
|
struct BridgePieceDebugInfo {
|
|
|
|
BridgePieces piece;
|
|
|
|
BridgePiecePillarFlags pillar_flags;
|
2020-11-01 21:35:21 +00:00
|
|
|
uint pillar_index;
|
2020-10-15 17:27:23 +00:00
|
|
|
};
|
|
|
|
BridgePieceDebugInfo GetBridgePieceDebugInfo(TileIndex tile);
|
|
|
|
|
2008-02-05 04:48:56 +00:00
|
|
|
void ResetBridges();
|
|
|
|
|
2005-08-01 20:23:38 +00:00
|
|
|
#endif /* BRIDGE_H */
|