# bridge.h

Go to the documentation of this file.

    00001 /* $Id: bridge.h 19567 2010-04-05 21:34:47Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef BRIDGE_H
    00013 #define BRIDGE_H
    00014
    00015 #include "gfx_type.h"
    00016 #include "tile_cmd.h"
    00017
    00022 enum BridgePieces {
    00023   BRIDGE_PIECE_NORTH = 0,
    00024   BRIDGE_PIECE_SOUTH,
    00025   BRIDGE_PIECE_INNER_NORTH,
    00026   BRIDGE_PIECE_INNER_SOUTH,
    00027   BRIDGE_PIECE_MIDDLE_ODD,
    00028   BRIDGE_PIECE_MIDDLE_EVEN,
    00029   BRIDGE_PIECE_HEAD,
    00030   BRIDGE_PIECE_INVALID,
    00031 };
    00032
    00033 DECLARE_POSTFIX_INCREMENT(BridgePieces);
    00034
    00035 enum {
    00036   MAX_BRIDGES = 13
    00037 };
    00038
    00039 typedef uint BridgeType;
    00040
    00043 struct BridgeSpec {
    00044   Year avail_year;
    00045   byte min_length;
    00046   byte max_length;
    00047   uint16 price;
    00048   uint16 speed;
    00049   SpriteID sprite;
    00050   PaletteID pal;
    00051   StringID material;
    00052   StringID transport_name[2];
    00053   PalSpriteID **sprite_table;
    00054   byte flags;
    00055 };
    00056
    00057 extern BridgeSpec _bridge[MAX_BRIDGES];
    00058
    00059 Foundation GetBridgeFoundation(Slope tileh, Axis axis);
    00060 bool HasBridgeFlatRamp(Slope tileh, Axis axis);
    00061
    00062 static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
    00063 {
    00064   assert(i < lengthof(_bridge));
    00065   return &_bridge[i];
    00066 }
    00067
    00068 void DrawBridgeMiddle(const TileInfo *ti);
    00069
    00070 CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
    00071 int CalcBridgeLenCostFactor(int x);
    00072
    00073 void ResetBridges();
    00074
    00075 #endif /* BRIDGE_H */