Changeset - r15116:ab250200d5be
[Not reviewed]
master
0 1 0
frosch - 15 years ago 2010-05-03 19:55:03
frosch@openttd.org
(svn r19755) -Fix: Blocked roadvehicles should first check whether they are still blocked before accelerating again, instead of continuous starting/stopping.
1 file changed with 10 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1598,13 +1598,18 @@ static bool RoadVehController(RoadVehicl
 
	int j = RoadVehAccelerate(v);
 

	
 
	int adv_spd = (v->direction & 1) ? 192 : 256;
 
	bool blocked = false;
 
	while (j >= adv_spd) {
 
		j -= adv_spd;
 

	
 
		RoadVehicle *u = v;
 
		for (RoadVehicle *prev = NULL; u != NULL; prev = u, u = u->Next()) {
 
			if (!IndividualRoadVehicleController(u, prev)) break;
 
			if (!IndividualRoadVehicleController(u, prev)) {
 
				blocked = true;
 
				break;
 
			}
 
		}
 
		if (blocked) break;
 

	
 
		/* 192 spd used for going straight, 256 for going diagonally. */
 
		adv_spd = (v->direction & 1) ? 192 : 256;
 
@@ -1619,7 +1624,10 @@ static bool RoadVehController(RoadVehicl
 
		u->UpdateViewport(false, false);
 
	}
 

	
 
	if (v->progress == 0) v->progress = j;
 
	/* If movement is blocked, set 'progress' to its maximum, so the roadvehicle does
 
	 * not accelerate again before it can actually move. I.e. make sure it tries to advance again
 
	 * on next tick to discover whether it is still blocked. */
 
	if (v->progress == 0) v->progress = blocked ? adv_spd - 1 : j;
 

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