mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-04 23:35:43 +01:00
whois: fall back to the consist owner in the +0/+7 mode too
The +8/+16/+24/+32/+40 (and the new +48) modes all pick the reporting vehicle the same way: the activator's own Mechanik if it's the primary driver, otherwise the consist's controlling vehicle (ctOwner) - so the event still resolves correctly if a wagon happens to trigger it ahead of its locomotive. +0 (train name / stations left / stop flag) predates that pattern and never got it: it required m_activator->Mechanik directly and silently wrote nothing otherwise. A whois hook placed where the loco doesn't necessarily lead (e.g. a train that reverses direction, or one being propelled) can have a wagon trigger the event first and the memcell stays empty, with no error - hard to diagnose from scenery side. Same owner-selection, same guard semantics (still nothing written if neither the activator nor its consist has a controller), only the source of the vehicle it reads from is widened.
This commit is contained in:
@@ -1129,20 +1129,28 @@ whois_event::run_() {
|
|||||||
+ "[engine power: " + to_string( m_activator->MoverParameters->Power, 2 ) + "]" );
|
+ "[engine power: " + to_string( m_activator->MoverParameters->Power, 2 ) + "]" );
|
||||||
}
|
}
|
||||||
// +0
|
// +0
|
||||||
else if( m_activator->Mechanik ) {
|
else {
|
||||||
if( m_activator->Mechanik->primary() ) { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera!
|
// same owner selection as the +8/+16/+24/+32/+40/+48 branches above: fall back to
|
||||||
|
// the consist's controlling vehicle if the activator itself isn't one (e.g. a wagon
|
||||||
|
// triggered the event ahead of its locomotive) - +0 used to require the activator's
|
||||||
|
// own Mechanik and silently produce nothing for a wagon-triggered whois
|
||||||
|
auto const *owner { (
|
||||||
|
m_activator->Mechanik != nullptr && m_activator->Mechanik->primary() ?
|
||||||
|
m_activator->Mechanik :
|
||||||
|
m_activator->ctOwner ) };
|
||||||
|
if( owner != nullptr ) {
|
||||||
targetcell->UpdateValues(
|
targetcell->UpdateValues(
|
||||||
m_activator->Mechanik->TrainName(),
|
owner->TrainName(),
|
||||||
m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex(), // ile przystanków do końca
|
owner->StationCount() - owner->StationIndex(), // ile przystanków do końca
|
||||||
m_activator->Mechanik->IsStop() ?
|
owner->IsStop() ?
|
||||||
1 :
|
1 :
|
||||||
0, // 1, gdy ma tu zatrzymanie
|
0, // 1, gdy ma tu zatrzymanie
|
||||||
m_input.flags & ( flags::text | flags::value1 | flags::value2 ) );
|
m_input.flags & ( flags::text | flags::value1 | flags::value2 ) );
|
||||||
WriteLog(
|
WriteLog(
|
||||||
"Type: WhoIs (" + std::to_string( m_input.flags ) + ") - "
|
"Type: WhoIs (" + std::to_string( m_input.flags ) + ") - "
|
||||||
+ "[train: " + m_activator->Mechanik->TrainName() + "], "
|
+ "[train: " + owner->TrainName() + "], "
|
||||||
+ "[stations left: " + std::to_string( m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex() ) + "], "
|
+ "[stations left: " + std::to_string( owner->StationCount() - owner->StationIndex() ) + "], "
|
||||||
+ "[stop at next station: " + ( m_activator->Mechanik->IsStop() ? "yes" : "no") + "]" );
|
+ "[stop at next station: " + ( owner->IsStop() ? "yes" : "no") + "]" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user