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

separate shp buzzer, other changes

This commit is contained in:
milek7
2019-04-02 21:53:19 +02:00
parent 155217243c
commit 20755795ea
11 changed files with 105 additions and 35 deletions

View File

@@ -2001,9 +2001,17 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
if( smBuforPrawy[ i ] ) if( smBuforPrawy[ i ] )
smBuforPrawy[ i ]->WillBeAnimated(); smBuforPrawy[ i ]->WillBeAnimated();
} }
}
for( auto &axle : m_axlesounds ) {
// wyszukiwanie osi (0 jest na końcu, dlatego dodajemy długość?)
axle.distance = (
Reversed ?
-axle.offset :
( axle.offset + MoverParameters->Dim.L ) ) + fDist;
} }
// McZapkie-250202 end. // McZapkie-250202 end.
Track->AddDynamicObject(this); // wstawiamy do toru na pozycję 0, a potem przesuniemy Track->AddDynamicObject(this); // wstawiamy do toru na pozycję 0, a potem przesuniemy
initial_track = MyTrack;
// McZapkie: zmieniono na ilosc osi brane z chk // McZapkie: zmieniono na ilosc osi brane z chk
// iNumAxles=(MoverParameters->NAxles>3 ? 4 : 2 ); // iNumAxles=(MoverParameters->NAxles>3 ? 4 : 2 );
iNumAxles = 2; iNumAxles = 2;
@@ -2012,13 +2020,33 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
std::max( MoverParameters->BDist, MoverParameters->ADist ), std::max( MoverParameters->BDist, MoverParameters->ADist ),
0.2, //żeby się dało wektory policzyć 0.2, //żeby się dało wektory policzyć
MoverParameters->Dim.L - 0.2 ); // nie mogą być za daleko bo będzie "walenie w mur" MoverParameters->Dim.L - 0.2 ); // nie mogą być za daleko bo będzie "walenie w mur"
place_on_track(Track, fDist, Reversed); double fAxleDistHalf = fAxleDist * 0.5;
initial_track = MyTrack; // przesuwanie pojazdu tak, aby jego początek był we wskazanym miejcu
// Ra: ustawienie pozycji do obliczania sprzęgów fDist -= 0.5 * MoverParameters->Dim.L; // dodajemy pół długości pojazdu, bo ustawiamy jego środek (zliczanie na minus)
MoverParameters->Loc = { switch (iNumAxles) {
-vPosition.x, // Ra: pojazdy wstawiane są na tor początkowy, a potem przesuwane
vPosition.z, case 2: // ustawianie osi na torze
vPosition.y }; // normalnie przesuwa ComputeMovement() w Update() Axle0.Init(Track, this, iDirection ? 1 : -1);
Axle0.Move((iDirection ? fDist : -fDist) + fAxleDistHalf, false);
Axle1.Init(Track, this, iDirection ? 1 : -1);
Axle1.Move((iDirection ? fDist : -fDist) - fAxleDistHalf, false); // false, żeby nie generować eventów
break;
case 4:
Axle0.Init(Track, this, iDirection ? 1 : -1);
Axle0.Move((iDirection ? fDist : -fDist) + (fAxleDistHalf + MoverParameters->ADist * 0.5), false);
Axle1.Init(Track, this, iDirection ? 1 : -1);
Axle1.Move((iDirection ? fDist : -fDist) - (fAxleDistHalf + MoverParameters->ADist * 0.5), false);
// Axle2.Init(Track,this,iDirection?1:-1);
// Axle2.Move((iDirection?fDist:-fDist)-(fAxleDistHalf-MoverParameters->ADist*0.5),false);
// Axle3.Init(Track,this,iDirection?1:-1);
// Axle3.Move((iDirection?fDist:-fDist)+(fAxleDistHalf-MoverParameters->ADist*0.5),false);
break;
}
// potrzebne do wyliczenia aktualnej pozycji; nie może być zero, bo nie przeliczy pozycji
// teraz jeszcze trzeba przypisać pojazdy do nowego toru, bo przesuwanie początkowe osi nie
// zrobiło tego
Move( 0.0001 );
ABuCheckMyTrack(); // zmiana toru na ten, co oś Axle0 (oś z przodu)
// ABuWozki 060504 // ABuWozki 060504
if (mdModel) // jeśli ma w czym szukać if (mdModel) // jeśli ma w czym szukać
{ {

View File

@@ -613,6 +613,7 @@ public:
bool is_vigilance_blinking() const; bool is_vigilance_blinking() const;
bool is_cabsignal_blinking() const; bool is_cabsignal_blinking() const;
bool is_beeping() const; bool is_beeping() const;
bool is_cabsignal_beeping() const;
bool is_braking() const; bool is_braking() const;
bool is_engine_blocked() const; bool is_engine_blocked() const;
bool radiostop_available() const; bool radiostop_available() const;

View File

@@ -161,7 +161,11 @@ bool TSecuritySystem::is_cabsignal_blinking() const {
} }
bool TSecuritySystem::is_beeping() const { bool TSecuritySystem::is_beeping() const {
return alert_timer > SoundSignalDelay; return alert_timer > SoundSignalDelay && (!separate_acknowledge || is_vigilance_blinking());
}
bool TSecuritySystem::is_cabsignal_beeping() const {
return alert_timer > SoundSignalDelay && is_cabsignal_blinking();
} }
bool TSecuritySystem::is_braking() const { bool TSecuritySystem::is_braking() const {
@@ -1141,6 +1145,8 @@ void TMoverParameters::CollisionDetect(int CouplerN, double dt)
if ((coupler.CouplingFlag & ctrain_pneumatic) == ctrain_pneumatic) if ((coupler.CouplingFlag & ctrain_pneumatic) == ctrain_pneumatic)
AlarmChainFlag = true; // hamowanie nagle - zerwanie przewodow hamulcowych AlarmChainFlag = true; // hamowanie nagle - zerwanie przewodow hamulcowych
// M7TMP: disable coupler breaking because consist cannot be teleported to starting place in one piece
/*
coupler.CouplingFlag = 0; coupler.CouplingFlag = 0;
switch (CouplerN) // wyzerowanie flag podlaczenia ale ciagle sa wirtualnie polaczone switch (CouplerN) // wyzerowanie flag podlaczenia ale ciagle sa wirtualnie polaczone
@@ -1152,6 +1158,7 @@ void TMoverParameters::CollisionDetect(int CouplerN, double dt)
coupler.Connected->Couplers[0].CouplingFlag = 0; coupler.Connected->Couplers[0].CouplingFlag = 0;
break; break;
} }
*/
WriteLog( "Bad driving: " + Name + " broke a coupler" ); WriteLog( "Bad driving: " + Name + " broke a coupler" );
} }
} }
@@ -3023,14 +3030,12 @@ bool TMoverParameters::RadiostopSwitch(bool Switch)
bool TMoverParameters::AlarmChainSwitch( bool const State ) { bool TMoverParameters::AlarmChainSwitch( bool const State ) {
bool stateswitched { false };
if( AlarmChainFlag != State ) { if( AlarmChainFlag != State ) {
// simple routine for the time being // simple routine for the time being
AlarmChainFlag = State; AlarmChainFlag = State;
stateswitched = true; return true;
} }
return stateswitched; return false;
} }
// ************************************************************************************************* // *************************************************************************************************

