Mercurial > hg > openttd
changeset 8532:b3bd4f1ed981 draft
(svn r12107) -Codechange: Add and use the typedef BridgeType
author | belugas <belugas@openttd.org> |
---|---|
date | Mon, 11 Feb 2008 04:12:30 +0000 |
parents | e1f4b0ce4884 |
children | a5a519aab85c |
files | src/bridge.h src/bridge_gui.cpp src/bridge_map.h src/tunnelbridge_cmd.cpp |
diffstat | 4 files changed, 20 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/bridge.h +++ b/src/bridge.h @@ -13,6 +13,8 @@ MAX_BRIDGES = 13 }; +typedef uint BridgeType; + /** Struct containing information about a single bridge type */ struct Bridge { @@ -35,7 +37,7 @@ 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 @@ 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();
--- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -26,7 +26,7 @@ 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 @@ 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++; } }
--- 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 @@ * @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 @@ * @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 @@ * @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 @@ * @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); }
--- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -44,7 +44,7 @@ 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 @@ 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 @@ */ 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 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 @@ * @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 @@ TileIndex rampsouth; Axis axis; uint piece; - uint type; + BridgeType type; int x; int y; uint z;