Changeset - r13979:0f4523dfc5ec
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-12-18 21:34:06
rubidium@openttd.org
(svn r18531) -Fix [FS#3384] (r18404): for articulated road vehicles only the first part was accounted for, so for extremely short fronts and lots after it the spreading did not work as it should.
3 files changed with 9 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/roadstop.cpp
Show inline comments
 
@@ -279,7 +279,7 @@ bool RoadStop::Enter(RoadVehicle *rv)
 
 */
 
void RoadStop::Entry::Leave(const RoadVehicle *rv)
 
{
 
	this->occupied -= rv->rcache.cached_veh_length;
 
	this->occupied -= rv->rcache.cached_total_length;
 
	assert(this->occupied >= 0);
 
}
 

	
 
@@ -292,7 +292,7 @@ void RoadStop::Entry::Enter(const RoadVe
 
	/* we cannot assert on this->occupied < this->length because of the
 
	 * remote possibility that RVs are running through eachother when
 
	 * trying to prevention an infinite jam. */
 
	this->occupied += rv->rcache.cached_veh_length;
 
	this->occupied += rv->rcache.cached_total_length;
 
}
 

	
 
/**
 
@@ -368,7 +368,7 @@ void RoadStop::Entry::Rebuild(const Road
 

	
 
	this->occupied = 0;
 
	for (RVList::iterator it = rserh.vehicles.begin(); it != rserh.vehicles.end(); it++) {
 
		this->occupied += (*it)->rcache.cached_veh_length;
 
		this->occupied += (*it)->rcache.cached_total_length;
 
	}
 
}
 

	
src/roadveh.h
Show inline comments
 
@@ -85,8 +85,9 @@ void RoadVehUpdateCache(RoadVehicle *v);
 

	
 
/** Cached oftenly queried (NewGRF) values */
 
struct RoadVehicleCache {
 
	byte cached_veh_length;
 
	EngineID first_engine;   ///< cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself.
 
	uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
 
	byte cached_veh_length;     ///< length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback
 
	EngineID first_engine;      ///< Cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself.
 
};
 

	
 
/**
src/roadveh_cmd.cpp
Show inline comments
 
@@ -169,6 +169,8 @@ void RoadVehUpdateCache(RoadVehicle *v)
 

	
 
	v->InvalidateNewGRFCacheOfChain();
 

	
 
	v->rcache.cached_total_length = 0;
 

	
 
	for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
 
		/* Check the v->first cache. */
 
		assert(u->First() == v);
 
@@ -178,6 +180,7 @@ void RoadVehUpdateCache(RoadVehicle *v)
 

	
 
		/* Update the length of the vehicle. */
 
		u->rcache.cached_veh_length = GetRoadVehLength(u);
 
		v->rcache.cached_total_length += u->rcache.cached_veh_length;
 

	
 
		/* Invalidate the vehicle colour map */
 
		u->colourmap = PAL_NONE;
0 comments (0 inline, 0 general)