17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 02:49:19 +02:00

Ask the cell itself whether its command is still pending, guard the order table

The spent command was tracked in a table flag, which is lost whenever the speed
table is rebuilt - the cell would go back to being a stop point. The memcell
already knows: StopCommandSent() drops the pending flag and keeps the text, so
the event now answers is_command_spent() and the table point follows it.

OrderNextGet() read one past the end of OrderList when the current order sat in
the last slot; it now reports Wait_for_orders there, which is what OrderNext()
wraps to anyway.
This commit is contained in:
maj00r
2026-09-15 22:09:02 +02:00
parent 1e52bb43ba
commit f718dbf95d
4 changed files with 27 additions and 8 deletions

View File

@@ -274,9 +274,10 @@ void TSpeedPos::CommandCheck()
// inna komenda w evencie skanowanym powoduje zatrzymanie i wysłanie tej komendy
// nie manewrowa, nie przystanek, nie zatrzymać na SBL
// jak nieznana komenda w komórce sygnałowej, to zatrzymujemy
// a cell keeps its text after the command has been delivered - going on standing in
// front of it would make every command cell a permanent stop point
fVelNext = ( ( iFlags & spCommandSent ) != 0 ? -1.0 : 0.0 );
// a cell keeps its text after the command has been delivered, so asking the driver to
// stand in front of it any longer would make every command cell a permanent stop point
fVelNext = ( evEvent != nullptr && evEvent->is_command_spent() ? -1.0 : 0.0 );
if( fVelNext < 0.0 ) { iFlags |= spCommandSent; }
// TODO: check whether clearing spShuntSemaphor flag doesn't cause problems
// potentially it can invalidate shunt semaphor used to transmit timetable or similar command
iFlags &= ~(spShuntSemaphor | spPassengerStopPoint | spStopOnSBL);
@@ -8525,9 +8526,6 @@ TController::check_route_ahead( double const Range ) {
eSignNext->StopCommandSent(); // się wykonało już
*/ // replacement of the above
eSignNext->send_command( *this );
for( auto &point : sSpeedTable ) {
if( point.evEvent == eSignNext ) { point.iFlags |= spCommandSent; }
}
}
}
break;

View File

@@ -696,9 +696,10 @@ private:
};
inline TOrders TController::OrderCurrentGet() const {
return OrderList[ OrderPos ];
return OrderList[ std::clamp( OrderPos, 0, maxorders - 1 ) ];
}
inline TOrders TController::OrderNextGet() const {
return OrderList[ OrderPos + 1 ];
// the last slot has no successor; OrderNext() wraps to zero there anyway
return ( OrderPos + 1 < maxorders ? OrderList[ OrderPos + 1 ] : Wait_for_orders );
}

View File

@@ -415,6 +415,13 @@ basic_event::is_command() const {
return false;
};
// returns: true for a data cell whose command has already been delivered
bool
basic_event::is_command_spent() const {
return false;
};
std::string
basic_event::input_text() const {
// odczytanie komendy z eventu
@@ -650,6 +657,13 @@ getvalues_event::is_command() const {
return m_input.data_cell()->StopCommand();
}
// returns: true for a data cell whose command has already been delivered
bool
getvalues_event::is_command_spent() const {
// the cell keeps its text after the command was sent, only the pending flag is dropped
return false == m_input.data_cell()->StopCommand();
}
// input data access
std::string
getvalues_event::input_text() const {

View File

@@ -78,6 +78,10 @@ public:
virtual
bool
is_command() const;
// returns: true for a data cell whose command has already been delivered
virtual
bool
is_command_spent() const;
// input data access
virtual std::string input_text() const;
virtual TCommandType input_command() const;
@@ -236,6 +240,8 @@ public:
void send_command( TController &Controller ) override;
// returns: true if associated data cell contains a command for vehicle controller
bool is_command() const override;
// returns: true for a data cell whose command has already been delivered
bool is_command_spent() const override;
// input data access
std::string input_text() const override;
TCommandType input_command() const override;