Changeset - r7416:05030b9b19b0
[Not reviewed]
master
0 1 0
maedhros - 17 years ago 2007-08-06 12:46:49
maedhros@openttd.org
(svn r10809) -Fix (r10097): When reversing, articulated parts of road vehicles should not attempt to do their own pathfinding.
1 file changed with 11 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1373,15 +1373,15 @@ static bool RoadVehLeaveDepot(Vehicle *v
 

	
 
	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 

	
 
	return true;
 
}
 

	
 
static Trackdir FollowPreviousRoadVehicle(const Vehicle *v, const Vehicle *prev, TileIndex tile, DiagDirection entry_dir)
 
static Trackdir FollowPreviousRoadVehicle(const Vehicle *v, const Vehicle *prev, TileIndex tile, DiagDirection entry_dir, bool already_reversed)
 
{
 
	if (prev->tile == v->tile) {
 
	if (prev->tile == v->tile && !already_reversed) {
 
		/* If the previous vehicle is on the same tile as this vehicle is
 
		 * then it must have reversed. */
 
		return _road_reverse_table[entry_dir];
 
	}
 

	
 
	byte prev_state = prev->u.road.state;
 
@@ -1488,13 +1488,13 @@ static bool IndividualRoadVehicleControl
 
		const RoadDriveEntry *rdp;
 

	
 
		if (IsRoadVehFront(v)) {
 
			/* If this is the front engine, look for the right path. */
 
			dir = RoadFindPathToDest(v, tile, (DiagDirection)(rd.x & 3));
 
		} else {
 
			dir = FollowPreviousRoadVehicle(v, prev, tile, (DiagDirection)(rd.x & 3));
 
			dir = FollowPreviousRoadVehicle(v, prev, tile, (DiagDirection)(rd.x & 3), false);
 
		}
 

	
 
		if (dir == INVALID_TRACKDIR) {
 
			if (!IsRoadVehFront(v)) error("!Disconnecting road vehicle.");
 
			v->cur_speed = 0;
 
			return false;
 
@@ -1580,17 +1580,24 @@ again:
 
		RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
 
		return true;
 
	}
 

	
 
	if (rd.x & RDE_TURNED) {
 
		/* Vehicle has finished turning around, it will now head back onto the same tile */
 
		Trackdir dir = RoadFindPathToDest(v, v->tile, (DiagDirection)(rd.x & 3));
 
		Trackdir dir;
 
		uint32 r;
 
		Direction newdir;
 
		const RoadDriveEntry *rdp;
 

	
 
		if (IsRoadVehFront(v)) {
 
			/* If this is the front engine, look for the right path. */
 
			dir = RoadFindPathToDest(v, v->tile, (DiagDirection)(rd.x & 3));
 
		} else {
 
			dir = FollowPreviousRoadVehicle(v, prev, v->tile, (DiagDirection)(rd.x & 3), true);
 
		}
 

	
 
		if (dir == INVALID_TRACKDIR) {
 
			v->cur_speed = 0;
 
			return false;
 
		}
 

	
 
		rdp = _road_drive_data[v->u.road.roadtype][(_opt.road_side << RVS_DRIVE_SIDE) + dir];
0 comments (0 inline, 0 general)