16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-20 19:29:18 +02:00

ai brake release logic tweak, auto sandbox cab control fix, sound source fixes

This commit is contained in:
tmj-fstate
2019-10-02 22:45:41 +02:00
parent 0e62593121
commit 07ba31cd7b
5 changed files with 35 additions and 9 deletions

View File

@@ -6072,7 +6072,10 @@ TController::UpdateSituation(double dt) {
// jeśli opóźnienie większe od wymaganego (z histerezą) luzowanie, gdy za dużo
// TBD: check if the condition isn't redundant with the DecBrake() code
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition >= 0 ) {
DecBrake(); // tutaj zmniejszało o 1 przy odczepianiu
if( VelDesired > 0.0 ) {
// sanity check to prevent unintended brake release on sharp slopes
DecBrake(); // tutaj zmniejszało o 1 przy odczepianiu
}
}
}
else if( mvOccupied->Handle->TimeEP ) {
@@ -6115,7 +6118,10 @@ TController::UpdateSituation(double dt) {
// yB: luzuje hamulec dopiero przy różnicy opóźnień rzędu 0.2
if( OrderCurrentGet() != Disconnect ) {
// przy odłączaniu nie zwalniamy tu hamulca
DecBrake(); // tutaj zmniejszało o 1 przy odczepianiu
if( VelDesired > 0.0 ) {
// sanity check to prevent unintended brake release on sharp slopes
DecBrake(); // tutaj zmniejszało o 1 przy odczepianiu
}
}
fBrakeTime = (
mvOccupied->BrakeDelayFlag > bdelay_G ?

View File

@@ -111,7 +111,7 @@ auto python_taskqueue::init() -> bool {
// release the lock, save the state for future use
m_mainthread = PyEval_SaveThread();
WriteLog( "Python Interpreter setup complete" );
WriteLog( "Python Interpreter: setup complete" );
// init workers
for( auto &worker : m_workers ) {
@@ -319,6 +319,7 @@ void python_taskqueue::run( GLFWwindow *Context, rendertask_sequence &Tasks, thr
void
python_taskqueue::error() {
ErrorLog( "Python Interpreter: encountered error" );
if( m_stderr != nullptr ) {
// std err pythona jest buforowane
PyErr_Print();

View File

@@ -202,6 +202,9 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::alarmchaintoggle, &TTrain::OnCommand_alarmchaintoggle },
{ user_command::wheelspinbrakeactivate, &TTrain::OnCommand_wheelspinbrakeactivate },
{ user_command::sandboxactivate, &TTrain::OnCommand_sandboxactivate },
{ user_command::autosandboxtoggle, &TTrain::OnCommand_autosandboxtoggle },
{ user_command::autosandboxactivate, &TTrain::OnCommand_autosandboxactivate },
{ user_command::autosandboxdeactivate, &TTrain::OnCommand_autosandboxdeactivate },
{ user_command::epbrakecontroltoggle, &TTrain::OnCommand_epbrakecontroltoggle },
{ user_command::trainbrakeoperationmodeincrease, &TTrain::OnCommand_trainbrakeoperationmodeincrease },
{ user_command::trainbrakeoperationmodedecrease, &TTrain::OnCommand_trainbrakeoperationmodedecrease },
@@ -1549,7 +1552,7 @@ void TTrain::OnCommand_autosandboxactivate(TTrain *Train, command_data const &Co
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
Train->mvOccupied->SandboxAutoAllow(true);
Train->ggAutoSandAllow.UpdateValue(1.0, Train->dsbSwitch);
Train->ggAutoSandButton.UpdateValue(1.0, Train->dsbSwitch);
}
};
@@ -1557,7 +1560,7 @@ void TTrain::OnCommand_autosandboxdeactivate(TTrain *Train, command_data const &
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
Train->mvOccupied->SandboxAutoAllow(false);
Train->ggAutoSandAllow.UpdateValue(0.0, Train->dsbSwitch);
Train->ggAutoSandButton.UpdateValue(0.0, Train->dsbSwitch);
}
};
@@ -6439,6 +6442,7 @@ bool TTrain::Update( double const Deltatime )
ggUniveralBrakeButton3.Update();
ggAntiSlipButton.Update();
ggSandButton.Update();
ggAutoSandButton.Update();
ggFuseButton.Update();
ggConverterFuseButton.Update();
ggStLinOffButton.Update();
@@ -7679,6 +7683,7 @@ void TTrain::clear_cab_controls()
ggUniveralBrakeButton2.Clear();
ggUniveralBrakeButton3.Clear();
ggSandButton.Clear();
ggAutoSandButton.Clear();
ggAntiSlipButton.Clear();
ggHornButton.Clear();
ggHornLowButton.Clear();
@@ -8153,7 +8158,14 @@ void TTrain::set_cab_controls( int const Cab ) {
1.f :
0.f );
}
// sandbox
if( ggAutoSandButton.type() != TGaugeType::push ) {
ggAutoSandButton.PutValue(
mvControlled->SandDoseAutoAllow ?
1.f :
0.f );
}
// we reset all indicators, as they're set during the update pass
// TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it
}
@@ -8346,7 +8358,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
{ "universalbrake2_bt:", ggUniveralBrakeButton2 },
{ "universalbrake3_bt:", ggUniveralBrakeButton3 },
{ "sand_bt:", ggSandButton },
{ "autosandallow_sw:", ggAutoSandAllow },
{ "autosandallow_sw:", ggAutoSandButton },
{ "antislip_bt:", ggAntiSlipButton },
{ "horn_bt:", ggHornButton },
{ "hornlow_bt:", ggHornLowButton },

View File

@@ -436,7 +436,7 @@ public: // reszta może by?publiczna
TGauge ggUniveralBrakeButton2;
TGauge ggUniveralBrakeButton3;
TGauge ggSandButton; // guzik piasecznicy
TGauge ggAutoSandAllow; // przełącznik piasecznicy
TGauge ggAutoSandButton; // przełącznik piasecznicy
TGauge ggAntiSlipButton;
TGauge ggFuseButton;
TGauge ggConverterFuseButton; // hunter-261211: przycisk odblokowania nadmiarowego przetwornic i ogrzewania

View File

@@ -509,7 +509,9 @@ sound_source::update_basic( audio::openal_source &Source ) {
// when it happens update active sample counters, and potentially activate the looping
update_counter( sound_id::begin, -1 );
update_counter( soundhandle, 1 );
Source.loop( TestFlag( m_flags, sound_flags::looping ) );
if( soundhandle == sound_id::main ) {
Source.loop( TestFlag( m_flags, sound_flags::looping ) );
}
}
}
@@ -574,7 +576,12 @@ sound_source::update_basic( audio::openal_source &Source ) {
}
else {
// the emitter is either all done or was terminated early
/*
update_counter( Source.sounds[ Source.sound_index - 1 ], -1 );
*/
for( auto &soundchunk : m_soundchunks ) {
soundchunk.first.playing = 0;
}
}
}
}