mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-09 05:54:43 +01:00
Merge pull request #167 from pwarszawski/whois-station-ahead
whois: add lookahead mode for the timetable entry after the next stop
This commit is contained in:
@@ -1025,13 +1025,42 @@ whois_event::run_() {
|
||||
auto *targetcell { static_cast<TMemCell *>( std::get<scene::basic_node *>( target ) ) };
|
||||
if( targetcell == nullptr ) { continue; }
|
||||
// event effect code
|
||||
// +48: station after the next one, unused, stop there or passthrough
|
||||
// +40: next station name, unused, stop at next station (duplicate of +0 2nd numeric value)
|
||||
// +32: vehicle name
|
||||
// +24: vehicle type, consist brake level, obstacle distance
|
||||
// +16: load type, load amount, max load amount
|
||||
// +8: destination, direction, engine power
|
||||
// +0: train name, station count, stop on next station
|
||||
if( m_input.flags & flags::whois_name ) {
|
||||
if( ( m_input.flags & ( flags::whois_name | flags::whois_load | flags::mode_alt ) )
|
||||
== ( flags::whois_name | flags::whois_load ) ) {
|
||||
// +48 (the whois_name | whois_load combination was unused; +56, same with mode_alt
|
||||
// set, stays free for a future mode)
|
||||
// the timetable entry one past the next stop, and whether the train stops there
|
||||
auto const *owner { (
|
||||
m_activator->Mechanik != nullptr && m_activator->Mechanik->primary() ?
|
||||
m_activator->Mechanik :
|
||||
m_activator->ctOwner ) };
|
||||
auto const *entry { (
|
||||
owner != nullptr ?
|
||||
&owner->TrainTimetable().TimeTableEntryAhead( 1 ) :
|
||||
nullptr ) };
|
||||
auto const aheadname { ( entry != nullptr ? entry->StationName : "none" ) };
|
||||
auto const aheadstop { ( entry != nullptr && entry->Ah >= 0 ? 1 : 0 ) };
|
||||
|
||||
targetcell->UpdateValues(
|
||||
aheadname, // station after the next one
|
||||
0, // unused
|
||||
aheadstop, // stop there or passthrough
|
||||
m_input.flags & ( flags::text | flags::value1 | flags::value2 ) );
|
||||
|
||||
WriteLog(
|
||||
"Type: WhoIs (" + std::to_string( m_input.flags ) + ") - "
|
||||
+ "[station after next: " + aheadname + "], "
|
||||
+ "[X], "
|
||||
+ "[stop there: " + ( aheadstop != 0 ? "yes" : "no" ) + "]" );
|
||||
}
|
||||
else if( m_input.flags & flags::whois_name ) {
|
||||
// +32 or +40
|
||||
// next station name
|
||||
if( m_input.flags & flags::mode_alt ) {
|
||||
|
||||
@@ -77,6 +77,15 @@ bool TTrainParameters::IsLastStop() const {
|
||||
return StationIndex >= StationCount;
|
||||
}
|
||||
|
||||
TMTableLine const &TTrainParameters::TimeTableEntryAhead( int Offset ) const
|
||||
{ // wpis rozkladu Offset pozycji za aktualnym (bez pomijania przelotow);
|
||||
// poza zakresem 1..StationCount zwraca techniczny wpis zerowy
|
||||
int const idx { StationIndex + Offset };
|
||||
if( ( idx < 1 ) || ( idx > StationCount ) )
|
||||
return TimeTable[0];
|
||||
return TimeTable[idx];
|
||||
}
|
||||
|
||||
|
||||
bool TTrainParameters::IsMaintenance() const {
|
||||
if( StationIndex <= StationCount )
|
||||
|
||||
@@ -70,6 +70,9 @@ class TTrainParameters
|
||||
std::string ShowRelation() const;
|
||||
double WatchMTable(double DistCounter) const;
|
||||
std::string NextStop() const;
|
||||
// wpis rozkladu Offset pozycji za StationIndex (Offset>=1); poza zakresem 1..StationCount
|
||||
// zwraca techniczny wpis zerowy (TimeTable[0], StationName=="nowhere", Ah==-1)
|
||||
TMTableLine const &TimeTableEntryAhead( int Offset ) const;
|
||||
sound_source next_stop_sound() const;
|
||||
sound_source last_stop_sound() const;
|
||||
bool IsStop() const;
|
||||
|
||||
Reference in New Issue
Block a user