diff src/roadveh_cmd.cpp @ 11327:fc99317cb85b draft

(svn r15677) -Fix [FS#2546]: vehicle images would be determined during the process of moving the vehicle which means that only the (orientation) data for the vehicles in front of it is valid. Now the data for the vehicles behind the vehicle are valid too.
author rubidium <rubidium@openttd.org>
date Wed, 11 Mar 2009 23:23:08 +0000
parents 557dd16a7c24
children 11acaad65229
line wrap: on
line diff
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1248,7 +1248,6 @@
 	v->u.road.state = tdir;
 	v->u.road.frame = RVC_DEPOT_START_FRAME;
 
-	v->cur_image = v->GetImage(v->direction);
 	v->UpdateDeltaXY(v->direction);
 	SetRoadVehPosition(v, x, y);
 
@@ -1377,7 +1376,6 @@
 
 		if (IsTileType(gp.new_tile, MP_TUNNELBRIDGE) && HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
 			/* Vehicle has just entered a bridge or tunnel */
-			v->cur_image = v->GetImage(v->direction);
 			v->UpdateDeltaXY(v->direction);
 			SetRoadVehPosition(v, gp.x, gp.y);
 			return true;
@@ -1524,7 +1522,6 @@
 			v->cur_speed -= v->cur_speed >> 2;
 		}
 
-		v->cur_image = v->GetImage(v->direction);
 		v->UpdateDeltaXY(v->direction);
 		RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
 		return true;
@@ -1590,7 +1587,6 @@
 			v->cur_speed -= v->cur_speed >> 2;
 		}
 
-		v->cur_image = v->GetImage(v->direction);
 		v->UpdateDeltaXY(v->direction);
 		RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
 		return true;
@@ -1631,7 +1627,6 @@
 		v->cur_speed -= (v->cur_speed >> 2);
 		if (old_dir != v->u.road.state) {
 			/* The vehicle is in a road stop */
-			v->cur_image = v->GetImage(v->direction);
 			v->UpdateDeltaXY(v->direction);
 			SetRoadVehPosition(v, v->x_pos, v->y_pos);
 			/* Note, return here means that the frame counter is not incremented
@@ -1755,7 +1750,6 @@
 	 * in a depot or entered a tunnel/bridge */
 	if (!HasBit(r, VETS_ENTERED_WORMHOLE)) v->u.road.frame++;
 
-	v->cur_image = v->GetImage(v->direction);
 	v->UpdateDeltaXY(v->direction);
 	RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
 	return true;
@@ -1813,6 +1807,14 @@
 		if (j >= adv_spd && RoadVehCheckTrainCrash(v)) break;
 	}
 
+	for (Vehicle *u = v; u != NULL; u = u->Next()) {
+		if ((u->vehstatus & VS_HIDDEN) != 0) continue;
+
+		uint16 old_image = u->cur_image;
+		u->cur_image = u->GetImage(u->direction);
+		if (old_image != u->cur_image) VehicleMove(u, true);
+	}
+
 	if (v->progress == 0) v->progress = j;
 }