16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 13:29:18 +02:00

fixes for EZT and coupler config parsing, minor re-arrangement of the main loop.

This commit is contained in:
tmj-fstate
2017-02-01 22:44:09 +01:00
parent e3f82b68eb
commit 22e168f518
10 changed files with 1292 additions and 1377 deletions

View File

@@ -5897,3 +5897,38 @@ void TDynamicObject::OverheadTrack(float o)
}
}
};
// returns type of the nearest functional power source present in the trainset
TPowerSource
TDynamicObject::ConnectedEnginePowerSource( TDynamicObject const *Caller ) const {
// if there's engine in the current vehicle, that's good enough...
if( MoverParameters->EnginePowerSource.SourceType != TPowerSource::NotDefined ) {
return MoverParameters->EnginePowerSource.SourceType;
}
// ...otherwise check rear first...
// NOTE: the order should be reversed in flipped vehicles, but we ignore this out of laziness
if( ( nullptr != NextConnected )
&& ( NextConnected != Caller )
&& ( MoverParameters->Couplers[1].CouplingFlag & ctrain_controll == ctrain_controll ) ) {
auto source = NextConnected->ConnectedEnginePowerSource( this );
if( source != TPowerSource::NotDefined ) {
return source;
}
}
// ...then rear...
if( ( nullptr != PrevConnected )
&& ( PrevConnected != Caller )
&& ( MoverParameters->Couplers[ 0 ].CouplingFlag & ctrain_controll == ctrain_controll ) ) {
auto source = PrevConnected->ConnectedEnginePowerSource( this );
if( source != TPowerSource::NotDefined ) {
return source;
}
}
// ...if we're still here, report lack of power source
return MoverParameters->EnginePowerSource.SourceType;
}