View File

@@ -6429,6 +6429,18 @@ TTrain::update_sounds( double const Deltatime ) {
} }
} }
if (mvOccupied->SecuritySystem.is_cabsignal_beeping()) {
if (!dsbCabsignalBuzzer.is_playing()) {
dsbCabsignalBuzzer
.pitch( dsbCabsignalBuzzer.m_frequencyoffset + dsbCabsignalBuzzer.m_frequencyfactor )
.gain( dsbCabsignalBuzzer.m_amplitudeoffset + dsbCabsignalBuzzer.m_amplitudefactor )
.play( sound_flags::looping );
}
}
else if (dsbCabsignalBuzzer.is_playing()) {
dsbCabsignalBuzzer.stop();
}
update_sounds_radio(); update_sounds_radio();
if( fTachoCount >= 3.f ) { if( fTachoCount >= 3.f ) {
@@ -6613,10 +6625,16 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
} }
else if (token == "buzzer:") else if (token == "buzzer:")
{ {
// bzyczek shp: // bzyczek czuwaka:
dsbBuzzer.deserialize( parser, sound_type::single ); dsbBuzzer.deserialize( parser, sound_type::single );
dsbBuzzer.owner( DynamicObject ); dsbBuzzer.owner( DynamicObject );
} }
else if (token == "cabsignalbuzzer:")
{
// bzyczek shp:
dsbCabsignalBuzzer.deserialize( parser, sound_type::single );
dsbCabsignalBuzzer.owner( DynamicObject );
}
else if( token == "radiostop:" ) { else if( token == "radiostop:" ) {
// radiostop // radiostop
m_radiostop.deserialize( parser, sound_type::single ); m_radiostop.deserialize( parser, sound_type::single );
@@ -6753,7 +6771,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
&dsbSwitch, &dsbPneumaticSwitch, &dsbSwitch, &dsbPneumaticSwitch,
&rsHiss, &rsHissU, &rsHissE, &rsHissX, &rsHissT, &rsSBHiss, &rsSBHissU, &rsHiss, &rsHissU, &rsHissE, &rsHissX, &rsHissT, &rsSBHiss, &rsSBHissU,
&rsFadeSound, &rsRunningNoise, &rsHuntingNoise, &rsFadeSound, &rsRunningNoise, &rsHuntingNoise,
&dsbHasler, &dsbBuzzer, &dsbSlipAlarm, &m_radiosound, &m_radiostop &dsbHasler, &dsbBuzzer, &dsbCabsignalBuzzer, &dsbSlipAlarm, &m_radiosound, &m_radiostop
}; };
for( auto sound : sounds ) { for( auto sound : sounds ) {
sound->offset( nullvector ); sound->offset( nullvector );
@@ -7039,6 +7057,9 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
if( dsbBuzzer.offset() == nullvector ) { if( dsbBuzzer.offset() == nullvector ) {
dsbBuzzer.offset( btLampkaCzuwaka.model_offset() ); dsbBuzzer.offset( btLampkaCzuwaka.model_offset() );
} }
if( dsbCabsignalBuzzer.offset() == nullvector ) {
dsbCabsignalBuzzer.offset( btLampkaCzuwaka.model_offset() );
}
// radio has two potential items which can provide the position // radio has two potential items which can provide the position
if( m_radiosound.offset() == nullvector ) { if( m_radiosound.offset() == nullvector ) {
m_radiosound.offset( btLampkaRadio.model_offset() ); m_radiosound.offset( btLampkaRadio.model_offset() );

View File

@@ -619,6 +619,7 @@ public: // reszta może by?publiczna
sound_source dsbHasler { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; sound_source dsbHasler { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source dsbBuzzer { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; sound_source dsbBuzzer { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source dsbCabsignalBuzzer { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE };
sound_source dsbSlipAlarm { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // Bombardier 011010: alarm przy poslizgu dla 181/182 sound_source dsbSlipAlarm { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // Bombardier 011010: alarm przy poslizgu dla 181/182
sound_source m_radiosound { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // cached template for radio messages sound_source m_radiosound { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // cached template for radio messages
std::vector<std::pair<int, std::shared_ptr<sound_source>>> m_radiomessages; // list of currently played radio messages std::vector<std::pair<int, std::shared_ptr<sound_source>>> m_radiomessages; // list of currently played radio messages

View File

@@ -252,6 +252,7 @@ commanddescription_sequence Commands_descriptions = {
{ "deletemodel", command_target::simulation, command_mode::oneoff }, { "deletemodel", command_target::simulation, command_mode::oneoff },
{ "trainsetmove", command_target::simulation, command_mode::oneoff }, { "trainsetmove", command_target::simulation, command_mode::oneoff },
{ "consistteleport", command_target::simulation, command_mode::oneoff }, { "consistteleport", command_target::simulation, command_mode::oneoff },
{ "pullalarmchain", command_target::simulation, command_mode::oneoff },
{ "notifyquit", command_target::simulation, command_mode::oneoff }, { "notifyquit", command_target::simulation, command_mode::oneoff },
}; };

View File

@@ -246,6 +246,7 @@ enum class user_command {
deletemodel, deletemodel,
dynamicmove, dynamicmove,
consistteleport, consistteleport,
pullalarmchain,
quitsimulation, quitsimulation,

View File

@@ -203,28 +203,26 @@ void state_manager::process_commands() {
TDynamicObject *vehicle = found_vehicle; TDynamicObject *vehicle = found_vehicle;
while (vehicle) { while (vehicle) {
vehicle->MoverParameters->DamageFlag = 0; if (vehicle->Next())
vehicle->MoverParameters->EngDmgFlag = 0;
vehicle->MoverParameters->V = 0.0;
vehicle->MoverParameters->DistCounter = 0.0;
vehicle->MoverParameters->WheelFlat = 0.0;
vehicle = vehicle->Next(); vehicle = vehicle->Next();
else
break;
} }
vehicle = found_vehicle;
while (vehicle) { while (vehicle) {
vehicle->MoverParameters->DamageFlag = 0; vehicle->MoverParameters->DamageFlag = 0;
vehicle->MoverParameters->EngDmgFlag = 0; vehicle->MoverParameters->EngDmgFlag = 0;
vehicle->MoverParameters->V = 0.0; vehicle->MoverParameters->V = 0.0;
vehicle->MoverParameters->DistCounter = 0.0; vehicle->MoverParameters->DistCounter = 0.0;
vehicle->MoverParameters->WheelFlat = 0.0; vehicle->MoverParameters->WheelFlat = 0.0;
vehicle->MoverParameters->AlarmChainFlag = false;
vehicle = vehicle->Prev(); vehicle = vehicle->Prev();
} }
} }
if (commanddata.command == user_command::fillcompressor) { if (commanddata.command == user_command::fillcompressor) {
TDynamicObject *found_vehicle = simulation::Vehicles.find(commanddata.payload); TDynamicObject *vehicle = simulation::Vehicles.find(commanddata.payload);
found_vehicle->MoverParameters->CompressedVolume = 8.0f * found_vehicle->MoverParameters->VeselVolume; vehicle->MoverParameters->CompressedVolume = 8.0f * vehicle->MoverParameters->VeselVolume;
} }
if (commanddata.command == user_command::dynamicmove) { if (commanddata.command == user_command::dynamicmove) {
@@ -254,12 +252,18 @@ void state_manager::process_commands() {
double offset = 0.0; double offset = 0.0;
while (vehicle) { while (vehicle) {
vehicle->place_on_track(track, offset, false);
offset += vehicle->MoverParameters->Dim.L; offset += vehicle->MoverParameters->Dim.L;
vehicle->place_on_track(track, offset, false);
vehicle = vehicle->Prev(); vehicle = vehicle->Prev();
} }
} }
if (commanddata.command == user_command::pullalarmchain) {
TDynamicObject *vehicle = simulation::Vehicles.find(commanddata.payload);
if (vehicle)
vehicle->MoverParameters->AlarmChainSwitch(true);
}
if (commanddata.command == user_command::quitsimulation) { if (commanddata.command == user_command::quitsimulation) {
Application.queue_quit(); Application.queue_quit();
} }

View File

@@ -118,7 +118,8 @@ init() {
"Radiostop", "Radiostop",
"Reset position", "Reset position",
"Stop and repair", "Stop and repair",
"Refill main pipe", "Refill main tank",
"Rupture main pipe",
"Move +500m", "Move +500m",
"Move -500m", "Move -500m",
@@ -326,6 +327,7 @@ init() {
u8"Zresetuj pozycję", u8"Zresetuj pozycję",
u8"Zatrzymaj i napraw", u8"Zatrzymaj i napraw",
u8"Napełnij ZG", u8"Napełnij ZG",
u8"Zerwij PG",
u8"Przesuń +500m", u8"Przesuń +500m",
u8"Przesuń -500m", u8"Przesuń -500m",

View File

@@ -108,6 +108,7 @@ enum string {
vehicleparams_resetposition, vehicleparams_resetposition,
vehicleparams_reset, vehicleparams_reset,
vehicleparams_resetpipe, vehicleparams_resetpipe,
vehicleparams_rupturepipe,
vehicleparams_move500f, vehicleparams_move500f,
vehicleparams_move500b, vehicleparams_move500b,

View File

@@ -197,12 +197,17 @@ void ui::vehicleparams_panel::render_contents()
if (ImGui::Button(LOC_STR(vehicleparams_resetposition))) { if (ImGui::Button(LOC_STR(vehicleparams_resetposition))) {
std::string payload = vehicle_ptr->name() + '%' + vehicle_ptr->initial_track->name(); std::string payload = vehicle_ptr->name() + '%' + vehicle_ptr->initial_track->name();
m_relay.post(user_command::consistteleport, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &payload); m_relay.post(user_command::consistteleport, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &payload);
m_relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
} }
if (ImGui::Button(LOC_STR(vehicleparams_resetpipe))) if (ImGui::Button(LOC_STR(vehicleparams_resetpipe)))
m_relay.post(user_command::fillcompressor, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::fillcompressor, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(LOC_STR(vehicleparams_rupturepipe)))
m_relay.post(user_command::pullalarmchain, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
ImGui::SameLine();
ImGui::Button(LOC_STR(cab_releaser_bt)); ImGui::Button(LOC_STR(cab_releaser_bt));
if (ImGui::IsItemClicked()) if (ImGui::IsItemClicked())
m_relay.post(user_command::consistreleaser, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::consistreleaser, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());