Changeset - r7816:344737b6b0e0
[Not reviewed]
master
0 1 0
rubidium - 17 years ago 2007-10-31 22:13:41
rubidium@openttd.org
(svn r11366) -Fix [FS#1258]: road vehicles must not drive through eachother on bridges/in tunnels.
1 file changed with 9 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -884,25 +884,30 @@ static Vehicle* RoadVehFindCloseTo(Vehic
 
{
 
	RoadVehFindData rvf;
 
	Vehicle *u;
 
	Vehicle *front = v->First();
 

	
 
	if (v->u.road.reverse_ctr != 0) return NULL;
 
	if (front->u.road.reverse_ctr != 0) return NULL;
 

	
 
	rvf.x = x;
 
	rvf.y = y;
 
	rvf.dir = dir;
 
	rvf.veh = v;
 
	u = (Vehicle*)VehicleFromPosXY(x, y, &rvf, EnumCheckRoadVehClose);
 
	if (front->u.road.state == RVSB_WORMHOLE) {
 
		u = (Vehicle*)VehicleFromPos(v->tile, &rvf, EnumCheckRoadVehClose);
 
	} else {
 
		u = (Vehicle*)VehicleFromPosXY(x, y, &rvf, EnumCheckRoadVehClose);
 
	}
 

	
 
	/* This code protects a roadvehicle from being blocked for ever
 
	 * If more than 1480 / 74 days a road vehicle is blocked, it will
 
	 * drive just through it. The ultimate backup-code of TTD.
 
	 * It can be disabled. */
 
	if (u == NULL) {
 
		v->u.road.blocked_ctr = 0;
 
		front->u.road.blocked_ctr = 0;
 
		return NULL;
 
	}
 

	
 
	if (++v->u.road.blocked_ctr > 1480) return NULL;
 
	if (++front->u.road.blocked_ctr > 1480) return NULL;
 

	
 
	return u;
 
}
0 comments (0 inline, 0 general)