(svn r23290) -Fix [FS#2379,FS#3569]: Change the centre of train vehicles to depend on the vehicle length instead of being fixed at 4/8th of the original vehicle length to make sure shortened vehicles don't block tiles they shouldn't block.

This commit is contained in:
michi_cc
2011-11-21 20:51:43 +00:00
parent 3748cab608
commit 4d2a9e384c
10 changed files with 230 additions and 59 deletions

View File

@@ -148,6 +148,18 @@ struct Train : public GroundVehicle<Train, VEH_TRAIN> {
return v;
}
/**
* Calculate the offset from this vehicle's center to the following center taking the vehicle lengths into account.
* @return Offset from center to center.
*/
int CalcNextVehicleOffset() const
{
/* For vehicles with odd lengths the part before the center will be one unit
* longer than the part after the center. This means we have to round up the
* length of the next vehicle but may not round the length of the current
* vehicle. */
return this->gcache.cached_veh_length / 2 + (this->Next() != NULL ? this->Next()->gcache.cached_veh_length + 1 : 0) / 2;
}
protected: // These functions should not be called outside acceleration code.