(svn r11367) -Fix [FS#1258]: non-articulated road vehicles should be able to overtake (not-too-long) articulated vehicles, i.e. overtaking of articulated vehicles that are several (3+) tiles long is not supported.
authorrubidium
Wed, 31 Oct 2007 22:15:19 +0000
changeset 7817 f5fd95f8bb9f
parent 7816 997b23172406
child 7818 fb1eecc34fd7
(svn r11367) -Fix [FS#1258]: non-articulated road vehicles should be able to overtake (not-too-long) articulated vehicles, i.e. overtaking of articulated vehicles that are several (3+) tiles long is not supported.
src/roadveh_cmd.cpp
--- a/src/roadveh_cmd.cpp	Wed Oct 31 22:13:41 2007 +0000
+++ b/src/roadveh_cmd.cpp	Wed Oct 31 22:15:19 2007 +0000
@@ -1015,7 +1015,7 @@
 	const OvertakeData* od = (OvertakeData*)data;
 
 	return
-		v->tile == od->tile && v->type == VEH_ROAD && v != od->u && v != od->v ?
+		v->tile == od->tile && v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v ?
 			v : NULL;
 }
 
@@ -1465,8 +1465,8 @@
 		GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 
 		const Vehicle *u = RoadVehFindCloseTo(v, gp.x, gp.y, v->direction);
-		if (u != NULL && u->cur_speed < v->cur_speed) {
-			v->cur_speed = u->cur_speed;
+		if (u != NULL && u->First()->cur_speed < v->cur_speed) {
+			v->cur_speed = u->First()->cur_speed;
 			return false;
 		}
 
@@ -1663,6 +1663,7 @@
 		Vehicle* u = RoadVehFindCloseTo(v, x, y, new_dir);
 
 		if (u != NULL) {
+			u = u->First();
 			/* There is a vehicle in front overtake it if possible */
 			if (v->u.road.overtaking == 0) RoadVehCheckOvertake(v, u);
 			if (v->u.road.overtaking == 0) v->cur_speed = u->cur_speed;