mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-01 23:59:12 +01:00
fix(sleepers): the timbers a switch shares with a track with no model of timbers of its own laid of the model of the switch, not of the one of eu07.ini without the fastenings: the model of a track with none of its own that of the tracks most of its timbers carry with one, and a timber carrying none of them, as under the short tracks between the halves of a slip, of the model of the nearest timber with one up to 1.5 m away; the fastenings and checkseats selftests take the model the same way
This commit is contained in:
@@ -216,6 +216,27 @@ beam_model const *timber_model( TTrack const &Track ) {
|
||||
return timber_model();
|
||||
}
|
||||
|
||||
beam_model const *timber_model( TTrack const &Track, std::vector<beam> const &Beams ) {
|
||||
|
||||
if( false == Track.m_timber_model_name.empty() ) {
|
||||
return timber_model( Track );
|
||||
}
|
||||
std::vector<std::pair<TTrack const *, std::size_t>> panels;
|
||||
for( auto const &beam : Beams ) {
|
||||
if( beam.plain || beam.panel == nullptr ) {
|
||||
continue;
|
||||
}
|
||||
auto found { std::find_if( panels.begin(), panels.end(), [&]( auto const &Panel ) { return Panel.first == beam.panel; } ) };
|
||||
if( found == panels.end() ) {
|
||||
panels.emplace_back( beam.panel, 0 );
|
||||
found = std::prev( panels.end() );
|
||||
}
|
||||
++found->second;
|
||||
}
|
||||
auto const most { std::max_element( panels.begin(), panels.end(), []( auto const &Left, auto const &Right ) { return Left.second < Right.second; } ) };
|
||||
return ( most != panels.end() ? timber_model( *most->first ) : timber_model( Track ) );
|
||||
}
|
||||
|
||||
beam_model const *plain_model( TTrack const &Track ) {
|
||||
|
||||
if( Track.m_sleeper_enabled && false == Track.m_sleeper_model_name.empty() ) {
|
||||
|
||||
Reference in New Issue
Block a user