diff --git a/Train.cpp b/Train.cpp index 91a76901..d5c0a90b 100644 --- a/Train.cpp +++ b/Train.cpp @@ -1775,9 +1775,6 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com } // play sound immediately when the switch is hit, not after release if( Train->fMainRelayTimer > 0.0f ) { -#ifdef EU07_USE_OLD_SOUNDCODE - Train->dsbRelay.play(); -#endif Train->fMainRelayTimer = 0.0f; } } @@ -1788,9 +1785,6 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com // ...after opening circuit, or holding for too short time to close it // hunter-091012: przeniesione z mover.pas, zeby dzwiek sie nie zapetlal, if( Train->fMainRelayTimer > 0.0f ) { -#ifdef EU07_USE_OLD_SOUNDCODE - Train->dsbRelay.play(); -#endif Train->fMainRelayTimer = 0.0f; } // we don't exactly know which of the two buttons was used, so reset both @@ -2114,12 +2108,6 @@ void TTrain::OnCommand_motorconnectorsopen( TTrain *Train, command_data const &C } // visual feedback Train->ggStLinOffButton.UpdateValue( 1.0, Train->dsbSwitch ); - // effect - if( true == Train->mvControlled->StLinFlag ) { -#ifdef EU07_USE_OLD_SOUNDCODE - Train->dsbRelay.play(); -#endif - } // yBARC - zmienione na przeciwne, bo true to zalaczone Train->mvControlled->StLinFlag = false; if( ( Train->mvControlled->TrainType == dt_ET41 ) @@ -3195,307 +3183,6 @@ void TTrain::OnCommand_cabchangebackward( TTrain *Train, command_data const &Com } } -void TTrain::OnKeyDown(int cKey) -{ // naciśnięcie klawisza - bool const isEztOer = - ( ( mvControlled->TrainType == dt_EZT ) - && ( mvControlled->Battery == true ) - && ( mvControlled->EpFuse == true ) - && ( mvOccupied->BrakeSubsystem == ss_ESt ) - && ( mvControlled->ActiveDir != 0 ) ); // od yB - - if ( false == Global::shiftState) - { // wciśnięty [Shift] -#ifdef EU07_USE_OLD_COMMAND_SYSTEM - if( cKey == Global::Keys[ k_BrakeProfile ] ) // McZapkie-240302-B: - //----------- - // przelacznik opoznienia hamowania - { // yB://ABu: male poprawki, zeby bylo mozna ustawic dowolny wagon - int CouplNr = -2; - if( true == FreeFlyModeFlag ) - { - TDynamicObject *temp; - temp = (DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1, 1500, CouplNr)); - if (temp == NULL) - { - CouplNr = -2; - temp = (DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500, CouplNr)); - } - if( (temp) - && (temp != DynamicObject ) ) - // NOTE: the command to occupied vehicle will be passed through new command system, so we skip it here - // TODO: clean this up when whole control system is unified - { - if( ( temp->MoverParameters->BrakeDelayFlag & bdelay_M ) != 0 ) { - // can't speed it up any more than this - return; - } - auto const fasterbrakesetting = ( - temp->MoverParameters->BrakeDelayFlag < bdelay_R ? - temp->MoverParameters->BrakeDelayFlag << 1 : - temp->MoverParameters->BrakeDelayFlag | bdelay_M ); - temp->MoverParameters->BrakeDelaySwitch( fasterbrakesetting ); - } - } - } - else if( cKey == GLFW_KEY_Q ) // ze Shiftem - włączenie AI - { // McZapkie-240302 - wlaczanie automatycznego pilota (zadziala tylko w trybie debugmode) - if (DynamicObject->Mechanik) - { - if (DebugModeFlag) - if( DynamicObject->Mechanik->AIControllFlag ) { - //żeby nie trzeba było rozłączać dla zresetowania - DynamicObject->Mechanik->TakeControl( false ); - } - DynamicObject->Mechanik->TakeControl(true); - } - } -#endif - } - else // McZapkie-240302 - klawisze bez shifta - { -#ifdef EU07_USE_OLD_COMMAND_SYSTEM - if( cKey == Global::Keys[ k_IncLocalBrakeLevel ] ) - { // Ra 2014-09: w - // trybie latania - // obsługa jest w - // World.cpp - if (!FreeFlyModeFlag) - { - if (Global::ctrlState) - if ((mvOccupied->LocalBrake == ManualBrake) || (mvOccupied->MBrake == true)) - { - mvOccupied->IncManualBrakeLevel(1); - } - else if (mvOccupied->LocalBrake != ManualBrake) - mvOccupied->IncLocalBrakeLevel(1); - } - } - else if (cKey == Global::Keys[k_DecLocalBrakeLevel]) - { // Ra 2014-06: wersja dla - // swobodnego latania - // przeniesiona do - // World.cpp - if (!FreeFlyModeFlag) - { - if (Global::ctrlState) - if ((mvOccupied->LocalBrake == ManualBrake) || (mvOccupied->MBrake == true)) - mvOccupied->DecManualBrakeLevel(1); - else // Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - - // odhamować jakoś trzeba - if ((mvOccupied->LocalBrake != ManualBrake) || mvOccupied->LocalBrakePos) - mvOccupied->DecLocalBrakeLevel(1); - } - } - else if (cKey == Global::Keys[k_Brake2]) { - if (Global::ctrlState) - mvOccupied->BrakeLevelSet( - mvOccupied->Handle->GetPos(bh_NP)); // yB: czy ten stos funkcji nie powinien być jako oddzielna funkcja movera? - } - else if (cKey == Global::Keys[k_Brake0]) - { - if (Global::ctrlState) - { - mvOccupied->BrakeCtrlPos2 = 0; // wyrownaj kapturek - } - } - else if (cKey == Global::Keys[k_BrakeProfile]) - { // yB://ABu: male poprawki, zeby - // bylo mozna ustawic dowolny - // wagon - int CouplNr = -2; - if( false == FreeFlyModeFlag ) { - if( Global::ctrlState ) - if (mvOccupied->BrakeDelaySwitch(bdelay_R)) - { - play_sound( dsbPneumaticRelay ); - } - else - ; - else if (mvOccupied->BrakeDelaySwitch(bdelay_G)) - { - play_sound( dsbPneumaticRelay ); - } - } - else { - TDynamicObject *temp; - temp = (DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1, 1500, CouplNr)); - if (temp == NULL) - { - CouplNr = -2; - temp = (DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500, CouplNr)); - } - if( (temp) - && (temp != DynamicObject ) ) - // NOTE: the command to occupied vehicle will be passed through new command system, so we skip it here - // TODO: clean this up when whole control system is unified - { - if( temp->MoverParameters->BrakeDelayFlag == bdelay_G ) { - // can't slow it down any more than this - return; - } - auto const slowerbrakesetting = ( - temp->MoverParameters->BrakeDelayFlag < bdelay_M ? - temp->MoverParameters->BrakeDelayFlag >> 1 : - temp->MoverParameters->BrakeDelayFlag ^ bdelay_M ); - - if( true == temp->MoverParameters->BrakeDelaySwitch( slowerbrakesetting ) ) { -#ifdef EU07_USE_OLD_SOUNDCODE - dsbPneumaticRelay.play(); -#endif - } - } - } - } - // McZapkie-240302 - wylaczanie automatycznego pilota (w trybie ~debugmode mozna tylko raz) - else if (cKey == GLFW_KEY_Q) // bez Shift - { - if (DynamicObject->Mechanik) - DynamicObject->Mechanik->TakeControl(false); - } - else if (cKey == Global::Keys[k_CabForward]) - { - if( !CabChange( 1 ) ) { - if( TestFlag( DynamicObject->MoverParameters->Couplers[ 0 ].CouplingFlag, ctrain_passenger ) ) { - // przejscie do nastepnego pojazdu - Global::changeDynObj = DynamicObject->PrevConnected; - Global::changeDynObj->MoverParameters->ActiveCab = ( - DynamicObject->PrevConnectedNo ? - -1 : - 1 ); - } - } -/* - NOTE: disabled to allow 'prototypical' 'tricking' pantograph compressor to run unattended - if (DynamicObject->MoverParameters->ActiveCab) - mvControlled->PantCompFlag = false; // wyjście z maszynowego wyłącza sprężarkę -*/ - } - else if (cKey == Global::Keys[k_CabBackward]) - { - if (!CabChange(-1)) - if (TestFlag(DynamicObject->MoverParameters->Couplers[1].CouplingFlag, ctrain_passenger)) { - // przejscie do poprzedniego - Global::changeDynObj = DynamicObject->NextConnected; - Global::changeDynObj->MoverParameters->ActiveCab = ( - DynamicObject->NextConnectedNo ? - -1 : - 1 ); - } -/* - NOTE: disabled to allow 'prototypical' 'tricking' pantograph compressor to run unattended - if (DynamicObject->MoverParameters->ActiveCab) - mvControlled->PantCompFlag = - false; // wyjście z maszynowego wyłącza sprężarkę pomocniczą -*/ - } - else if (cKey == Global::Keys[k_Couple]) { - - if( true == FreeFlyModeFlag ) { - // tryb freefly - int CouplNr = -1; // normalnie żaden ze sprzęgów - TDynamicObject *tmp; - tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500, CouplNr); - if (tmp == nullptr) - tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1, 1500, CouplNr); - - if( ( CouplNr != -1 ) - && ( tmp != nullptr ) ) { - - tmp->couple( CouplNr ); - } - if( DynamicObject->Mechanik ) { - // aktualizacja flag kierunku w składzie - DynamicObject->Mechanik->CheckVehicles( Connect ); - } - - } - } - else if (cKey == Global::Keys[k_DeCouple]) { - - if( true == FreeFlyModeFlag ) { - // tryb freefly - int CouplNr = -1; - auto *tmp { DynamicObject->ABuScanNearestObject( DynamicObject->GetTrack(), 1, 1500, CouplNr ) }; - if( tmp == nullptr ) { - tmp = DynamicObject->ABuScanNearestObject( DynamicObject->GetTrack(), -1, 1500, CouplNr ); - } - - if( ( CouplNr != -1 ) - && ( tmp != nullptr ) ) { - - tmp->uncouple( CouplNr ); - } - if( DynamicObject->Mechanik ) { - // aktualizacja skrajnych pojazdów w składzie - DynamicObject->Mechanik->CheckVehicles( Disconnect ); - } - } - - } -#endif - // else - if (DebugModeFlag) - { // przesuwanie składu o 100m - TDynamicObject *d = DynamicObject; - if (cKey == GLFW_KEY_LEFT_BRACKET) - { - while (d) - { - d->Move(100.0 * d->DirectionGet()); - d = d->Next(); // pozostałe też - } - d = DynamicObject->Prev(); - while (d) - { - d->Move(100.0 * d->DirectionGet()); - d = d->Prev(); // w drugą stronę też - } - } - else if (cKey == GLFW_KEY_RIGHT_BRACKET) - { - while (d) - { - d->Move(-100.0 * d->DirectionGet()); - d = d->Next(); // pozostałe też - } - d = DynamicObject->Prev(); - while (d) - { - d->Move(-100.0 * d->DirectionGet()); - d = d->Prev(); // w drugą stronę też - } - } - else if (cKey == GLFW_KEY_TAB) - { - while (d) - { - d->MoverParameters->V+= d->DirectionGet()*2.78; - d = d->Next(); // pozostałe też - } - d = DynamicObject->Prev(); - while (d) - { - d->MoverParameters->V += d->DirectionGet()*2.78; - d = d->Prev(); // w drugą stronę też - } - } - } -#ifdef EU07_USE_OLD_COMMAND_SYSTEM - if (cKey == GLFW_KEY_MINUS) - { // zmniejszenie numeru kanału radiowego - if (iRadioChannel > 0) - --iRadioChannel; // 0=wyłączony - } - else if (cKey == GLFW_KEY_EQUAL) - { // zmniejszenie numeru kanału radiowego - if (iRadioChannel < 8) - ++iRadioChannel; // 0=wyłączony - } -#endif - } -} - // cab movement update, fixed step part void TTrain::UpdateMechPosition(double dt) { // Ra: mechanik powinien być @@ -4463,148 +4150,6 @@ bool TTrain::Update( double const Deltatime ) ggCompressorButton.Update(); ggCompressorLocalButton.Update(); -#ifdef EU07_USE_OLD_COMMAND_SYSTEM - if( ( ( DynamicObject->iLights[ 0 ] ) == 0 ) && ( ( DynamicObject->iLights[ 1 ] ) == 0 ) ) - { - ggRightLightButton.PutValue(0); - ggLeftLightButton.PutValue(0); - ggUpperLightButton.PutValue(0); - ggRightEndLightButton.PutValue(0); - ggLeftEndLightButton.PutValue(0); - } - - // hunter-230112 - // REFLEKTOR LEWY - // glowne oswietlenie - if ((DynamicObject->iLights[0] & 1) == 1) - if ((mvOccupied->ActiveCab) == 1) - ggLeftLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == -1) - ggRearLeftLightButton.PutValue(1); - - if ((DynamicObject->iLights[1] & 1) == 1) - if ((mvOccupied->ActiveCab) == -1) - ggLeftLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == 1) - ggRearLeftLightButton.PutValue(1); - - // końcówki - if ((DynamicObject->iLights[0] & 2) == 2) - if ((mvOccupied->ActiveCab) == 1) - { - if (ggLeftEndLightButton.SubModel) - { - ggLeftEndLightButton.PutValue(1); - ggLeftLightButton.PutValue(0); - } - else - ggLeftLightButton.PutValue(-1); - } - else if ((mvOccupied->ActiveCab) == -1) - { - if (ggRearLeftEndLightButton.SubModel) - { - ggRearLeftEndLightButton.PutValue(1); - ggRearLeftLightButton.PutValue(0); - } - else - ggRearLeftLightButton.PutValue(-1); - } - - if ((DynamicObject->iLights[1] & 2) == 2) - if ((mvOccupied->ActiveCab) == -1) - { - if (ggLeftEndLightButton.SubModel) - { - ggLeftEndLightButton.PutValue(1); - ggLeftLightButton.PutValue(0); - } - else - ggLeftLightButton.PutValue(-1); - } - else if ((mvOccupied->ActiveCab) == 1) - { - if (ggRearLeftEndLightButton.SubModel) - { - ggRearLeftEndLightButton.PutValue(1); - ggRearLeftLightButton.PutValue(0); - } - else - ggRearLeftLightButton.PutValue(-1); - } - //-------------- - // REFLEKTOR GORNY - if ((DynamicObject->iLights[0] & 4) == 4) - if ((mvOccupied->ActiveCab) == 1) - ggUpperLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == -1) - ggRearUpperLightButton.PutValue(1); - - if ((DynamicObject->iLights[1] & 4) == 4) - if ((mvOccupied->ActiveCab) == -1) - ggUpperLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == 1) - ggRearUpperLightButton.PutValue(1); - //-------------- - // REFLEKTOR PRAWY - // główne oświetlenie - if ((DynamicObject->iLights[0] & 16) == 16) - if ((mvOccupied->ActiveCab) == 1) - ggRightLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == -1) - ggRearRightLightButton.PutValue(1); - - if ((DynamicObject->iLights[1] & 16) == 16) - if ((mvOccupied->ActiveCab) == -1) - ggRightLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == 1) - ggRearRightLightButton.PutValue(1); - - // końcówki - if ((DynamicObject->iLights[0] & 32) == 32) - if ((mvOccupied->ActiveCab) == 1) - { - if (ggRightEndLightButton.SubModel) - { - ggRightEndLightButton.PutValue(1); - ggRightLightButton.PutValue(0); - } - else - ggRightLightButton.PutValue(-1); - } - else if ((mvOccupied->ActiveCab) == -1) - { - if (ggRearRightEndLightButton.SubModel) - { - ggRearRightEndLightButton.PutValue(1); - ggRearRightLightButton.PutValue(0); - } - else - ggRearRightLightButton.PutValue(-1); - } - - if ((DynamicObject->iLights[1] & 32) == 32) - if ((mvOccupied->ActiveCab) == -1) - { - if (ggRightEndLightButton.SubModel) - { - ggRightEndLightButton.PutValue(1); - ggRightLightButton.PutValue(0); - } - else - ggRightLightButton.PutValue(-1); - } - else if ((mvOccupied->ActiveCab) == 1) - { - if (ggRearRightEndLightButton.SubModel) - { - ggRearRightEndLightButton.PutValue(1); - ggRearRightLightButton.PutValue(0); - } - else - ggRearRightLightButton.PutValue(-1); - } -#endif //--------- // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy if( ( mvControlled->Heating == true ) @@ -4641,397 +4186,7 @@ bool TTrain::Update( double const Deltatime ) btLampkaCzuwaka.Turn( false ); btLampkaSHP.Turn( true ); } - // przelaczniki -#ifdef EU07_USE_OLD_COMMAND_SYSTEM - if( Console::Pressed( Global::Keys[ k_Horn ] ) ) - { - if (Global::shiftState) - { - SetFlag(mvOccupied->WarningSignal, 2); - mvOccupied->WarningSignal &= (255 - 1); - if (ggHornButton.SubModel) - ggHornButton.UpdateValue(1); - } - else - { - SetFlag(mvOccupied->WarningSignal, 1); - mvOccupied->WarningSignal &= (255 - 2); - if (ggHornButton.SubModel) - ggHornButton.UpdateValue(-1); - } - } - else - { - mvOccupied->WarningSignal = 0; - if (ggHornButton.SubModel) - ggHornButton.UpdateValue(0); - } - - if (Console::Pressed(Global::Keys[k_Horn2])) - if (Global::Keys[k_Horn2] != Global::Keys[k_Horn]) - { - SetFlag(mvOccupied->WarningSignal, 2); - } - //---------------- - // hunter-141211: wyl. szybki zalaczony i wylaczony przeniesiony z - // OnKeyPress() - if (Global::shiftState && Console::Pressed(Global::Keys[k_Main])) - { - fMainRelayTimer += dt; - ggMainOnButton.PutValue(1); - if (mvControlled->Mains != true) // hunter-080812: poprawka - mvControlled->ConverterSwitch(false); - if (fMainRelayTimer > mvControlled->InitialCtrlDelay) // wlaczanie WSa z opoznieniem - if (mvControlled->MainSwitch(true)) - { - // if (mvControlled->MainCtrlPos!=0) //zabezpieczenie, by po - // wrzuceniu pozycji przed wlaczonym - // mvControlled->StLinFlag=true; //WSem nie wrzucilo na ta - // pozycje po jego zalaczeniu //yBARC - co to tutaj robi?! - if (mvControlled->EngineType == DieselEngine) - dsbDieselIgnition->Play(0, 0, 0); - } - } - else - { - if (ggConverterButton.GetValue() != - 0) // po puszczeniu przycisku od WSa odpalanie potwora - mvControlled->ConverterSwitch(true); - // hunter-091012: przeniesione z mover.pas, zeby dzwiek sie nie zapetlal, - // drugi warunek zeby nie odtwarzalo w nieskonczonosc i przeniesienie - // zerowania timera - if ((mvControlled->Mains != true) && (fMainRelayTimer > 0)) - { - dsbRelay->Play(0, 0, 0); - fMainRelayTimer = 0; - } - ggMainOnButton.UpdateValue(0); - } - //--- - if (!Global::shiftState && Console::Pressed(Global::Keys[k_Main])) - { - ggMainOffButton.PutValue(1); - if (mvControlled->MainSwitch(false)) - dsbRelay->Play(0, 0, 0); - } - else - ggMainOffButton.UpdateValue(0); - /* if (cKey==Global::Keys[k_Main]) //z shiftem - { - ggMainOnButton.PutValue(1); - if (mvControlled->MainSwitch(true)) - { - if (mvControlled->MainCtrlPos!=0) //hunter-131211: takie - zabezpieczenie - mvControlled->StLinFlag=true; - - if (mvControlled->EngineType==DieselEngine) - dsbDieselIgnition->Play(0,0,0); - else - dsbNastawnikJazdy->Play(0,0,0); - } - } - else */ - - /* if (cKey==Global::Keys[k_Main]) //bez shifta - { - ggMainOffButton.PutValue(1); - if (mvControlled->MainSwitch(false)) - { - dsbNastawnikJazdy->Play(0,0,0); - } - } - else */ - //---------------- - // hunter-131211: czuwak przeniesiony z OnKeyPress - // hunter-091012: zrobiony test czuwaka - if (Console::Pressed(Global::Keys[k_Czuwak])) - { // czuwak testuje kierunek, ale podobno w - // EZT nie, więc może być w rozrządczym - fCzuwakTestTimer += dt; - ggSecurityResetButton.PutValue(1); - if (CAflag == false) - { - CAflag = true; - mvOccupied->SecuritySystemReset(); - } - else if (fCzuwakTestTimer > 1.0) - SetFlag(mvOccupied->SecuritySystem.Status, s_CAtest); - } - else - { - fCzuwakTestTimer = 0; - ggSecurityResetButton.UpdateValue(0); - if (TestFlag(mvOccupied->SecuritySystem.Status, - s_CAtest)) //&&(!TestFlag(mvControlled->SecuritySystem.Status,s_CAebrake))) - { - SetFlag(mvOccupied->SecuritySystem.Status, -s_CAtest); - mvOccupied->s_CAtestebrake = false; - mvOccupied->SecuritySystem.SystemBrakeCATestTimer = 0; - // if ((!TestFlag(mvOccupied->SecuritySystem.Status,s_SHPebrake)) - // ||(!TestFlag(mvOccupied->SecuritySystem.Status,s_CAebrake))) - // mvControlled->EmergencyBrakeFlag=false; //YB-HN - } - CAflag = false; - } - /* - if ( Console::Pressed(Global::Keys[k_Czuwak]) ) - { - ggSecurityResetButton.PutValue(1); - if ((mvOccupied->SecuritySystem.Status&s_aware)&& - (mvOccupied->SecuritySystem.Status&s_active)) - { - mvOccupied->SecuritySystem.SystemTimer=0; - mvOccupied->SecuritySystem.Status-=s_aware; - mvOccupied->SecuritySystem.VelocityAllowed=-1; - CAflag=1; - } - else if (CAflag!=1) - mvOccupied->SecuritySystemReset(); - } - else - { - ggSecurityResetButton.UpdateValue(0); - CAflag=0; - } - */ - - //----------------- - // hunter-201211: piasecznica przeniesiona z OnKeyPress, wlacza sie tylko, - // gdy trzymamy przycisk, a nie tak jak wczesniej (raz nacisnelo sie 's' - // i sypala caly czas) - /* - if (cKey==Global::Keys[k_Sand]) - { - if (mvControlled->SandDoseOn()) - if (mvControlled->SandDose) - { - dsbPneumaticRelay->SetVolume(-30); - dsbPneumaticRelay->Play(0,0,0); - } - } - */ - - if( Console::Pressed( Global::Keys[ k_Sand ] ) ) - { - if (mvControlled->TrainType != dt_EZT && ggSandButton.SubModel != NULL) - { - // dsbPneumaticRelay->SetVolume(-30); - // dsbPneumaticRelay->Play(0,0,0); - ggSandButton.PutValue(1); - mvControlled->SandDose = true; - // mvControlled->SandDoseOn(true); - } - } - else - { - mvControlled->SandDose = false; - // mvControlled->SandDoseOn(false); - // dsbPneumaticRelay->SetVolume(-30); - // dsbPneumaticRelay->Play(0,0,0); - } - - //----------------- - // hunter-221211: hamowanie przy poslizgu - if (Console::Pressed(Global::Keys[k_AntiSlipping])) - { - if (mvControlled->BrakeSystem != ElectroPneumatic) - { - ggAntiSlipButton.PutValue(1); - mvControlled->AntiSlippingBrake(); - } - } - else - ggAntiSlipButton.UpdateValue(0); - //----------------- - // hunter-261211: przetwornica i sprezarka - if (Global::shiftState && - Console::Pressed(Global::Keys[k_Converter])) // NBMX 14-09-2003: przetwornica wl - { //(mvControlled->CompressorPower<2) - ggConverterButton.PutValue(1); - if ((mvControlled->PantFrontVolt != 0.0) || (mvControlled->PantRearVolt != 0.0) || - (mvControlled->EnginePowerSource.SourceType != - CurrentCollector) /*||(!Global::bLiveTraction)*/) - mvControlled->ConverterSwitch(true); - // if - // ((mvControlled->EngineType!=ElectricSeriesMotor)&&(mvControlled->TrainType!=dt_EZT)) - // //hunter-110212: poprawka dla EZT - if (mvControlled->CompressorPower == 2) // hunter-091012: tak jest poprawnie - mvControlled->CompressorSwitch(true); - } - else - { - if (mvControlled->ConvSwitchType == "impulse") - { - ggConverterButton.PutValue(0); - ggConverterOffButton.PutValue(0); - } - } - // if ( - // Global::shiftState&&Console::Pressed(Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT)) - // ) //NBMX 14-09-2003: sprezarka wl - if (Global::shiftState && Console::Pressed(Global::Keys[k_Compressor]) && - (mvControlled->CompressorPower < 2)) // hunter-091012: tak jest poprawnie - { // hunter-110212: poprawka dla EZT - ggCompressorButton.PutValue(1); - mvControlled->CompressorSwitch(true); - } - if (!Global::shiftState && - Console::Pressed(Global::Keys[k_Converter])) // NBMX 14-09-2003: przetwornica wl - { - ggConverterButton.PutValue(0); - ggConverterOffButton.PutValue(1); - mvControlled->ConverterSwitch(false); - if ((mvControlled->TrainType == dt_EZT) && (!TestFlag(mvControlled->EngDmgFlag, 4))) - mvControlled->ConvOvldFlag = false; - } - // if ( - // !Global::shiftState&&Console::Pressed(Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT)) - // ) //NBMX 14-09-2003: sprezarka wl - if (!Global::shiftState && Console::Pressed(Global::Keys[k_Compressor]) && - (mvControlled->CompressorPower < 2)) // hunter-091012: tak jest poprawnie - { // hunter-110212: poprawka dla EZT - ggCompressorButton.PutValue(0); - mvControlled->CompressorSwitch(false); - } - /* - bez szifta - if (cKey==Global::Keys[k_Converter]) //NBMX wyl przetwornicy - { - if (mvControlled->ConverterSwitch(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0,0,0);; - } - } - else - if (cKey==Global::Keys[k_Compressor]) //NBMX wyl sprezarka - { - if (mvControlled->CompressorSwitch(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0,0,0);; - } - } - else - */ - //----------------- - if ((!FreeFlyModeFlag) && - (!(DynamicObject->Mechanik ? DynamicObject->Mechanik->AIControllFlag : false))) - { - if (Console::Pressed(Global::Keys[k_Releaser])) // yB: odluzniacz caly - // czas trzymany, warunki - // powinny byc takie same, - // jak przy naciskaniu. - // Wlasciwie stamtad mozna - // wyrzucic sprawdzanie - // nacisniecia. - { - if ((mvControlled->EngineType == ElectricSeriesMotor) || - (mvControlled->EngineType == DieselElectric)) - if (mvControlled->TrainType != dt_EZT) - if ((mvOccupied->BrakeCtrlPosNo > 0) && (mvControlled->ActiveDir != 0)) - { - ggReleaserButton.PutValue(1); - mvOccupied->BrakeReleaser(1); - } - } // releaser - else - mvOccupied->BrakeReleaser(0); - } // FFMF - - if (Console::Pressed(Global::Keys[k_Univ1])) - { - if (!DebugModeFlag) - { - if (ggUniversal1Button.SubModel) - if (Global::shiftState) - ggUniversal1Button.IncValue(dt / 2); - else - ggUniversal1Button.DecValue(dt / 2); - } - } - if (!Console::Pressed(Global::Keys[k_SmallCompressor])) - // Ra: przecieść to na zwolnienie klawisza - if (DynamicObject->Mechanik ? !DynamicObject->Mechanik->AIControllFlag : - false) // nie wyłączać, gdy AI - mvControlled->PantCompFlag = false; // wyłączona, gdy nie trzymamy klawisza -/* - // NOTE: disabled to allow 'prototypical' 'tricking' pantograph compressor into running unattended - if( ( ( DynamicObject->Mechanik != nullptr ) - && ( false == DynamicObject->Mechanik->AIControllFlag ) ) - && ( mvControlled->TrainType == dt_EZT ? - ( mvControlled != mvOccupied ) : - ( mvOccupied->ActiveCab != 0 ) ) ) { - // HACK: if we're in one of the cabs we can't be activating pantograph compressor - // NOTE: this will break in multiplayer setups, do a proper tracking of pantograph user then - mvControlled->PantCompFlag = false; - } -*/ - if (Console::Pressed(Global::Keys[k_Univ2])) - { - if (!DebugModeFlag) - { - if (ggUniversal2Button.SubModel) - if (Global::shiftState) - ggUniversal2Button.IncValue(dt / 2); - else - ggUniversal2Button.DecValue(dt / 2); - } - } - - // hunter-091012: zrobione z uwzglednieniem przelacznika swiatla - if (Console::Pressed(Global::Keys[k_Univ3])) - { - if (Global::shiftState) - { - if (Global::ctrlState) - { - bCabLight = true; - if (ggCabLightButton.SubModel) - { - ggCabLightButton.PutValue(1); - btCabLight.TurnOn(); - } - } - else - { - if (ggInstrumentLightButton.SubModel) - { - ggInstrumentLightButton.PutValue(1); // hunter-131211: z UpdateValue na - // PutValue - by zachowywal sie jak - // pozostale przelaczniki - if (btInstrumentLight.Active()) - InstrumentLightActive = true; - } - } - } - else - { - if (Global::ctrlState) - { - bCabLight = false; - if (ggCabLightButton.SubModel) - { - ggCabLightButton.PutValue(0); - btCabLight.TurnOff(); - } - } - else - { - if (ggInstrumentLightButton.SubModel) - { - ggInstrumentLightButton.PutValue(0); // hunter-131211: z UpdateValue na - // PutValue - by zachowywal sie jak - // pozostale przelaczniki - if (btInstrumentLight.Active()) - InstrumentLightActive = false; - } - } - } - } -#endif // ABu030405 obsluga lampki uniwersalnej: if( btInstrumentLight.Active() ) // w ogóle jest if( InstrumentLightActive ) // załączona @@ -5051,215 +4206,6 @@ bool TTrain::Update( double const Deltatime ) else btInstrumentLight.Turn( false ); -#ifdef EU07_USE_OLD_COMMAND_SYSTEM - // hunter-091012: przepisanie univ4 i zrobione z uwzglednieniem przelacznika swiatla - if (Console::Pressed(Global::Keys[k_Univ4])) - { - if( Global::shiftState ) - { - if (Global::ctrlState) - { - bCabLightDim = true; - if (ggCabLightDimButton.SubModel) - { - ggCabLightDimButton.PutValue(1); - } - } - else - { - Universal4Active = true; - // ggUniversal4Button.UpdateValue(1); - } - } - else - { - if (Global::ctrlState) - { - bCabLightDim = false; - if (ggCabLightDimButton.SubModel) - { - ggCabLightDimButton.PutValue(0); // hunter-131211: z UpdateValue na - // PutValue - by zachowywal sie jak - // pozostale przelaczniki - } - } - else - { - Universal4Active = false; - // ggUniversal4Button.UpdateValue(0); - } - } - } - // Odskakiwanie hamulce EP - if ((!Console::Pressed(Global::Keys[k_DecBrakeLevel])) && - (!Console::Pressed(Global::Keys[k_WaveBrake])) && (mvOccupied->BrakeCtrlPos == -1) && - (mvOccupied->BrakeHandle == FVel6) && (DynamicObject->Controller != AIdriver) && - (Global::iFeedbackMode != 4) && (!(Global::bMWDmasterEnable && Global::bMWDBreakEnable))) - { - // mvOccupied->BrakeCtrlPos=(mvOccupied->BrakeCtrlPos)+1; - // mvOccupied->IncBrakeLevel(); - mvOccupied->BrakeLevelSet(mvOccupied->BrakeCtrlPos + 1); - keybrakecount = 0; - if ((mvOccupied->TrainType == dt_EZT) && (mvControlled->Mains) && - (mvControlled->ActiveDir != 0)) - { - play_sound( dsbPneumaticSwitch ); - } - } - if ((mvOccupied->BrakeHandle == FV4a) && (Console::Pressed(Global::Keys[k_IncBrakeLevel]))) - { - if (Global::ctrlState) - { - mvOccupied->BrakeCtrlPos2 -= Deltatime / 20.0; - if (mvOccupied->BrakeCtrlPos2 < -1.5) - mvOccupied->BrakeCtrlPos2 = -1.5; - } - else - { - // mvOccupied->BrakeCtrlPosR+=(mvOccupied->BrakeCtrlPosR>mvOccupied->BrakeCtrlPosNo?0:dt*2); - mvOccupied->BrakeLevelAdd(dt * 2); - // mvOccupied->BrakeCtrlPos= - // floor(mvOccupied->BrakeCtrlPosR+0.499); - } - } - - if ((mvOccupied->BrakeHandle == FV4a) && (Console::Pressed(Global::Keys[k_DecBrakeLevel]))) - { - if (Global::ctrlState) - { - mvOccupied->BrakeCtrlPos2 += (mvOccupied->BrakeCtrlPos2 > 2 ? 0 : Deltatime / 20.0); - if (mvOccupied->BrakeCtrlPos2 < -3) - mvOccupied->BrakeCtrlPos2 = -3; - } - else - { - // mvOccupied->BrakeCtrlPosR-=(mvOccupied->BrakeCtrlPosR<-1?0:dt*2); - // mvOccupied->BrakeCtrlPos= - // floor(mvOccupied->BrakeCtrlPosR+0.499); - mvOccupied->BrakeLevelAdd(-dt * 2); - } - } - - if( ( mvOccupied->BrakeSystem == ElectroPneumatic ) - && ( mvOccupied->BrakeHandle == St113 ) - && ( mvControlled->EpFuse == true ) ) - if (Console::Pressed(Global::Keys[k_AntiSlipping])) // kEP - { - ggAntiSlipButton.UpdateValue(1); - if (mvOccupied->SwitchEPBrake(1)) - { - dsbPneumaticSwitch.play(); - } - } - else - { - if (mvOccupied->SwitchEPBrake(0)) - { - dsbPneumaticSwitch.play(); - } - } - - if (Console::Pressed(Global::Keys[k_DepartureSignal])) - { - ggDepartureSignalButton.PutValue(1); - btLampkaDepartureSignal.TurnOn(); - mvControlled->DepartureSignal = true; - } - else - { - btLampkaDepartureSignal.TurnOff(); - if (DynamicObject->Mechanik) // może nie być? - if (!DynamicObject->Mechanik->AIControllFlag) // tylko jeśli nie prowadzi AI - mvControlled->DepartureSignal = false; - } - if (Console::Pressed(Global::Keys[k_Main])) //[] - { - if (Global::shiftState) - ggMainButton.PutValue(1); - else - ggMainButton.PutValue(0); - } - else - ggMainButton.PutValue(0); - if (Console::Pressed(Global::Keys[k_CurrentNext])) - { - if (mvControlled->TrainType != dt_EZT) - { - if (ShowNextCurrent == false) - { - if (ggNextCurrentButton.SubModel) - { - ggNextCurrentButton.UpdateValue(1); - play_sound( dsbSwitch ); - ShowNextCurrent = true; - } - } - } - else - { - if (Global::shiftState) - { - // if (Console::Pressed(k_CurrentNext)) - { // Ra: było pod GLFW_KEY_F3 - if ((mvOccupied->EpFuseSwitch(true))) - { - play_sound( dsbPneumaticSwitch ); - } - } - } - else - { - // if (Console::Pressed(k_CurrentNext)) - { // Ra: było pod GLFW_KEY_F3 - if (Global::ctrlState) - { - if ((mvOccupied->EpFuseSwitch(false))) - { - play_sound( dsbPneumaticSwitch ); - } - } - } - } - } - } - else - { - if (ShowNextCurrent == true) - { - if (ggNextCurrentButton.SubModel) - { - ggNextCurrentButton.UpdateValue(0); - play_sound( dsbSwitch ); - ShowNextCurrent = false; - } - } - } - // Winger 010304 PantAllDownButton - if (Console::Pressed(Global::Keys[k_PantFrontUp])) - { - if (Global::shiftState) - ggPantFrontButton.PutValue(1); - else - ggPantAllDownButton.PutValue(1); - } - else if (mvControlled->PantSwitchType == "impulse") - { - ggPantFrontButton.PutValue(0); - ggPantAllDownButton.PutValue(0); - } - if (Console::Pressed(Global::Keys[k_PantRearUp])) - { - if (Global::shiftState) - ggPantRearButton.PutValue(1); - else - ggPantFrontButtonOff.PutValue(1); - } - else if (mvControlled->PantSwitchType == "impulse") - { - ggPantRearButton.PutValue(0); - ggPantFrontButtonOff.PutValue(0); - } -#endif // guziki: ggMainOffButton.Update(); ggMainOnButton.Update(); @@ -5307,14 +4253,6 @@ bool TTrain::Update( double const Deltatime ) ggHornButton.Update(); ggHornLowButton.Update(); ggHornHighButton.Update(); -#ifdef EU07_USE_OLD_COMMAND_SYSTEM - ggUniversal1Button.Update(); - ggUniversal2Button.Update(); - if( Universal4Active ) { - ggUniversal4Button.PermIncValue( dt ); - } - ggUniversal4Button.Update(); -#endif for( auto &universal : ggUniversals ) { universal.Update(); } @@ -5324,17 +4262,6 @@ bool TTrain::Update( double const Deltatime ) ggCabLightDimButton.Update(); ggBatteryButton.Update(); //------ -#ifdef EU07_USE_OLD_COMMAND_SYSTEM - ggMainOffButton.UpdateValue(0); - ggMainOnButton.UpdateValue(0); - ggSecurityResetButton.UpdateValue(0); - ggReleaserButton.UpdateValue(0); - ggSandButton.UpdateValue(0); - ggAntiSlipButton.UpdateValue(0); - ggDepartureSignalButton.UpdateValue( 0 ); - ggFuseButton.UpdateValue( 0 ); - ggConverterFuseButton.UpdateValue(0); -#endif pyScreens.update(); } // wyprowadzenie sygnałów dla haslera na PoKeys (zaznaczanie na taśmie) diff --git a/Train.h b/Train.h index b3d79190..c04f7f23 100644 --- a/Train.h +++ b/Train.h @@ -82,7 +82,6 @@ class TTrain TTrain(); // McZapkie-010302 bool Init(TDynamicObject *NewDynamicObject, bool e3d = false); - void OnKeyDown(int cKey); inline vector3 GetDirection() { return DynamicObject->VectorFront(); }; inline vector3 GetUp() { return DynamicObject->VectorUp(); }; diff --git a/World.cpp b/World.cpp index 9de820a4..b1d685ed 100644 --- a/World.cpp +++ b/World.cpp @@ -230,15 +230,6 @@ bool TWorld::Init( GLFWwindow *Window ) { "ShaXbee, Oli_EU, youBy, KURS90, Ra, hunter, szociu, Stele, Q, firleju and others\n" ); UILayer.set_background( "logo" ); -#ifdef EU07_USE_OLD_SOUNDCODE - if( true == TSoundsManager::Init( glfwGetWin32Window( window ) ) ) { - WriteLog( "Sound subsystem setup complete" ); - } - else { - ErrorLog( "Sound subsystem setup failed" ); - return false; - } -#endif glfwSetWindowTitle( window, ( Global::AppName + " (" + Global::SceneryFile + ")" ).c_str() ); // nazwa scenerii UILayer.set_progress(0.01); UILayer.set_progress( "Loading scenery / Wczytywanie scenerii" ); @@ -643,103 +634,52 @@ void TWorld::OnKeyDown(int cKey) { if( Controlled->MoverParameters->Radio ) simulation::Region->RadioStop( Camera.Pos ); } - else if (!Global::iPause) //podczas pauzy sterownaie nie działa - if (Train) - if (Controlled) - if( ( Controlled->Controller == Humandriver ) - || ( true == DebugModeFlag ) ) { - Train->OnKeyDown( cKey ); // przekazanie klawisza do kabiny - } + else { - if (FreeFlyModeFlag) // aby nie odluźniało wagonu za lokomotywą - { // operacje wykonywane na dowolnym pojeździe, przeniesione tu z kabiny - // NOTE: disabled so it doesn't interfere with new system controls in outside view - // TODO: implement as part of the new system -#ifdef EU07_USE_OLD_COMMAND_SYSTEM - if (cKey == Global::Keys[k_Releaser]) // odluźniacz - { // działa globalnie, sprawdzić zasięg - TDynamicObject *temp{ std::get( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, false ) ) }; - if( temp ) { - if( Global::ctrlState ) // z ctrl odcinanie { - temp->MoverParameters->Hamulec->SetBrakeStatus( temp->MoverParameters->Hamulec->GetBrakeStatus() ^ b_dmg ); - } - else { - temp->MoverParameters->BrakeReleaser( 1 ); - } - } - else if (cKey == Global::Keys[k_Heating]) // Ra: klawisz nie jest najszczęśliwszy - { // zmiana próżny/ładowny; Ra: zabrane z kabiny - auto *vehicle { std::get( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, false ) ) }; - if (vehicle) - { - if (Global::shiftState ? vehicle->MoverParameters->IncBrakeMult() : - vehicle->MoverParameters->DecBrakeMult()) - if (Train) - { // dźwięk oczywiście jest w kabinie - Train->dsbSwitch.play(); + if( ( true == DebugModeFlag ) + && ( false == Global::shiftState ) + && ( true == Global::ctrlState ) + && ( Controlled != nullptr ) + && ( Controlled->Controller == Humandriver ) ) { + + if( DebugModeFlag ) { + // przesuwanie składu o 100m + TDynamicObject *d = Controlled; + if( cKey == GLFW_KEY_LEFT_BRACKET ) { + while( d ) { + d->Move( 100.0 * d->DirectionGet() ); + d = d->Next(); // pozostałe też + } + d = Controlled->Prev(); + while( d ) { + d->Move( 100.0 * d->DirectionGet() ); + d = d->Prev(); // w drugą stronę też + } + } + else if( cKey == GLFW_KEY_RIGHT_BRACKET ) { + while( d ) { + d->Move( -100.0 * d->DirectionGet() ); + d = d->Next(); // pozostałe też + } + d = Controlled->Prev(); + while( d ) { + d->Move( -100.0 * d->DirectionGet() ); + d = d->Prev(); // w drugą stronę też + } + } + else if( cKey == GLFW_KEY_TAB ) { + while( d ) { + d->MoverParameters->V += d->DirectionGet()*2.78; + d = d->Next(); // pozostałe też + } + d = Controlled->Prev(); + while( d ) { + d->MoverParameters->V += d->DirectionGet()*2.78; + d = d->Prev(); // w drugą stronę też } - } - } - else if (cKey == Global::Keys[k_EndSign]) { - // Ra 2014-07: zabrane z kabiny - auto *vehicle { std::get( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, true ) ) }; - - if( vehicle == nullptr ) { return; } - - int const CouplNr { - clamp( - vehicle->DirectionGet() - * ( LengthSquared3( vehicle->HeadPosition() - Camera.Pos ) > LengthSquared3( vehicle->RearPosition() - Camera.Pos ) ? - 1 : - -1 ), - 0, 1 ) }; // z [-1,1] zrobić [0,1] - int mask, set = 0; // Ra: [Shift]+[Ctrl]+[T] odpala mi jakąś idiotyczną zmianę tapety pulpitu :/ - if (Global::shiftState) // z [Shift] zapalanie - set = mask = light::rearendsignals; // bez [Ctrl] założyć tabliczki - else if (Global::ctrlState) - set = mask = ( light::redmarker_left | light::redmarker_right ); // z [Ctrl] zapalić światła czerwone - else - mask = ( light::rearendsignals | light::redmarker_left | light::redmarker_right ); // wyłączanie ściąga wszystko - if (((vehicle->iLights[CouplNr]) & mask) != set) - { - vehicle->iLights[CouplNr] = (vehicle->iLights[CouplNr] & ~mask) | set; - if (Train) - { // Ra: ten dźwięk z kabiny to przegięcie, ale na razie zostawiam - Train->dsbSwitch.play(); } } } - else if (cKey == Global::Keys[k_IncLocalBrakeLevel]) - { // zahamowanie dowolnego pojazdu - auto *vehicle { std::get( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, false ) ) }; - if (vehicle) - { - if( Global::ctrlState ) { - if( ( vehicle->MoverParameters->LocalBrake == ManualBrake ) - || ( vehicle->MoverParameters->MBrake == true ) ) - vehicle->MoverParameters->IncManualBrakeLevel( 1 ); - } - else if( vehicle->MoverParameters->LocalBrake != ManualBrake ) { - vehicle->MoverParameters->IncLocalBrakeLevelFAST(); - } - } - } - else if (cKey == Global::Keys[k_DecLocalBrakeLevel]) - { // odhamowanie dowolnego pojazdu - auto *vehicle { std::get( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, false ) ) }; - if (vehicle) - { - if( Global::ctrlState ) { - if( ( vehicle->MoverParameters->LocalBrake == ManualBrake ) - || ( vehicle->MoverParameters->MBrake == true ) ) - vehicle->MoverParameters->DecManualBrakeLevel( 1 ); - } - else if( vehicle->MoverParameters->LocalBrake != ManualBrake ) { - vehicle->MoverParameters->DecLocalBrakeLevelFAST(); - } - } - } -#endif } }