17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-13 06:55:39 +01:00

whois: add lookahead mode for the timetable entry after the next stop

Dispatcher scripts that route trains at a station based on where they
go afterwards (e.g. a big terminal throat with several outbound
directions) have no way to read that: whois +40 only exposes the
current/next timetable entry (NextStop()/IsStop()), which while the
train is at that very station is that station itself.

Adds flags::whois_ahead (bit 6, previously unused) plus
TTrainParameters::StationNameAhead(Offset)/StationIsStopAhead(Offset),
returning the raw TimeTable[] entry Offset positions past StationIndex
(name and whether it's a booked stop, "none"/false past the end of the
timetable). The new whois branch calls both with Offset=1, mirroring
the existing +40 branch's UpdateValues()/WriteLog() shape.

Logic-verified with an isolated harness mirroring the touched types
(TTrainParameters/TController/TMemCell shapes and the exact function
bodies); not yet build-tested against the full engine locally - relying
on CI for that.
This commit is contained in:
Piotr Warszawski
2026-09-04 15:52:38 +02:00
parent a9b561cd65
commit 4575f61cc8
4 changed files with 51 additions and 1 deletions

View File

@@ -1018,13 +1018,42 @@ whois_event::run_() {
auto *targetcell { static_cast<TMemCell *>( std::get<scene::basic_node *>( target ) ) };
if( targetcell == nullptr ) { continue; }
// event effect code
// +64: 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_ahead ) {
// +64
// 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 aheadname { (
owner != nullptr ?
owner->TrainTimetable().StationNameAhead( 1 ) :
"none" ) };
auto const aheadstop { (
owner != nullptr && owner->TrainTimetable().StationIsStopAhead( 1 ) ?
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 ) {