mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
build 210426. announcements soundproofing, releaser control logic tweak, minor bug fixes
This commit is contained in:
15
Driver.cpp
15
Driver.cpp
@@ -7622,7 +7622,7 @@ void TController::control_tractive_force() {
|
|||||||
auto const velocity { DirectionalVel() };
|
auto const velocity { DirectionalVel() };
|
||||||
// jeśli przyspieszenie pojazdu jest mniejsze niż żądane oraz...
|
// jeśli przyspieszenie pojazdu jest mniejsze niż żądane oraz...
|
||||||
if( ( AccDesired > EU07_AI_NOACCELERATION ) // don't add power if not asked for actual speed-up
|
if( ( AccDesired > EU07_AI_NOACCELERATION ) // don't add power if not asked for actual speed-up
|
||||||
&& ( AccDesired - AbsAccS > 0.05 )
|
&& ( AbsAccS < AccDesired /* - 0.05 */ )
|
||||||
&& ( false == TestFlag( iDrivigFlags, movePress ) ) ) {
|
&& ( false == TestFlag( iDrivigFlags, movePress ) ) ) {
|
||||||
// ...jeśli prędkość w kierunku czoła jest mniejsza od dozwolonej o margines...
|
// ...jeśli prędkość w kierunku czoła jest mniejsza od dozwolonej o margines...
|
||||||
if( velocity < (
|
if( velocity < (
|
||||||
@@ -7652,7 +7652,7 @@ void TController::control_tractive_force() {
|
|||||||
else if( ( velocity > VelDesired + SpeedCtrlMargin)
|
else if( ( velocity > VelDesired + SpeedCtrlMargin)
|
||||||
|| ( fAccGravity < -0.01 ?
|
|| ( fAccGravity < -0.01 ?
|
||||||
AccDesired < 0.0 :
|
AccDesired < 0.0 :
|
||||||
(AbsAccS > AccDesired + 0.05) )
|
( AbsAccS > AccDesired + 0.05 ) )
|
||||||
|| ( IsAnyCouplerStretched ) ) {
|
|| ( IsAnyCouplerStretched ) ) {
|
||||||
// jak za bardzo przyspiesza albo prędkość przekroczona
|
// jak za bardzo przyspiesza albo prędkość przekroczona
|
||||||
// dodany wyjatek na "pelna w przod"
|
// dodany wyjatek na "pelna w przod"
|
||||||
@@ -7817,11 +7817,12 @@ void TController::control_releaser() {
|
|||||||
if( mvOccupied->BrakeSystem != TBrakeSystem::Pneumatic ) { return; }
|
if( mvOccupied->BrakeSystem != TBrakeSystem::Pneumatic ) { return; }
|
||||||
|
|
||||||
auto const hasreleaser {
|
auto const hasreleaser {
|
||||||
( mvOccupied->BrakeHandle == TBrakeHandle::FV4a )
|
( false == ( is_dmu() || is_emu() ) ) // TODO: a more refined test than rejecting these types wholesale
|
||||||
|| ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P )
|
&& ( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a )
|
||||||
|| ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K5P )
|
|| ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P )
|
||||||
|| ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P )
|
|| ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K5P )
|
||||||
|| ( mvOccupied->BrakeHandle == TBrakeHandle::M394 ) };
|
|| ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P )
|
||||||
|
|| ( mvOccupied->BrakeHandle == TBrakeHandle::M394 ) ) };
|
||||||
|
|
||||||
if( false == hasreleaser ) { return; }
|
if( false == hasreleaser ) { return; }
|
||||||
|
|
||||||
|
|||||||
60
DynObj.cpp
60
DynObj.cpp
@@ -4109,17 +4109,20 @@ void TDynamicObject::RenderSounds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// heater sound
|
// heater sound
|
||||||
if( ( true == MoverParameters->Heating )
|
{
|
||||||
&& ( std::abs( MoverParameters->enrot ) > 0.01 ) ) {
|
auto const isdieselenginepowered { ( MoverParameters->EngineType == TEngineType::DieselElectric ) || ( MoverParameters->EngineType == TEngineType::DieselEngine ) };
|
||||||
// TBD: check whether heating should depend on 'engine rotations' for electric vehicles
|
if( ( true == MoverParameters->Heating )
|
||||||
sHeater
|
&& ( ( false == isdieselenginepowered )
|
||||||
.pitch( true == sHeater.is_combined() ?
|
|| ( std::abs( MoverParameters->enrot ) > 0.01 ) ) ) {
|
||||||
|
sHeater
|
||||||
|
.pitch( true == sHeater.is_combined() ?
|
||||||
std::abs( MoverParameters->enrot ) * 60.f * 0.01f :
|
std::abs( MoverParameters->enrot ) * 60.f * 0.01f :
|
||||||
1.f )
|
1.f )
|
||||||
.play( sound_flags::exclusive | sound_flags::looping );
|
.play( sound_flags::exclusive | sound_flags::looping );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sHeater.stop();
|
sHeater.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// battery sound
|
// battery sound
|
||||||
@@ -4338,6 +4341,11 @@ void TDynamicObject::RenderSounds() {
|
|||||||
m_pasystem.announcement = m_pasystem.announcement_queue.front();
|
m_pasystem.announcement = m_pasystem.announcement_queue.front();
|
||||||
m_pasystem.announcement.owner( this );
|
m_pasystem.announcement.owner( this );
|
||||||
m_pasystem.announcement.range( 0.5 * MoverParameters->Dim.L * -1 );
|
m_pasystem.announcement.range( 0.5 * MoverParameters->Dim.L * -1 );
|
||||||
|
if( m_pasystem.soundproofing ) {
|
||||||
|
if( !m_pasystem.announcement.soundproofing() ) {
|
||||||
|
m_pasystem.announcement.soundproofing() = m_pasystem.soundproofing;
|
||||||
|
}
|
||||||
|
}
|
||||||
m_pasystem.announcement.play();
|
m_pasystem.announcement.play();
|
||||||
m_pasystem.announcement_queue.pop_front();
|
m_pasystem.announcement_queue.pop_front();
|
||||||
}
|
}
|
||||||
@@ -5958,7 +5966,6 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
// announcement sounds
|
// announcement sounds
|
||||||
// content provided as "key: value" pairs together enclosed in "{}"
|
// content provided as "key: value" pairs together enclosed in "{}"
|
||||||
// value can be optionally set of values enclosed in "[]" in which case one value will be picked randomly
|
// value can be optionally set of values enclosed in "[]" in which case one value will be picked randomly
|
||||||
std::array<sound_source, static_cast<int>( announcement_t::end )> announcementsounds;
|
|
||||||
std::unordered_map<std::string, announcement_t> const announcements = {
|
std::unordered_map<std::string, announcement_t> const announcements = {
|
||||||
{ "near_stop:", announcement_t::approaching },
|
{ "near_stop:", announcement_t::approaching },
|
||||||
{ "stop:", announcement_t::current },
|
{ "stop:", announcement_t::current },
|
||||||
@@ -5968,23 +5975,50 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
while( ( ( token = parser.getToken<std::string>() ) != "" )
|
while( ( ( token = parser.getToken<std::string>() ) != "" )
|
||||||
&& ( token != "}" ) ) {
|
&& ( token != "}" ) ) {
|
||||||
if( token.back() == ':' ) {
|
if( token.back() == ':' ) {
|
||||||
|
|
||||||
|
if( token == "soundproofing:" ) {
|
||||||
|
// custom soundproofing in format [ p1, p2, p3, p4, p5, p6 ]
|
||||||
|
parser.getTokens( 6, false, "\n\r\t ,;[]" );
|
||||||
|
std::array<float, 6> soundproofing;
|
||||||
|
parser
|
||||||
|
>> soundproofing[ 0 ]
|
||||||
|
>> soundproofing[ 1 ]
|
||||||
|
>> soundproofing[ 2 ]
|
||||||
|
>> soundproofing[ 3 ]
|
||||||
|
>> soundproofing[ 4 ]
|
||||||
|
>> soundproofing[ 5 ];
|
||||||
|
m_pasystem.soundproofing = soundproofing;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto const lookup { announcements.find( token ) };
|
auto const lookup { announcements.find( token ) };
|
||||||
auto const announcementtype { (
|
auto const announcementtype { (
|
||||||
lookup != announcements.end() ?
|
lookup != announcements.end() ?
|
||||||
lookup->second :
|
lookup->second :
|
||||||
announcement_t::idle ) };
|
announcement_t::idle ) };
|
||||||
// NOTE: we retrieve key value for all keys, not just recognized ones
|
// NOTE: we retrieve key value for all keys, not just recognized ones
|
||||||
auto announcementsound{ deserialize_random_set( parser ) };
|
|
||||||
replace_slashes( announcementsound );
|
|
||||||
if( announcementtype == announcement_t::idle ) {
|
if( announcementtype == announcement_t::idle ) {
|
||||||
|
token = parser.getToken<std::string>();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
auto announcementsound { deserialize_random_set( parser ) };
|
||||||
|
replace_slashes( announcementsound );
|
||||||
|
*/
|
||||||
sound_source soundtemplate { sound_placement::engine }; // NOTE: sound range gets filled by pa system
|
sound_source soundtemplate { sound_placement::engine }; // NOTE: sound range gets filled by pa system
|
||||||
soundtemplate.deserialize( announcementsound, sound_type::single );
|
soundtemplate.deserialize( parser, sound_type::single );
|
||||||
soundtemplate.owner( this );
|
soundtemplate.owner( this );
|
||||||
m_pasystem.announcements[ static_cast<int>( announcementtype ) ] = soundtemplate;
|
m_pasystem.announcements[ static_cast<int>( announcementtype ) ] = soundtemplate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// set provided custom soundproofing to assigned sounds (for sounds without their own custom soundproofing)
|
||||||
|
if( m_pasystem.soundproofing ) {
|
||||||
|
for( auto &announcement : m_pasystem.announcements ) {
|
||||||
|
if( !announcement.soundproofing() ) {
|
||||||
|
announcement.soundproofing() = m_pasystem.soundproofing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while( ( token != "" )
|
} while( ( token != "" )
|
||||||
|
|||||||
1
DynObj.h
1
DynObj.h
@@ -417,6 +417,7 @@ private:
|
|||||||
// single source per vehicle
|
// single source per vehicle
|
||||||
struct pasystem_sounds {
|
struct pasystem_sounds {
|
||||||
std::array<sound_source, static_cast<int>( announcement_t::end )> announcements;
|
std::array<sound_source, static_cast<int>( announcement_t::end )> announcements;
|
||||||
|
std::optional< std::array<float, 6> > soundproofing;
|
||||||
sound_source announcement;
|
sound_source announcement;
|
||||||
std::deque<sound_source> announcement_queue; // fifo queue
|
std::deque<sound_source> announcement_queue; // fifo queue
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -938,7 +938,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 ( ( mvControlling->Sand == 0 ) || ( mvControlling->SandDose == true ) ); } );
|
return ( ( mvControlling->Sand == 0 ) || ( mvControlling->SandDose == true ) || ( mvControlling->SlippingWheels == false ) ); } );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case locale::string::driver_hint_sandingoff: {
|
case locale::string::driver_hint_sandingoff: {
|
||||||
|
|||||||
Reference in New Issue
Block a user