diff options
author | belugas <belugas@openttd.org> | 2008-02-11 04:12:30 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2008-02-11 04:12:30 +0000 |
commit | c21787238cd8f4aed1e7b878bcfc5bf69cc1c339 (patch) | |
tree | 879853417b4a7923051e4d8ebc3db81a8302897a /src | |
parent | f54a21450ab8e799bb5d4d83ba24b496a33088fa (diff) | |
download | openttd-c21787238cd8f4aed1e7b878bcfc5bf69cc1c339.tar.xz |
(svn r12107) -Codechange: Add and use the typedef BridgeType
Diffstat (limited to 'src')
-rw-r--r-- | src/bridge.h | 6 | ||||
-rw-r--r-- | src/bridge_gui.cpp | 10 | ||||
-rw-r--r-- | src/bridge_map.h | 9 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 12 |
4 files changed, 20 insertions, 17 deletions
diff --git a/src/bridge.h b/src/bridge.h index 29afd06b1..96526850d 100644 --- a/src/bridge.h +++ b/src/bridge.h @@ -13,6 +13,8 @@ enum { MAX_BRIDGES = 13 }; +typedef uint BridgeType; + /** Struct containing information about a single bridge type */ struct Bridge { @@ -35,7 +37,7 @@ extern Bridge _bridge[MAX_BRIDGES]; Foundation GetBridgeFoundation(Slope tileh, Axis axis); bool HasBridgeFlatRamp(Slope tileh, Axis axis); -static inline const Bridge *GetBridgeSpec(uint i) +static inline const Bridge *GetBridgeSpec(BridgeType i) { assert(i < lengthof(_bridge)); return &_bridge[i]; @@ -43,7 +45,7 @@ static inline const Bridge *GetBridgeSpec(uint i) void DrawBridgeMiddle(const TileInfo *ti); -bool CheckBridge_Stuff(byte bridge_type, uint bridge_len); +bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len); int CalcBridgeLenCostFactor(int x); void ResetBridges(); diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 11d8ee074..38a576a7e 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -26,7 +26,7 @@ static struct BridgeData { TileIndex start_tile; TileIndex end_tile; uint8 type; - uint8 indexes[MAX_BRIDGES]; + BridgeType indexes[MAX_BRIDGES]; Money costs[MAX_BRIDGES]; BridgeData() @@ -188,14 +188,14 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type) const uint tot_bridgedata_len = CalcBridgeLenCostFactor(bridge_len + 2); /* loop for all bridgetypes */ - for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) { - if (CheckBridge_Stuff(bridge_type, bridge_len)) { + for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) { + if (CheckBridge_Stuff(brd_type, bridge_len)) { /* bridge is accepted, add to list */ - const Bridge *b = GetBridgeSpec(bridge_type); + const Bridge *b = GetBridgeSpec(brd_type); /* Add to terraforming & bulldozing costs the cost of the * bridge itself (not computed with DC_QUERY_COST) */ _bridgedata.costs[j] = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * b->price) >> 8); - _bridgedata.indexes[j] = bridge_type; + _bridgedata.indexes[j] = brd_type; j++; } } diff --git a/src/bridge_map.h b/src/bridge_map.h index a47a625e2..a4f4f1e4d 100644 --- a/src/bridge_map.h +++ b/src/bridge_map.h @@ -8,6 +8,7 @@ #include "direction_func.h" #include "rail_type.h" #include "road_map.h" +#include "bridge.h" /** @@ -67,7 +68,7 @@ static inline bool IsBridgeAbove(TileIndex t) * @pre IsBridgeTile(t) * @return The bridge type */ -static inline uint GetBridgeType(TileIndex t) +static inline BridgeType GetBridgeType(TileIndex t) { assert(IsBridgeTile(t)); return GB(_m[t].m2, 4, 4); @@ -163,7 +164,7 @@ static inline void SetBridgeMiddle(TileIndex t, Axis a) * @param rt the road or rail type * @note this function should not be called directly. */ -static inline void MakeBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, TransportType tt, uint rt) +static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt, uint rt) { SetTileType(t, MP_TUNNELBRIDGE); SetTileOwner(t, o); @@ -181,7 +182,7 @@ static inline void MakeBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDir * @param d the direction this ramp must be facing * @param r the road type of the bridge */ -static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, RoadTypes r) +static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RoadTypes r) { MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, r); } @@ -194,7 +195,7 @@ static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, uint bridgetype, Dia * @param d the direction this ramp must be facing * @param r the rail type of the bridge */ -static inline void MakeRailBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, RailType r) +static inline void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType r) { MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL, r); } diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index f23920f79..53ac0012b 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -44,7 +44,7 @@ Bridge _bridge[MAX_BRIDGES]; void ResetBridges() { /* First, free sprite table data */ - for (uint i = 0; i < MAX_BRIDGES; i++) { + for (BridgeType i = 0; i < MAX_BRIDGES; i++) { if (_bridge[i].sprite_table != NULL) { for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]); free(_bridge[i].sprite_table); @@ -151,7 +151,7 @@ static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, uint *z) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); } -bool CheckBridge_Stuff(byte bridge_type, uint bridge_len) +bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len) { const Bridge *b = GetBridgeSpec(bridge_type); uint max; // max possible length of a bridge (with patch 100) @@ -176,7 +176,7 @@ bool CheckBridge_Stuff(byte bridge_type, uint bridge_len) */ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) { - uint bridge_type; + BridgeType bridge_type; RailType railtype = INVALID_RAILTYPE; RoadTypes roadtypes = ROADTYPES_NONE; uint x; @@ -196,7 +196,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p CommandCost cost(EXPENSES_CONSTRUCTION); CommandCost ret; bool replace_bridge = false; - uint replaced_bridge_type; + BridgeType replaced_bridge_type; TransportType transport_type; /* unpack parameters */ @@ -708,7 +708,7 @@ static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags) * @param y Sprite Y position of front pillar. * @param z_bridge Absolute height of bridge bottom. */ -static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, uint type, int x, int y, int z_bridge) +static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, BridgeType type, int x, int y, int z_bridge) { SpriteID image = psid->sprite; if (image != 0) { @@ -994,7 +994,7 @@ void DrawBridgeMiddle(const TileInfo* ti) TileIndex rampsouth; Axis axis; uint piece; - uint type; + BridgeType type; int x; int y; uint z; |