mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 19:49:19 +02:00
minor ai logic tweaks, minor bug fixes
This commit is contained in:
39
Driver.cpp
39
Driver.cpp
@@ -1373,6 +1373,12 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
|||||||
// ograniczenie aktualnej prędkości aż do wyjechania za ograniczenie
|
// ograniczenie aktualnej prędkości aż do wyjechania za ograniczenie
|
||||||
fVelDes = v;
|
fVelDes = v;
|
||||||
}
|
}
|
||||||
|
if( ( sSpeedTable[ i ].iFlags & spEnd )
|
||||||
|
&& ( mvOccupied->CategoryFlag & 1 ) ) {
|
||||||
|
// if the railway track ends here set the velnext accordingly as well
|
||||||
|
// TODO: test this with turntables and such
|
||||||
|
fNext = 0.0;
|
||||||
|
}
|
||||||
// if (v==0.0) fAcc=-0.9; //hamowanie jeśli stop
|
// if (v==0.0) fAcc=-0.9; //hamowanie jeśli stop
|
||||||
continue; // i tyle wystarczy
|
continue; // i tyle wystarczy
|
||||||
}
|
}
|
||||||
@@ -2455,8 +2461,6 @@ bool TController::PrepareEngine()
|
|||||||
// wyłączanie silnika (test wyłączenia, a część wykonawcza tylko jeśli steruje komputer)
|
// wyłączanie silnika (test wyłączenia, a część wykonawcza tylko jeśli steruje komputer)
|
||||||
bool TController::ReleaseEngine() {
|
bool TController::ReleaseEngine() {
|
||||||
|
|
||||||
bool OK = false;
|
|
||||||
|
|
||||||
if( mvOccupied->Vel > 0.01 ) {
|
if( mvOccupied->Vel > 0.01 ) {
|
||||||
// TBD, TODO: make a dedicated braking procedure out of it for potential reuse
|
// TBD, TODO: make a dedicated braking procedure out of it for potential reuse
|
||||||
VelDesired = 0.0;
|
VelDesired = 0.0;
|
||||||
@@ -2466,12 +2470,15 @@ bool TController::ReleaseEngine() {
|
|||||||
; // zerowanie nastawników
|
; // zerowanie nastawników
|
||||||
}
|
}
|
||||||
IncBrake();
|
IncBrake();
|
||||||
return OK; // don't bother with the rest until we're standing still
|
// don't bother with the rest until we're standing still
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LastReactionTime = 0.0;
|
LastReactionTime = 0.0;
|
||||||
ReactionTime = PrepareTime;
|
ReactionTime = PrepareTime;
|
||||||
|
|
||||||
|
bool OK { false };
|
||||||
|
|
||||||
if( false == AIControllFlag ) {
|
if( false == AIControllFlag ) {
|
||||||
// tylko to testujemy dla pojazdu człowieka
|
// tylko to testujemy dla pojazdu człowieka
|
||||||
OK = ( ( mvOccupied->ActiveDir == 0 ) && ( mvControlling->Mains ) );
|
OK = ( ( mvOccupied->ActiveDir == 0 ) && ( mvControlling->Mains ) );
|
||||||
@@ -2515,7 +2522,7 @@ bool TController::ReleaseEngine() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mvControlling->Mains ) {
|
if( true == mvControlling->Mains ) {
|
||||||
mvControlling->CompressorSwitch( false );
|
mvControlling->CompressorSwitch( false );
|
||||||
mvControlling->ConverterSwitch( false );
|
mvControlling->ConverterSwitch( false );
|
||||||
// line breaker/engine
|
// line breaker/engine
|
||||||
@@ -2528,15 +2535,9 @@ bool TController::ReleaseEngine() {
|
|||||||
else {
|
else {
|
||||||
OK = true;
|
OK = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (OK)
|
if( OK ) {
|
||||||
{ // jeśli się zatrzymał
|
// finish vehicle shutdown
|
||||||
iEngineActive = 0;
|
|
||||||
eStopReason = stopSleep; // stoimy z powodu wyłączenia
|
|
||||||
eAction = TAction::actSleep; //śpi (wygaszony)
|
|
||||||
if (AIControllFlag)
|
|
||||||
{
|
|
||||||
if( ( mvControlling->EngineType == TEngineType::DieselElectric )
|
if( ( mvControlling->EngineType == TEngineType::DieselElectric )
|
||||||
|| ( mvControlling->EngineType == TEngineType::DieselEngine ) ) {
|
|| ( mvControlling->EngineType == TEngineType::DieselEngine ) ) {
|
||||||
// heating/cooling subsystem
|
// heating/cooling subsystem
|
||||||
@@ -2553,6 +2554,14 @@ bool TController::ReleaseEngine() {
|
|||||||
Lights( 0, 0 );
|
Lights( 0, 0 );
|
||||||
mvOccupied->BatterySwitch( false );
|
mvOccupied->BatterySwitch( false );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OK) {
|
||||||
|
// jeśli się zatrzymał
|
||||||
|
iEngineActive = 0;
|
||||||
|
eStopReason = stopSleep; // stoimy z powodu wyłączenia
|
||||||
|
eAction = TAction::actSleep; //śpi (wygaszony)
|
||||||
|
|
||||||
OrderNext(Wait_for_orders); //żeby nie próbował coś robić dalej
|
OrderNext(Wait_for_orders); //żeby nie próbował coś robić dalej
|
||||||
TableClear(); // zapominamy ograniczenia
|
TableClear(); // zapominamy ograniczenia
|
||||||
iDrivigFlags &= ~moveActive; // ma nie skanować sygnałów i nie reagować na komendy
|
iDrivigFlags &= ~moveActive; // ma nie skanować sygnałów i nie reagować na komendy
|
||||||
@@ -4415,8 +4424,8 @@ TController::UpdateSituation(double dt) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
fMinProximityDist = 0.01;
|
fMinProximityDist = 5.0;
|
||||||
fMaxProximityDist = 2.0; //[m]
|
fMaxProximityDist = 10.0; //[m]
|
||||||
fVelPlus = 2.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania
|
fVelPlus = 2.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania
|
||||||
fVelMinus = 5.0; // margines prędkości powodujący załączenie napędu
|
fVelMinus = 5.0; // margines prędkości powodujący załączenie napędu
|
||||||
}
|
}
|
||||||
@@ -4809,7 +4818,7 @@ TController::UpdateSituation(double dt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( OrderCurrentGet() & Wait_for_orders ) != 0 ) {
|
if( OrderCurrentGet() == Wait_for_orders ) {
|
||||||
// wait means sit and wait
|
// wait means sit and wait
|
||||||
VelDesired = 0.0;
|
VelDesired = 0.0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ drivingaid_panel::update() {
|
|||||||
text_lines.emplace_back( textline + " " + expandedtext, Global.UITextColor );
|
text_lines.emplace_back( textline + " " + expandedtext, Global.UITextColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const sizex = ( is_expanded ? 660 : 135 );
|
auto const sizex = ( is_expanded ? 735 : 135 );
|
||||||
size = { sizex, 85 };
|
size = { sizex, 85 };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -786,6 +786,7 @@ debug_panel::update_section_scenario( std::vector<text_line> &Output ) {
|
|||||||
// current luminance level
|
// current luminance level
|
||||||
textline = "Light level: " + to_string( Global.fLuminance, 3 );
|
textline = "Light level: " + to_string( Global.fLuminance, 3 );
|
||||||
if( Global.FakeLight ) { textline += "(*)"; }
|
if( Global.FakeLight ) { textline += "(*)"; }
|
||||||
|
textline += "\nAir temperature: " + to_string( Global.AirTemperature, 1 ) + " deg C";
|
||||||
|
|
||||||
Output.emplace_back( textline, Global.UITextColor );
|
Output.emplace_back( textline, Global.UITextColor );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ opengl_material::deserialize( cParser &Input, bool const Loadnow ) {
|
|||||||
bool
|
bool
|
||||||
opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool const Loadnow ) {
|
opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool const Loadnow ) {
|
||||||
// token can be a key or block end
|
// token can be a key or block end
|
||||||
std::string const key { Input.getToken<std::string>( true, "\n\r\t ,;[]" ) };
|
std::string const key { Input.getToken<std::string>( true, "\n\r\t ;[]" ) };
|
||||||
|
|
||||||
if( ( true == key.empty() ) || ( key == "}" ) ) { return false; }
|
if( ( true == key.empty() ) || ( key == "}" ) ) { return false; }
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ init() {
|
|||||||
"Throttle: %2d+%d %c%s",
|
"Throttle: %2d+%d %c%s",
|
||||||
" Speed: %d km/h (limit %d km/h%s)%s",
|
" Speed: %d km/h (limit %d km/h%s)%s",
|
||||||
", new limit: %d km/h in %.1f km",
|
", new limit: %d km/h in %.1f km",
|
||||||
" Grade: %.1f%%",
|
" Grade: %.1f%%%%",
|
||||||
"Brakes: %4.1f+%-2.0f%c%s",
|
"Brakes: %4.1f+%-2.0f%c%s",
|
||||||
" Pressure: %.2f kPa (train pipe: %.2f kPa)",
|
" Pressure: %.2f kPa (train pipe: %.2f kPa)",
|
||||||
"!ALERTER! ",
|
"!ALERTER! ",
|
||||||
@@ -48,7 +48,7 @@ init() {
|
|||||||
"Resume",
|
"Resume",
|
||||||
"Quit",
|
"Quit",
|
||||||
|
|
||||||
"Name: %s%s\nLoad: %d %s\nStatus: %s%s\nCouplers:\n front: %s\n rear: %s",
|
"Name: %s%s\nLoad: %.0f %s\nStatus: %s%s\nCouplers:\n front: %s\n rear: %s",
|
||||||
", owned by: ",
|
", owned by: ",
|
||||||
"none",
|
"none",
|
||||||
"Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s%s%s%.0f@%.0f",
|
"Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s%s%s%.0f@%.0f",
|
||||||
@@ -70,7 +70,7 @@ init() {
|
|||||||
"Nastawnik: %2d+%d %c%s",
|
"Nastawnik: %2d+%d %c%s",
|
||||||
" Predkosc: %d km/h (limit %d km/h%s)%s",
|
" Predkosc: %d km/h (limit %d km/h%s)%s",
|
||||||
", nowy limit: %d km/h za %.1f km",
|
", nowy limit: %d km/h za %.1f km",
|
||||||
" Pochylenie: %.1f%%",
|
" Pochylenie: %.1f%%%%",
|
||||||
"Hamulce: %4.1f+%-2.0f%c%s",
|
"Hamulce: %4.1f+%-2.0f%c%s",
|
||||||
" Cisnienie: %.2f kPa (przewod glowny: %.2f kPa)",
|
" Cisnienie: %.2f kPa (przewod glowny: %.2f kPa)",
|
||||||
"!CZUWAK! ",
|
"!CZUWAK! ",
|
||||||
@@ -88,7 +88,7 @@ init() {
|
|||||||
"Wznow",
|
"Wznow",
|
||||||
"Zakoncz",
|
"Zakoncz",
|
||||||
|
|
||||||
"Nazwa: %s%s\nLadunek: %d %s\nStatus: %s%s\nSprzegi:\n przedni: %s\n tylny: %s",
|
"Nazwa: %s%s\nLadunek: %.0f %s\nStatus: %s%s\nSprzegi:\n przedni: %s\n tylny: %s",
|
||||||
", wlasciciel: ",
|
", wlasciciel: ",
|
||||||
"wolny",
|
"wolny",
|
||||||
"Urzadzenia: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nTransfer pradow: %.0f@%.0f%s%s%s%.0f@%.0f",
|
"Urzadzenia: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nTransfer pradow: %.0f@%.0f%s%s%s%.0f@%.0f",
|
||||||
|
|||||||
Reference in New Issue
Block a user