Changeset - r17196:ef67da674066
[Not reviewed]
master
0 2 0
rubidium - 13 years ago 2011-02-02 22:06:14
rubidium@openttd.org
(svn r21945) -Codechange: simplify setting the overtaking counter and remove the magic from its numbers
2 files changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/roadveh.h
Show inline comments
 
@@ -76,6 +76,9 @@ static const uint RVC_TURN_AROUND_START_
 
static const uint RVC_DRIVE_THROUGH_STOP_FRAME           = 11;
 
static const uint RVC_DEPOT_STOP_FRAME                   = 11;
 

	
 
/** The number of ticks a vehicle has for overtaking. */
 
static const byte RV_OVERTAKE_TIMEOUT = 35;
 

	
 
void RoadVehUpdateCache(RoadVehicle *v);
 

	
 
/**
src/roadveh_cmd.cpp
Show inline comments
 
@@ -773,13 +773,10 @@ static void RoadVehCheckOvertake(RoadVeh
 
	od.tile = v->tile + TileOffsByDiagDir(DirToDiagDir(v->direction));
 
	if (CheckRoadBlockedForOvertaking(&od)) return;
 

	
 
	if (od.u->cur_speed == 0 || (od.u->vehstatus & VS_STOPPED)) {
 
		v->overtaking_ctr = 0x11;
 
		v->overtaking = RVSB_DRIVE_SIDE;
 
	} else {
 
		v->overtaking_ctr = 0;
 
		v->overtaking = RVSB_DRIVE_SIDE;
 
	}
 
	/* When the vehicle in front of us is stopped we may only take
 
	 * half the time to pass it than when the vehicle is moving. */
 
	v->overtaking_ctr = (od.u->cur_speed == 0 || (od.u->vehstatus & VS_STOPPED)) ? RV_OVERTAKE_TIMEOUT / 2 : 0;
 
	v->overtaking = RVSB_DRIVE_SIDE;
 
}
 

	
 
static void RoadZPosAffectSpeed(RoadVehicle *v, byte old_z)
 
@@ -1043,7 +1040,7 @@ static bool IndividualRoadVehicleControl
 
		if (IsTileType(v->tile, MP_STATION)) {
 
			/* Force us to be not overtaking! */
 
			v->overtaking = 0;
 
		} else if (++v->overtaking_ctr >= 35) {
 
		} else if (++v->overtaking_ctr >= RV_OVERTAKE_TIMEOUT) {
 
			/* If overtaking just aborts at a random moment, we can have a out-of-bound problem,
 
			 *  if the vehicle started a corner. To protect that, only allow an abort of
 
			 *  overtake if we are on straight roads */
0 comments (0 inline, 0 general)