# bridge.h

Go to the documentation of this file.

    00001 /* $Id: bridge.h 17248 2009-08-21 20:21:05Z 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 "direction_type.h"
    00017 #include "tile_cmd.h"
    00018
    00023 enum BridgePieces {
    00024   BRIDGE_PIECE_NORTH = 0,
    00025   BRIDGE_PIECE_SOUTH,
    00026   BRIDGE_PIECE_INNER_NORTH,
    00027   BRIDGE_PIECE_INNER_SOUTH,
    00028   BRIDGE_PIECE_MIDDLE_ODD,
    00029   BRIDGE_PIECE_MIDDLE_EVEN,
    00030   BRIDGE_PIECE_HEAD,
    00031   BRIDGE_PIECE_INVALID,
    00032 };
    00033
    00034 DECLARE_POSTFIX_INCREMENT(BridgePieces);
    00035
    00036 enum {
    00037   MAX_BRIDGES = 13
    00038 };
    00039
    00040 typedef uint BridgeType;
    00041
    00044 struct BridgeSpec {
    00045   Year avail_year;
    00046   byte min_length;
    00047   byte max_length;
    00048   uint16 price;
    00049   uint16 speed;
    00050   SpriteID sprite;
    00051   SpriteID pal;
    00052   StringID material;
    00053   StringID transport_name[2];
    00054   PalSpriteID **sprite_table;
    00055   byte flags;
    00056 };
    00057
    00058 extern BridgeSpec _bridge[MAX_BRIDGES];
    00059
    00060 Foundation GetBridgeFoundation(Slope tileh, Axis axis);
    00061 bool HasBridgeFlatRamp(Slope tileh, Axis axis);
    00062
    00063 static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
    00064 {
    00065   assert(i < lengthof(_bridge));
    00066   return &_bridge[i];
    00067 }
    00068
    00069 void DrawBridgeMiddle(const TileInfo *ti);
    00070
    00071 bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
    00072 int CalcBridgeLenCostFactor(int x);
    00073
    00074 void ResetBridges();
    00075
    00076 #endif /* BRIDGE_H */