mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 15:09:19 +02:00
load exchange ai logic tweaks, minor bug fixes
This commit is contained in:
76
Driver.cpp
76
Driver.cpp
@@ -1285,25 +1285,6 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pVehicle->DirectionGet() != m_lastexchangedirection ) {
|
|
||||||
// generally means the ai driver moved to the opposite end of the consist
|
|
||||||
// TODO: investigate whether user playing with the reverser can mess this up
|
|
||||||
auto const left { ( m_lastexchangedirection > 0 ) ? 1 : 2 };
|
|
||||||
auto const right { 3 - left };
|
|
||||||
m_lastexchangeplatforms =
|
|
||||||
( ( m_lastexchangeplatforms & left ) != 0 ? right : 0 )
|
|
||||||
+ ( ( m_lastexchangeplatforms & right ) != 0 ? left : 0 );
|
|
||||||
m_lastexchangedirection = pVehicle->DirectionGet();
|
|
||||||
}
|
|
||||||
if( ( false == TrainParams.IsMaintenance() )
|
|
||||||
&& ( ( false == TestFlag( iDrivigFlags, moveDoorOpened ) )
|
|
||||||
|| ( true == DoesAnyDoorNeedOpening ) ) ) {
|
|
||||||
iDrivigFlags |= moveDoorOpened; // nie wykonywać drugi raz
|
|
||||||
remove_hint( locale::string::driver_hint_doorleftopen );
|
|
||||||
remove_hint( locale::string::driver_hint_doorrightopen );
|
|
||||||
Doors( true, m_lastexchangeplatforms );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OrderCurrentGet() & ( Shunt | Loose_shunt )) {
|
if (OrderCurrentGet() & ( Shunt | Loose_shunt )) {
|
||||||
OrderNext(Obey_train); // uruchomić jazdę pociągową
|
OrderNext(Obey_train); // uruchomić jazdę pociągową
|
||||||
CheckVehicles(); // zmienić światła
|
CheckVehicles(); // zmienić światła
|
||||||
@@ -2748,6 +2729,7 @@ bool TController::PrepareEngine()
|
|||||||
|
|
||||||
if( IsAnyConverterOverloadRelayOpen ) {
|
if( IsAnyConverterOverloadRelayOpen ) {
|
||||||
// wywalił bezpiecznik nadmiarowy przetwornicy
|
// wywalił bezpiecznik nadmiarowy przetwornicy
|
||||||
|
cue_action( locale::string::driver_hint_compressoroff ); // TODO: discern whether compressor needs converter to operate
|
||||||
cue_action( locale::string::driver_hint_converteroff );
|
cue_action( locale::string::driver_hint_converteroff );
|
||||||
cue_action( locale::string::driver_hint_primaryconverteroverloadreset ); // reset nadmiarowego
|
cue_action( locale::string::driver_hint_primaryconverteroverloadreset ); // reset nadmiarowego
|
||||||
}
|
}
|
||||||
@@ -6625,6 +6607,44 @@ TController::check_departure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// verify progress of load exchange
|
||||||
|
void
|
||||||
|
TController::check_load_exchange() {
|
||||||
|
|
||||||
|
ExchangeTime = 0.f;
|
||||||
|
DoesAnyDoorNeedOpening = false;
|
||||||
|
|
||||||
|
if( fStopTime > 0 ) { return; }
|
||||||
|
|
||||||
|
// czas postoju przed dalszą jazdą (np. na przystanku)
|
||||||
|
auto *vehicle { pVehicles[ end::front ] };
|
||||||
|
while( vehicle != nullptr ) {
|
||||||
|
auto const vehicleexchangetime { vehicle->LoadExchangeTime() };
|
||||||
|
DoesAnyDoorNeedOpening |= ( ( vehicleexchangetime > 0 ) && ( vehicle->LoadExchangeSpeed() == 0 ) );
|
||||||
|
ExchangeTime = std::max( ExchangeTime, vehicleexchangetime );
|
||||||
|
vehicle = vehicle->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pVehicle->DirectionGet() != m_lastexchangedirection ) {
|
||||||
|
// generally means the ai driver moved to the opposite end of the consist
|
||||||
|
// TODO: investigate whether user playing with the reverser can mess this up
|
||||||
|
auto const left { ( m_lastexchangedirection > 0 ) ? 1 : 2 };
|
||||||
|
auto const right { 3 - left };
|
||||||
|
m_lastexchangeplatforms =
|
||||||
|
( ( m_lastexchangeplatforms & left ) != 0 ? right : 0 )
|
||||||
|
+ ( ( m_lastexchangeplatforms & right ) != 0 ? left : 0 );
|
||||||
|
m_lastexchangedirection = pVehicle->DirectionGet();
|
||||||
|
}
|
||||||
|
if( ( false == TrainParams.IsMaintenance() )
|
||||||
|
&& ( ( false == TestFlag( iDrivigFlags, moveDoorOpened ) )
|
||||||
|
|| ( true == DoesAnyDoorNeedOpening ) ) ) {
|
||||||
|
iDrivigFlags |= moveDoorOpened; // nie wykonywać drugi raz
|
||||||
|
remove_hint( locale::string::driver_hint_doorleftopen );
|
||||||
|
remove_hint( locale::string::driver_hint_doorrightopen );
|
||||||
|
Doors( true, m_lastexchangeplatforms );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TController::UpdateChangeDirection() {
|
TController::UpdateChangeDirection() {
|
||||||
// TODO: rework into driver mode independent routine
|
// TODO: rework into driver mode independent routine
|
||||||
@@ -6640,6 +6660,10 @@ TController::UpdateChangeDirection() {
|
|||||||
// shared part of the routine, implement if direction matches what was requested
|
// shared part of the routine, implement if direction matches what was requested
|
||||||
if( ( mvOccupied->Vel < EU07_AI_NOMOVEMENT )
|
if( ( mvOccupied->Vel < EU07_AI_NOMOVEMENT )
|
||||||
&& ( iDirection == iDirectionOrder ) ) {
|
&& ( iDirection == iDirectionOrder ) ) {
|
||||||
|
// NOTE: we can't be sure there's a visible signal within scan range after direction change
|
||||||
|
// which would normally overwrite the old limit, so we reset signal value manually here
|
||||||
|
VelSignal = -1;
|
||||||
|
VelSignalNext = -1;
|
||||||
PrepareEngine();
|
PrepareEngine();
|
||||||
JumpToNextOrder(); // następnie robimy, co jest do zrobienia (Shunt albo Obey_train)
|
JumpToNextOrder(); // następnie robimy, co jest do zrobienia (Shunt albo Obey_train)
|
||||||
if( OrderCurrentGet() & ( Shunt | Loose_shunt | Connect ) ) {
|
if( OrderCurrentGet() & ( Shunt | Loose_shunt | Connect ) ) {
|
||||||
@@ -7249,22 +7273,12 @@ TController::adjust_desired_speed_for_limits() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// recalculate potential load exchange duration
|
// recalculate potential load exchange duration
|
||||||
DoesAnyDoorNeedOpening = false;
|
check_load_exchange();
|
||||||
ExchangeTime = 0.f;
|
|
||||||
if( fStopTime < 0 ) {
|
|
||||||
// czas postoju przed dalszą jazdą (np. na przystanku)
|
|
||||||
// verify progress of load exchange
|
|
||||||
auto *vehicle { pVehicles[ end::front ] };
|
|
||||||
while( vehicle != nullptr ) {
|
|
||||||
auto const vehicleexchangetime { vehicle->LoadExchangeTime() };
|
|
||||||
DoesAnyDoorNeedOpening |= ( ( vehicleexchangetime > 0 ) && ( vehicle->LoadExchangeSpeed() == 0 ) );
|
|
||||||
ExchangeTime = std::max( ExchangeTime, vehicleexchangetime );
|
|
||||||
vehicle = vehicle->Next();
|
|
||||||
}
|
|
||||||
if( ( ExchangeTime > 0 )
|
if( ( ExchangeTime > 0 )
|
||||||
|| ( mvOccupied->Vel > 2.0 ) ) { // HACK: force timer reset if the load exchange is cancelled due to departure
|
|| ( mvOccupied->Vel > 2.0 ) ) { // HACK: force timer reset if the load exchange is cancelled due to departure
|
||||||
WaitingSet( ExchangeTime );
|
WaitingSet( ExchangeTime );
|
||||||
}
|
}
|
||||||
|
if( fStopTime < 0 ) {
|
||||||
VelDesired = 0.0; // jak ma czekać, to nie ma jazdy
|
VelDesired = 0.0; // jak ma czekać, to nie ma jazdy
|
||||||
cue_action( locale::string::driver_hint_waitloadexchange );
|
cue_action( locale::string::driver_hint_waitloadexchange );
|
||||||
return; // speed limit can't get any lower
|
return; // speed limit can't get any lower
|
||||||
|
|||||||
1
Driver.h
1
Driver.h
@@ -314,6 +314,7 @@ private:
|
|||||||
void handle_engine();
|
void handle_engine();
|
||||||
void handle_orders();
|
void handle_orders();
|
||||||
void UpdateNextStop();
|
void UpdateNextStop();
|
||||||
|
void check_load_exchange(); // returns: estimated remaining time of load exchange, in seconds
|
||||||
void check_departure();
|
void check_departure();
|
||||||
void UpdateConnect();
|
void UpdateConnect();
|
||||||
void UpdateDisconnect();
|
void UpdateDisconnect();
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ TCommandType TMemCell::CommandCheck()
|
|||||||
eCommand = TCommandType::cm_OutsideStation;
|
eCommand = TCommandType::cm_OutsideStation;
|
||||||
bCommand = false; // tego nie powinno być w komórce
|
bCommand = false; // tego nie powinno być w komórce
|
||||||
}
|
}
|
||||||
else if( szText.compare( 0, 19, "PassengerStopPoint:" ) == 0 ) // porównanie początków
|
else if( starts_with( szText, "PassengerStopPoint:" ) ) // porównanie początków
|
||||||
{
|
{
|
||||||
eCommand = TCommandType::cm_PassengerStopPoint;
|
eCommand = TCommandType::cm_PassengerStopPoint;
|
||||||
bCommand = false; // tego nie powinno być w komórce
|
bCommand = false; // tego nie powinno być w komórce
|
||||||
|
|||||||
@@ -723,7 +723,7 @@ TController::cue_action( locale::string const Action, float const Actionparamete
|
|||||||
hint(
|
hint(
|
||||||
Action,
|
Action,
|
||||||
[this](float const Parameter) -> bool {
|
[this](float const Parameter) -> bool {
|
||||||
return ( mvPantographUnit->PantPress >= 4.2 ); } );
|
return ( mvPantographUnit->PantPress >= ( is_emu() ? ( mvPantographUnit->PantPressLockActive ? 4.6 : 2.6 ) : 4.2 ) ); } );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case locale::string::driver_hint_waitloadexchange: {
|
case locale::string::driver_hint_waitloadexchange: {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
textline =
|
textline =
|
||||||
"name: " + ( node->name().empty() ? "(none)" : node->name() )
|
"name: " + ( node->name().empty() ? "(none)" : Bezogonkow( node->name() ) )
|
||||||
+ "\nlocation: [" + to_string( node->location().x, 2 ) + ", " + to_string( node->location().y, 2 ) + ", " + to_string( node->location().z, 2 ) + "]"
|
+ "\nlocation: [" + to_string( node->location().x, 2 ) + ", " + to_string( node->location().y, 2 ) + ", " + to_string( node->location().z, 2 ) + "]"
|
||||||
+ " (distance: " + to_string( glm::length( glm::dvec3{ node->location().x, 0.0, node->location().z } -glm::dvec3{ camera.Pos.x, 0.0, camera.Pos.z } ), 1 ) + " m)";
|
+ " (distance: " + to_string( glm::length( glm::dvec3{ node->location().x, 0.0, node->location().z } -glm::dvec3{ camera.Pos.x, 0.0, camera.Pos.z } ), 1 ) + " m)";
|
||||||
text_lines.emplace_back( textline, Global.UITextColor );
|
text_lines.emplace_back( textline, Global.UITextColor );
|
||||||
@@ -112,7 +112,7 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
|
|||||||
auto const *subnode = static_cast<TTrack const *>( node );
|
auto const *subnode = static_cast<TTrack const *>( node );
|
||||||
// basic attributes
|
// basic attributes
|
||||||
textline =
|
textline =
|
||||||
"isolated: " + ( ( subnode->pIsolated != nullptr ) ? subnode->pIsolated->asName : "(none)" )
|
"isolated: " + ( ( subnode->pIsolated != nullptr ) ? Bezogonkow( subnode->pIsolated->asName ) : "(none)" )
|
||||||
+ "\nvelocity: " + to_string( subnode->SwitchExtension ? subnode->SwitchExtension->fVelocity : subnode->fVelocity )
|
+ "\nvelocity: " + to_string( subnode->SwitchExtension ? subnode->SwitchExtension->fVelocity : subnode->fVelocity )
|
||||||
+ "\nwidth: " + to_string( subnode->fTrackWidth ) + " m"
|
+ "\nwidth: " + to_string( subnode->fTrackWidth ) + " m"
|
||||||
+ "\nfriction: " + to_string( subnode->fFriction, 2 )
|
+ "\nfriction: " + to_string( subnode->fFriction, 2 )
|
||||||
@@ -168,7 +168,7 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
|
|||||||
}
|
}
|
||||||
textline += (
|
textline += (
|
||||||
event.second != nullptr ?
|
event.second != nullptr ?
|
||||||
event.second->m_name :
|
Bezogonkow( event.second->m_name ) :
|
||||||
event.first + " (missing)" );
|
event.first + " (missing)" );
|
||||||
}
|
}
|
||||||
textline += "] ";
|
textline += "] ";
|
||||||
@@ -184,7 +184,7 @@ itemproperties_panel::update( scene::basic_node const *Node ) {
|
|||||||
+ " [" + to_string( subnode->Value1(), 2 ) + "]"
|
+ " [" + to_string( subnode->Value1(), 2 ) + "]"
|
||||||
+ " [" + to_string( subnode->Value2(), 2 ) + "]";
|
+ " [" + to_string( subnode->Value2(), 2 ) + "]";
|
||||||
text_lines.emplace_back( textline, Global.UITextColor );
|
text_lines.emplace_back( textline, Global.UITextColor );
|
||||||
textline = "track: " + ( subnode->asTrackName.empty() ? "(none)" : subnode->asTrackName );
|
textline = "track: " + ( subnode->asTrackName.empty() ? "(none)" : Bezogonkow( subnode->asTrackName ) );
|
||||||
text_lines.emplace_back( textline, Global.UITextColor );
|
text_lines.emplace_back( textline, Global.UITextColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ std::ptrdiff_t len_common_prefix( std::string const &Left, std::string const &Ri
|
|||||||
// returns true if provided string ends with another provided string
|
// returns true if provided string ends with another provided string
|
||||||
bool ends_with( std::string_view String, std::string_view Suffix );
|
bool ends_with( std::string_view String, std::string_view Suffix );
|
||||||
// returns true if provided string begins with another provided string
|
// returns true if provided string begins with another provided string
|
||||||
bool starts_with( std::string_view String, std::string_view Suffix );
|
bool starts_with( std::string_view String, std::string_view Prefix );
|
||||||
|
|
||||||
template <typename Type_>
|
template <typename Type_>
|
||||||
void SafeDelete( Type_ &Pointer ) {
|
void SafeDelete( Type_ &Pointer ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user