Mercurial > hg > openttd
changeset 6141:4be07d3ba23b draft
(svn r8884) -Fix
Replace SetSpeedLimitOnBridge() by something simpler
author | tron <tron@openttd.org> |
---|---|
date | Sat, 24 Feb 2007 18:44:30 +0000 |
parents | 577a7c5a9ae7 |
children | 586baa62c8d6 |
files | src/bridge.h src/roadveh_cmd.cpp src/train_cmd.cpp src/tunnelbridge_cmd.cpp |
diffstat | 4 files changed, 13 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/bridge.h +++ b/src/bridge.h @@ -28,6 +28,11 @@ extern Bridge _bridge[MAX_BRIDGES]; uint GetBridgeFoundation(Slope tileh, Axis axis); -uint SetSpeedLimitOnBridge(Vehicle *); + +static inline const Bridge *GetBridge(uint i) +{ + assert(i < lengthof(_bridge)); + return &_bridge[i]; +} #endif /* BRIDGE_H */
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -880,7 +880,9 @@ // Clamp spd = min(spd, v->max_speed); - if (v->u.road.state == RVSB_WORMHOLE) spd = min(spd, SetSpeedLimitOnBridge(v)); + if (v->u.road.state == RVSB_WORMHOLE && !(v->vehstatus & VS_HIDDEN)) { + spd = min(spd, GetBridge(GetBridgeType(v->tile))->speed * 2); + } //updates statusbar only if speed have changed to save CPU time if (spd != v->cur_speed) {
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3136,7 +3136,10 @@ /* In tunnel or on a bridge */ GetNewVehiclePos(v, &gp); - SetSpeedLimitOnBridge(v); + if (!(v->vehstatus & VS_HIDDEN)) { + v->cur_speed = + min(v->cur_speed, GetBridge(GetBridgeType(v->tile))->speed); + } if (!(IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) || !HASBIT(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) { v->x_pos = gp.x;
--- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -1051,21 +1051,6 @@ } -uint SetSpeedLimitOnBridge(Vehicle *v) -{ - uint bridge_speed; - if (v->vehstatus & VS_HIDDEN) return v->max_speed; /* in tunnel */ - - bridge_speed = _bridge[GetBridgeType(v->tile)].speed; - - if (v->type == VEH_Road) bridge_speed *= 2; /* XXX give vehicles proper speeds */ - - if (v->cur_speed > bridge_speed) v->cur_speed = bridge_speed; - return bridge_speed; -} - - - static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y) { uint z;