Changeset - r6141:c62fa95eacc3
[Not reviewed]
master
0 4 0
tron - 18 years ago 2007-02-24 18:44:30
tron@openttd.org
(svn r8884) -Fix

Replace SetSpeedLimitOnBridge() by something simpler
4 files changed with 13 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/bridge.h
Show inline comments
 
@@ -25,9 +25,14 @@ typedef struct Bridge {
 
} Bridge;
 

	
 
extern const Bridge orig_bridge[MAX_BRIDGES];
 
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 */
src/roadveh_cmd.cpp
Show inline comments
 
@@ -877,13 +877,15 @@ static bool RoadVehAccelerate(Vehicle *v
 
{
 
	uint spd = v->cur_speed + 1 + (v->u.road.overtaking != 0 ? 1 : 0);
 
	byte t;
 

	
 
	// 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) {
 
		v->cur_speed = spd;
 
		if (_patches.vehicle_speed) {
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
src/train_cmd.cpp
Show inline comments
 
@@ -3133,13 +3133,16 @@ static void TrainController(Vehicle *v, 
 
				v->direction = chosen_dir;
 
			}
 
		} else {
 
			/* 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;
 
				v->y_pos = gp.y;
 
				VehiclePositionChanged(v);
 
				if (!(v->vehstatus & VS_HIDDEN)) EndVehicleMove(v);
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1048,27 +1048,12 @@ void DrawBridgeMiddle(const TileInfo* ti
 
		// draw pillars below for high bridges
 
		DrawBridgePillars(psid, ti, axis, type, x, y, z);
 
	}
 
}
 

	
 

	
 
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;
 
	Slope tileh = GetTileSlope(tile, &z);
 

	
 
	x &= 0xF;
0 comments (0 inline, 0 general)