mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-04 21:16:59 +01:00
refactor(sonar): use structured bindings for pair access (cpp:S6005)
This commit is contained in:
@@ -624,11 +624,11 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
|
|||||||
std::vector<std::pair<coupling, sound>> const soundmappings = {{coupling::coupler, sound::attachcoupler}, {coupling::brakehose, sound::attachbrakehose},
|
std::vector<std::pair<coupling, sound>> const soundmappings = {{coupling::coupler, sound::attachcoupler}, {coupling::brakehose, sound::attachbrakehose},
|
||||||
{coupling::mainhose, sound::attachmainhose}, {coupling::control, sound::attachcontrol},
|
{coupling::mainhose, sound::attachmainhose}, {coupling::control, sound::attachcontrol},
|
||||||
{coupling::gangway, sound::attachgangway}, {coupling::heating, sound::attachheating}};
|
{coupling::gangway, sound::attachgangway}, {coupling::heating, sound::attachheating}};
|
||||||
for (auto const &soundmapping : soundmappings)
|
for (auto const &[mappingcoupling, mappingsound] : soundmappings)
|
||||||
{
|
{
|
||||||
if ((couplingchange & soundmapping.first) != 0)
|
if ((couplingchange & mappingcoupling) != 0)
|
||||||
{
|
{
|
||||||
soundflag |= soundmapping.second;
|
soundflag |= mappingsound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetFlag(coupler.sounds, soundflag);
|
SetFlag(coupler.sounds, soundflag);
|
||||||
@@ -685,11 +685,11 @@ bool TMoverParameters::Dettach(int ConnectNo)
|
|||||||
std::vector<std::pair<coupling, sound>> const soundmappings = {{coupling::coupler, sound::attachcoupler}, {coupling::brakehose, sound::attachbrakehose},
|
std::vector<std::pair<coupling, sound>> const soundmappings = {{coupling::coupler, sound::attachcoupler}, {coupling::brakehose, sound::attachbrakehose},
|
||||||
{coupling::mainhose, sound::attachmainhose}, {coupling::control, sound::attachcontrol},
|
{coupling::mainhose, sound::attachmainhose}, {coupling::control, sound::attachcontrol},
|
||||||
{coupling::gangway, sound::attachgangway}, {coupling::heating, sound::attachheating}};
|
{coupling::gangway, sound::attachgangway}, {coupling::heating, sound::attachheating}};
|
||||||
for (auto const &soundmapping : soundmappings)
|
for (auto const &[mappingcoupling, mappingsound] : soundmappings)
|
||||||
{
|
{
|
||||||
if ((couplingchange & soundmapping.first) != 0)
|
if ((couplingchange & mappingcoupling) != 0)
|
||||||
{
|
{
|
||||||
soundflag |= soundmapping.second;
|
soundflag |= mappingsound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetFlag(coupler.sounds, soundflag);
|
SetFlag(coupler.sounds, soundflag);
|
||||||
|
|||||||
@@ -1021,9 +1021,9 @@ debug_panel::update_vehicle_brake() const {
|
|||||||
{ bdelay_R, "R" },
|
{ bdelay_R, "R" },
|
||||||
{ bdelay_M, "+Mg" } };
|
{ bdelay_M, "+Mg" } };
|
||||||
|
|
||||||
for( auto const &delay : delays ) {
|
for( auto const &[delayflag, delayname] : delays ) {
|
||||||
if( ( mover.BrakeDelayFlag & delay.first ) == delay.first ) {
|
if( ( mover.BrakeDelayFlag & delayflag ) == delayflag ) {
|
||||||
brakedelay += delay.second;
|
brakedelay += delayname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1086,8 +1086,8 @@ debug_panel::update_section_engine( std::vector<text_line> &Output ) const {
|
|||||||
{ "cdesi: ", mover.dizel_engagestate },
|
{ "cdesi: ", mover.dizel_engagestate },
|
||||||
{ "cdelt: ", mover.dizel_engagedeltaomega },
|
{ "cdelt: ", mover.dizel_engagedeltaomega },
|
||||||
{ "gears: ", mover.dizel_automaticgearstatus} };
|
{ "gears: ", mover.dizel_automaticgearstatus} };
|
||||||
for( auto const ¶meter : paramvalues ) {
|
for( auto const &[parametername, parametervalue] : paramvalues ) {
|
||||||
parameterstext += "\n" + parameter.first + to_string( parameter.second, 2, 9 );
|
parameterstext += "\n" + parametername + to_string( parametervalue, 2, 9 );
|
||||||
}
|
}
|
||||||
Output.emplace_back( parameterstext, Global.UITextColor );
|
Output.emplace_back( parameterstext, Global.UITextColor );
|
||||||
|
|
||||||
@@ -1104,8 +1104,8 @@ debug_panel::update_section_engine( std::vector<text_line> &Output ) const {
|
|||||||
{ "hRtTq: ", mover.hydro_R_Torque }
|
{ "hRtTq: ", mover.hydro_R_Torque }
|
||||||
|
|
||||||
};
|
};
|
||||||
for( auto const ¶meter : hydrovalues ) {
|
for( auto const &[parametername, parametervalue] : hydrovalues ) {
|
||||||
parameterstext += "\n" + parameter.first + to_string( parameter.second, 2, 9 );
|
parameterstext += "\n" + parametername + to_string( parametervalue, 2, 9 );
|
||||||
}
|
}
|
||||||
Output.emplace_back( parameterstext, Global.UITextColor );
|
Output.emplace_back( parameterstext, Global.UITextColor );
|
||||||
}
|
}
|
||||||
@@ -1176,14 +1176,14 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) const {
|
|||||||
{ mover.RunningTrack.Velmax, "track" } };
|
{ mover.RunningTrack.Velmax, "track" } };
|
||||||
|
|
||||||
std::string restrictionstext;
|
std::string restrictionstext;
|
||||||
for( auto const &restriction : restrictions ) {
|
for( auto const &[restrictionspeed, restrictionsource] : restrictions ) {
|
||||||
if( restriction.first < 0.0 ) { continue; }
|
if( restrictionspeed < 0.0 ) { continue; }
|
||||||
if( false == restrictionstext.empty() ) {
|
if( false == restrictionstext.empty() ) {
|
||||||
restrictionstext += ", ";
|
restrictionstext += ", ";
|
||||||
}
|
}
|
||||||
restrictionstext +=
|
restrictionstext +=
|
||||||
to_string( restriction.first, 0 )
|
to_string( restrictionspeed, 0 )
|
||||||
+ " (" + restriction.second + ")";
|
+ " (" + restrictionsource + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
if( false == restrictionstext.empty() ) {
|
if( false == restrictionstext.empty() ) {
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ sound_source::deserialize( cParser &Input, sound_type const Legacytype, int cons
|
|||||||
m_soundchunks.back().second.fadeout = static_cast<float>(std::max( Chunkrange, m_soundchunks.back().second.threshold ));
|
m_soundchunks.back().second.fadeout = static_cast<float>(std::max( Chunkrange, m_soundchunks.back().second.threshold ));
|
||||||
// m_soundchunks.back().second.fadeout = m_soundchunks.back().second.threshold;
|
// m_soundchunks.back().second.fadeout = m_soundchunks.back().second.threshold;
|
||||||
// test if the chunk table contains any actual samples while at it
|
// test if the chunk table contains any actual samples while at it
|
||||||
for( auto &soundchunk : m_soundchunks ) {
|
for( auto &[chunkbuffer, chunkdata] : m_soundchunks ) {
|
||||||
if( soundchunk.first.buffer != null_handle ) {
|
if( chunkbuffer.buffer != null_handle ) {
|
||||||
m_soundchunksempty = false;
|
m_soundchunksempty = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -219,9 +219,9 @@ sound_source::deserialize_mapping( cParser &Input ) {
|
|||||||
if( indexstart != std::string::npos ) {
|
if( indexstart != std::string::npos ) {
|
||||||
auto const index { std::stoi( key.substr( indexstart, indexend - indexstart ) ) };
|
auto const index { std::stoi( key.substr( indexstart, indexend - indexstart ) ) };
|
||||||
auto const pitch { Input.getToken<float>( false, "\n\r\t ,;" ) };
|
auto const pitch { Input.getToken<float>( false, "\n\r\t ,;" ) };
|
||||||
for( auto &chunk : m_soundchunks ) {
|
for( auto &[chunkbuffer, chunkdata] : m_soundchunks ) {
|
||||||
if( chunk.second.threshold == index ) {
|
if( chunkdata.threshold == index ) {
|
||||||
chunk.second.pitch = pitch > 0.f ? pitch : 1.f;
|
chunkdata.pitch = pitch > 0.f ? pitch : 1.f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,8 +333,8 @@ sound_source::copy_sounds( sound_source const &Source ) {
|
|||||||
for( auto &sound : m_sounds ) {
|
for( auto &sound : m_sounds ) {
|
||||||
sound.playing = 0;
|
sound.playing = 0;
|
||||||
}
|
}
|
||||||
for( auto &sound : m_soundchunks ) {
|
for( auto &[chunkbuffer, chunkdata] : m_soundchunks ) {
|
||||||
sound.first.playing = 0;
|
chunkbuffer.playing = 0;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -418,14 +418,14 @@ sound_source::play_combined() {
|
|||||||
auto const soundpoint { compute_combined_point() };
|
auto const soundpoint { compute_combined_point() };
|
||||||
for( std::uint32_t idx = 0; idx < m_soundchunks.size(); ++idx ) {
|
for( std::uint32_t idx = 0; idx < m_soundchunks.size(); ++idx ) {
|
||||||
|
|
||||||
auto const &soundchunk { m_soundchunks[ idx ] };
|
auto const &[chunkbuffer, chunkdata]{ m_soundchunks[ idx ] };
|
||||||
// a chunk covers range from fade in point, where it starts rising in volume over crossfade distance,
|
// a chunk covers range from fade in point, where it starts rising in volume over crossfade distance,
|
||||||
// lasts until fadeout - crossfade distance point, past which it grows quiet until fade out point where it ends
|
// lasts until fadeout - crossfade distance point, past which it grows quiet until fade out point where it ends
|
||||||
if( soundpoint < soundchunk.second.fadein ) { break; }
|
if( soundpoint < chunkdata.fadein ) { break; }
|
||||||
if( soundpoint >= soundchunk.second.fadeout ) { continue; }
|
if( soundpoint >= chunkdata.fadeout ) { continue; }
|
||||||
|
|
||||||
if( soundchunk.first.buffer == null_handle || ( (m_flags & (sound_flags::exclusive | sound_flags::looping)) != 0
|
if( chunkbuffer.buffer == null_handle || ( (m_flags & (sound_flags::exclusive | sound_flags::looping)) != 0
|
||||||
&& soundchunk.first.playing > 0 ) ) {
|
&& chunkbuffer.playing > 0 ) ) {
|
||||||
// combined sounds only play looped, single copy of each activated chunk
|
// combined sounds only play looped, single copy of each activated chunk
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -669,9 +669,9 @@ sound_source::update_combined( audio::openal_source &Source ) {
|
|||||||
// for sound chunks, test whether the chunk should still be active given current value of the controlling variable
|
// for sound chunks, test whether the chunk should still be active given current value of the controlling variable
|
||||||
if( ( m_flags & ( sound_flags::exclusive | sound_flags::looping ) ) != 0 ) {
|
if( ( m_flags & ( sound_flags::exclusive | sound_flags::looping ) ) != 0 ) {
|
||||||
auto const soundpoint { compute_combined_point() };
|
auto const soundpoint { compute_combined_point() };
|
||||||
auto const &soundchunk { m_soundchunks[ soundhandle ^ sound_id::chunk ] };
|
auto const &[chunkbuffer, chunkdata]{ m_soundchunks[ soundhandle ^ sound_id::chunk ] };
|
||||||
if( soundpoint < soundchunk.second.fadein
|
if( soundpoint < chunkdata.fadein
|
||||||
|| soundpoint >= soundchunk.second.fadeout ) {
|
|| soundpoint >= chunkdata.fadeout ) {
|
||||||
Source.stop();
|
Source.stop();
|
||||||
update_counter( soundhandle, -1 );
|
update_counter( soundhandle, -1 );
|
||||||
return;
|
return;
|
||||||
@@ -867,8 +867,8 @@ sound_source::is_playing( bool const /*Includesoundends*/ ) const {
|
|||||||
if( false == isplaying
|
if( false == isplaying
|
||||||
&& false == m_soundchunks.empty() ) {
|
&& false == m_soundchunks.empty() ) {
|
||||||
// for emitters with sample tables check also if any of the chunks is active
|
// for emitters with sample tables check also if any of the chunks is active
|
||||||
for( auto const &soundchunk : m_soundchunks ) {
|
for( auto const &[chunkbuffer, chunkdata] : m_soundchunks ) {
|
||||||
if( soundchunk.first.playing > 0 ) {
|
if( chunkbuffer.playing > 0 ) {
|
||||||
isplaying = true;
|
isplaying = true;
|
||||||
break; // one will do
|
break; // one will do
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,11 +307,11 @@ gl::shader::shader(const std::string &filename)
|
|||||||
{
|
{
|
||||||
name = filename;
|
name = filename;
|
||||||
|
|
||||||
std::pair<GLuint, std::string> source = process_source(filename, "shaders/");
|
auto [shadertype, shadersource] = process_source(filename, "shaders/");
|
||||||
|
|
||||||
const GLchar *cstr = source.second.c_str();
|
const GLchar *cstr = shadersource.c_str();
|
||||||
|
|
||||||
**this = glCreateShader(source.first);
|
**this = glCreateShader(shadertype);
|
||||||
glShaderSource(*this, 1, &cstr, nullptr);
|
glShaderSource(*this, 1, &cstr, nullptr);
|
||||||
glCompileShader(*this);
|
glCompileShader(*this);
|
||||||
|
|
||||||
@@ -338,10 +338,10 @@ void gl::program::init()
|
|||||||
{
|
{
|
||||||
bind();
|
bind();
|
||||||
|
|
||||||
for (auto it : texture_conf)
|
for (auto [texturename, textureentry] : texture_conf)
|
||||||
{
|
{
|
||||||
shader::texture_entry &e = it.second;
|
shader::texture_entry &e = textureentry;
|
||||||
GLuint loc = glGetUniformLocation(*this, it.first.c_str());
|
GLuint loc = glGetUniformLocation(*this, texturename.c_str());
|
||||||
glUniform1i(loc, static_cast<GLint>(e.id));
|
glUniform1i(loc, static_cast<GLint>(e.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,10 +378,10 @@ gl::program::program(std::vector<std::reference_wrapper<const gl::shader>> shade
|
|||||||
|
|
||||||
void gl::program::attach(const gl::shader &s)
|
void gl::program::attach(const gl::shader &s)
|
||||||
{
|
{
|
||||||
for (auto it : s.texture_conf)
|
for (auto [texturename, textureentry] : s.texture_conf)
|
||||||
texture_conf.try_emplace(it.first, std::move(it.second));
|
texture_conf.try_emplace(texturename, std::move(textureentry));
|
||||||
for (auto it : s.param_conf)
|
for (auto [paramname, paramentry] : s.param_conf)
|
||||||
param_conf.try_emplace(it.first, std::move(it.second));
|
param_conf.try_emplace(paramname, std::move(paramentry));
|
||||||
glAttachShader(*this, *s);
|
glAttachShader(*this, *s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -796,12 +796,12 @@ std::unordered_map<std::string, user_command> commandMap = {
|
|||||||
void command_queue::update()
|
void command_queue::update()
|
||||||
{
|
{
|
||||||
double delta = Timer::GetDeltaTime();
|
double delta = Timer::GetDeltaTime();
|
||||||
for (auto c : m_active_continuous)
|
for (auto [activecommand, activerecipient] : m_active_continuous)
|
||||||
{
|
{
|
||||||
command_data data({c.first, GLFW_REPEAT, 0.0, 0.0, delta, false, glm::vec3()}); // todo: improve
|
command_data data({activecommand, GLFW_REPEAT, 0.0, 0.0, delta, false, glm::vec3()}); // todo: improve
|
||||||
auto lookup = m_commands.try_emplace( c.second, commanddata_sequence() );
|
auto [queueiterator, queueinserted] = m_commands.try_emplace( activerecipient, commanddata_sequence() );
|
||||||
// recipient stack was either located or created, so we can add to it quite safely
|
// recipient stack was either located or created, so we can add to it quite safely
|
||||||
lookup.first->second.emplace_back( data );
|
queueiterator->second.emplace_back( data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -809,8 +809,8 @@ void command_queue::update()
|
|||||||
void
|
void
|
||||||
command_queue::push( command_data const &Command, uint32_t const Recipient ) {
|
command_queue::push( command_data const &Command, uint32_t const Recipient ) {
|
||||||
if (is_network_target(Recipient)) {
|
if (is_network_target(Recipient)) {
|
||||||
auto lookup = m_intercept_queue.try_emplace(Recipient, commanddata_sequence());
|
auto [queueiterator, queueinserted] = m_intercept_queue.try_emplace(Recipient, commanddata_sequence());
|
||||||
lookup.first->second.emplace_back(Command);
|
queueiterator->second.emplace_back(Command);
|
||||||
} else {
|
} else {
|
||||||
push_direct(Command, Recipient);
|
push_direct(Command, Recipient);
|
||||||
}
|
}
|
||||||
@@ -827,9 +827,9 @@ void command_queue::push_direct(const command_data &Command, const uint32_t Reci
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lookup = m_commands.try_emplace( Recipient, commanddata_sequence() );
|
auto [queueiterator, queueinserted] = m_commands.try_emplace( Recipient, commanddata_sequence() );
|
||||||
// recipient stack was either located or created, so we can add to it quite safely
|
// recipient stack was either located or created, so we can add to it quite safely
|
||||||
lookup.first->second.emplace_back( Command );
|
queueiterator->second.emplace_back( Command );
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieves oldest posted command for specified recipient, if any. returns: true on retrieval, false if there's nothing to retrieve
|
// retrieves oldest posted command for specified recipient, if any. returns: true on retrieval, false if there's nothing to retrieve
|
||||||
@@ -868,9 +868,9 @@ command_queue::commands_map command_queue::pop_intercept_queue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void command_queue::push_commands(const commands_map &commands) {
|
void command_queue::push_commands(const commands_map &commands) {
|
||||||
for (auto const &kv : commands)
|
for (auto const &[recipient, sequence] : commands)
|
||||||
for (command_data const &data : kv.second)
|
for (command_data const &data : sequence)
|
||||||
push_direct(data, kv.first);
|
push_direct(data, recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -367,9 +367,9 @@ drivermouse_input::button( int const Button, int const Action ) {
|
|||||||
control->screen_touch_list->emplace_back(pos);
|
control->screen_touch_list->emplace_back(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const controlbindings { bindings( simulation::Train->GetLabel( control ) ) };
|
auto const [leftbinding, rightbinding]{ bindings( simulation::Train->GetLabel( control ) ) };
|
||||||
// if the recognized element under the cursor has a command associated with the pressed button, notify the recipient
|
// if the recognized element under the cursor has a command associated with the pressed button, notify the recipient
|
||||||
mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? controlbindings.first : controlbindings.second;
|
mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? leftbinding : rightbinding;
|
||||||
|
|
||||||
if( mousecommand == user_command::none ) {
|
if( mousecommand == user_command::none ) {
|
||||||
// if we don't have any recognized element under the cursor and the right button was pressed, enter view panning mode
|
// if we don't have any recognized element under the cursor and the right button was pressed, enter view panning mode
|
||||||
|
|||||||
@@ -189,16 +189,16 @@ gamepad_input::recall_bindings() {
|
|||||||
|
|
||||||
std::string bindingpoint {};
|
std::string bindingpoint {};
|
||||||
entryparser >> bindingpoint;
|
entryparser >> bindingpoint;
|
||||||
auto const splitbindingpoint { split_string_and_number( bindingpoint ) };
|
auto const [bindingtype, bindingindex]{ split_string_and_number( bindingpoint ) };
|
||||||
|
|
||||||
if( splitbindingpoint.first == "axis" ) {
|
if( bindingtype == "axis" ) {
|
||||||
// one or more sets of: [modeIDX] input type, parameters
|
// one or more sets of: [modeIDX] input type, parameters
|
||||||
// [optional] modeIDX associates the set with control mode IDX
|
// [optional] modeIDX associates the set with control mode IDX
|
||||||
// input types:
|
// input types:
|
||||||
// -- range commandname IDX; axis value is passed as paramIDX of commandname
|
// -- range commandname IDX; axis value is passed as paramIDX of commandname
|
||||||
// -- 3state commandname commandname; positive axis value issues first commandname, negative value issues second commandname
|
// -- 3state commandname commandname; positive axis value issues first commandname, negative value issues second commandname
|
||||||
|
|
||||||
auto const axisindex { splitbindingpoint.second };
|
auto const axisindex { bindingindex };
|
||||||
// sanity check, connected gamepad isn't guaranteed to have that many axes
|
// sanity check, connected gamepad isn't guaranteed to have that many axes
|
||||||
if( axisindex >= m_inputaxes.size() ) { continue; }
|
if( axisindex >= m_inputaxes.size() ) { continue; }
|
||||||
|
|
||||||
@@ -264,9 +264,9 @@ gamepad_input::recall_bindings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( splitbindingpoint.first == "button" ) {
|
else if( bindingtype == "button" ) {
|
||||||
|
|
||||||
auto const buttonindex { splitbindingpoint.second };
|
auto const buttonindex { bindingindex };
|
||||||
// sanity check, connected gamepad isn't guaranteed to have that many buttons
|
// sanity check, connected gamepad isn't guaranteed to have that many buttons
|
||||||
if( buttonindex >= m_inputbuttons.size() ) { continue; }
|
if( buttonindex >= m_inputbuttons.size() ) { continue; }
|
||||||
|
|
||||||
@@ -486,17 +486,17 @@ gamepad_input::process_axes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// issue remaining, assembled commands
|
// issue remaining, assembled commands
|
||||||
for( auto const &command : commands ) {
|
for( auto const &[commandid, commandparams] : commands ) {
|
||||||
auto const param1 { std::get<0>( command.second ) };
|
auto const param1 { std::get<0>( commandparams ) };
|
||||||
auto const param2 { std::get<1>( command.second ) };
|
auto const param2 { std::get<1>( commandparams ) };
|
||||||
auto &lastparams { m_lastcommandparams[ command.first ] };
|
auto &lastparams { m_lastcommandparams[ commandid ] };
|
||||||
if( param1 != 0.0 || std::get<0>(lastparams) != 0.0
|
if( param1 != 0.0 || std::get<0>(lastparams) != 0.0
|
||||||
|| param2 != 0.0 || std::get<1>(lastparams) != 0.0 ) {
|
|| param2 != 0.0 || std::get<1>(lastparams) != 0.0 ) {
|
||||||
m_relay.post(
|
m_relay.post(
|
||||||
command.first,
|
commandid,
|
||||||
param1,
|
param1,
|
||||||
param2,
|
param2,
|
||||||
std::get<2>( command.second ),
|
std::get<2>( commandparams ),
|
||||||
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
||||||
// TODO: pass correct entity id once the missing systems are in place
|
// TODO: pass correct entity id once the missing systems are in place
|
||||||
0 );
|
0 );
|
||||||
|
|||||||
@@ -330,9 +330,9 @@ void
|
|||||||
keyboard_input::bind() {
|
keyboard_input::bind() {
|
||||||
m_bindings.clear();
|
m_bindings.clear();
|
||||||
|
|
||||||
for( auto const &bindingsetup : m_bindingsetups ) {
|
for( auto const &[setupcommand, setupbinding] : m_bindingsetups ) {
|
||||||
|
|
||||||
m_bindings[ std::get<int>(bindingsetup.second) ] = bindingsetup.first;
|
m_bindings[ std::get<int>(setupbinding) ] = setupcommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
// cache movement key bindings
|
// cache movement key bindings
|
||||||
@@ -347,9 +347,9 @@ keyboard_input::bind() {
|
|||||||
int
|
int
|
||||||
keyboard_input::binding( user_command const Command ) const {
|
keyboard_input::binding( user_command const Command ) const {
|
||||||
|
|
||||||
for( auto const &binding : m_bindings ) {
|
for( auto const &[bindingkey, bindingcommand] : m_bindings ) {
|
||||||
if( binding.second == Command ) {
|
if( bindingcommand == Command ) {
|
||||||
return binding.first;
|
return bindingkey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ TModelsManager::GetModel(std::string const &Name, bool const Dynamic, bool const
|
|||||||
postfix = "^^" + std::to_string(uid);
|
postfix = "^^" + std::to_string(uid);
|
||||||
|
|
||||||
// see if we have it in the databank
|
// see if we have it in the databank
|
||||||
auto banklookup { find_in_databank( filename + postfix ) };
|
auto [banklookupfound, banklookupmodel]{ find_in_databank( filename + postfix ) };
|
||||||
TModel3d *model { banklookup.second };
|
TModel3d *model { banklookupmodel };
|
||||||
if( true == banklookup.first ) {
|
if( true == banklookupfound ) {
|
||||||
Global.asCurrentTexturePath = buftp;
|
Global.asCurrentTexturePath = buftp;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ network::manager::manager() = default;
|
|||||||
|
|
||||||
void network::manager::update()
|
void network::manager::update()
|
||||||
{
|
{
|
||||||
for (auto &backend : backend_list())
|
for (auto &[backendname, backendinstance] : backend_list())
|
||||||
backend.second->update();
|
backendinstance->update();
|
||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
client->update();
|
client->update();
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ void network::server_hello::deserialize(std::istream &stream)
|
|||||||
void ::network::request_command::serialize(std::ostream &stream) const
|
void ::network::request_command::serialize(std::ostream &stream) const
|
||||||
{
|
{
|
||||||
sn_utils::ls_uint32(stream, static_cast<uint32_t>(commands.size()));
|
sn_utils::ls_uint32(stream, static_cast<uint32_t>(commands.size()));
|
||||||
for (auto const &kv : commands)
|
for (auto const &[recipient, sequence] : commands)
|
||||||
{
|
{
|
||||||
sn_utils::ls_uint32(stream, kv.first);
|
sn_utils::ls_uint32(stream, recipient);
|
||||||
sn_utils::ls_uint32(stream, static_cast<uint32_t>(kv.second.size()));
|
sn_utils::ls_uint32(stream, static_cast<uint32_t>(sequence.size()));
|
||||||
for (command_data const &data : kv.second)
|
for (command_data const &data : sequence)
|
||||||
{
|
{
|
||||||
sn_utils::ls_uint32(stream, (uint32_t)data.command);
|
sn_utils::ls_uint32(stream, (uint32_t)data.command);
|
||||||
sn_utils::ls_int32(stream, data.action);
|
sn_utils::ls_int32(stream, data.action);
|
||||||
|
|||||||
@@ -49,15 +49,15 @@ opengl33_particles::update( opengl_camera const &Camera ) {
|
|||||||
// build billboard data for particles from visible sources
|
// build billboard data for particles from visible sources
|
||||||
auto const camerarotation { glm::mat3( Camera.modelview() ) };
|
auto const camerarotation { glm::mat3( Camera.modelview() ) };
|
||||||
particle_vertex vertex;
|
particle_vertex vertex;
|
||||||
for( auto const &source : sources ) {
|
for( auto const &[sourcekey, sourcedata] : sources ) {
|
||||||
|
|
||||||
auto const particlecolor {
|
auto const particlecolor {
|
||||||
glm::clamp(
|
glm::clamp(
|
||||||
source.second.color()
|
sourcedata.color()
|
||||||
* ( glm::vec3 { Global.DayLight.ambient }
|
* ( glm::vec3 { Global.DayLight.ambient }
|
||||||
+ 0.35f * glm::vec3{ Global.DayLight.diffuse } ) * simulation::Environment.light_intensity(),
|
+ 0.35f * glm::vec3{ Global.DayLight.diffuse } ) * simulation::Environment.light_intensity(),
|
||||||
glm::vec3{ 0.f }, glm::vec3{ 1.f } ) };
|
glm::vec3{ 0.f }, glm::vec3{ 1.f } ) };
|
||||||
auto const &particles { source.second.sequence() };
|
auto const &particles { sourcedata.sequence() };
|
||||||
// TODO: put sanity cap on the overall amount of particles that can be drawn
|
// TODO: put sanity cap on the overall amount of particles that can be drawn
|
||||||
auto const sizestep { 256.0 * billboard_vertices.size() };
|
auto const sizestep { 256.0 * billboard_vertices.size() };
|
||||||
m_particlevertices.reserve(
|
m_particlevertices.reserve(
|
||||||
@@ -72,9 +72,9 @@ opengl33_particles::update( opengl_camera const &Camera ) {
|
|||||||
auto const offset { glm::vec3{ particle.position - Camera.position() } };
|
auto const offset { glm::vec3{ particle.position - Camera.position() } };
|
||||||
auto const rotation { glm::angleAxis( particle.rotation, glm::vec3{ 0.f, 0.f, 1.f } ) };
|
auto const rotation { glm::angleAxis( particle.rotation, glm::vec3{ 0.f, 0.f, 1.f } ) };
|
||||||
|
|
||||||
for( auto const &billboardvertex : billboard_vertices ) {
|
for( auto const &[billboardoffset, billboardtexture] : billboard_vertices ) {
|
||||||
vertex.position = offset + ( rotation * billboardvertex.first * particle.size ) * camerarotation;
|
vertex.position = offset + ( rotation * billboardoffset * particle.size ) * camerarotation;
|
||||||
vertex.texture = billboardvertex.second;
|
vertex.texture = billboardtexture;
|
||||||
|
|
||||||
m_particlevertices.emplace_back( vertex );
|
m_particlevertices.emplace_back( vertex );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,15 +47,15 @@ opengl_particles::update( opengl_camera const &Camera ) {
|
|||||||
// build billboard data for particles from visible sources
|
// build billboard data for particles from visible sources
|
||||||
auto const camerarotation { glm::mat3( Camera.modelview() ) };
|
auto const camerarotation { glm::mat3( Camera.modelview() ) };
|
||||||
particle_vertex vertex;
|
particle_vertex vertex;
|
||||||
for( auto const &source : sources ) {
|
for( auto const &[sourcekey, sourcedata] : sources ) {
|
||||||
|
|
||||||
auto const particlecolor {
|
auto const particlecolor {
|
||||||
glm::clamp(
|
glm::clamp(
|
||||||
source.second.color()
|
sourcedata.color()
|
||||||
* ( glm::vec3 { Global.DayLight.ambient } + 0.35f * glm::vec3{ Global.DayLight.diffuse } )
|
* ( glm::vec3 { Global.DayLight.ambient } + 0.35f * glm::vec3{ Global.DayLight.diffuse } )
|
||||||
* 255.f,
|
* 255.f,
|
||||||
glm::vec3{ 0.f }, glm::vec3{ 255.f } ) };
|
glm::vec3{ 0.f }, glm::vec3{ 255.f } ) };
|
||||||
auto const &particles { source.second.sequence() };
|
auto const &particles { sourcedata.sequence() };
|
||||||
// TODO: put sanity cap on the overall amount of particles that can be drawn
|
// TODO: put sanity cap on the overall amount of particles that can be drawn
|
||||||
auto const sizestep { 256.0 * billboard_vertices.size() };
|
auto const sizestep { 256.0 * billboard_vertices.size() };
|
||||||
m_particlevertices.reserve(
|
m_particlevertices.reserve(
|
||||||
@@ -70,9 +70,9 @@ opengl_particles::update( opengl_camera const &Camera ) {
|
|||||||
auto const offset { glm::vec3{ particle.position - Camera.position() } };
|
auto const offset { glm::vec3{ particle.position - Camera.position() } };
|
||||||
auto const rotation { glm::angleAxis( particle.rotation, glm::vec3{ 0.f, 0.f, 1.f } ) };
|
auto const rotation { glm::angleAxis( particle.rotation, glm::vec3{ 0.f, 0.f, 1.f } ) };
|
||||||
|
|
||||||
for( auto const &billboardvertex : billboard_vertices ) {
|
for( auto const &[billboardoffset, billboardtexture] : billboard_vertices ) {
|
||||||
vertex.position = offset + ( rotation * billboardvertex.first * particle.size ) * camerarotation;
|
vertex.position = offset + ( rotation * billboardoffset * particle.size ) * camerarotation;
|
||||||
vertex.texture = billboardvertex.second;
|
vertex.texture = billboardtexture;
|
||||||
|
|
||||||
m_particlevertices.emplace_back( vertex );
|
m_particlevertices.emplace_back( vertex );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,36 +30,36 @@ void render_task::run()
|
|||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto const &datapair : m_input->floats)
|
for (auto const &[dataname, datavalue] : m_input->floats)
|
||||||
{
|
{
|
||||||
auto *value{PyGetFloat(datapair.second)};
|
auto *value{PyGetFloat(datavalue)};
|
||||||
if (value == nullptr)
|
if (value == nullptr)
|
||||||
{
|
{
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PyDict_SetItemString(input, datapair.first.c_str(), value);
|
PyDict_SetItemString(input, dataname.c_str(), value);
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
}
|
}
|
||||||
for (auto const &datapair : m_input->integers)
|
for (auto const &[dataname, datavalue] : m_input->integers)
|
||||||
{
|
{
|
||||||
auto *value{PyLong_FromLong(datapair.second)};
|
auto *value{PyLong_FromLong(datavalue)};
|
||||||
if (value == nullptr)
|
if (value == nullptr)
|
||||||
{
|
{
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PyDict_SetItemString(input, datapair.first.c_str(), value);
|
PyDict_SetItemString(input, dataname.c_str(), value);
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
}
|
}
|
||||||
for (auto const &datapair : m_input->bools)
|
for (auto const &[dataname, datavalue] : m_input->bools)
|
||||||
{
|
{
|
||||||
// Py_True / Py_False sa niesmiertelne, ale PyDict_SetItemString i tak
|
// Py_True / Py_False sa niesmiertelne, ale PyDict_SetItemString i tak
|
||||||
// pobiera wlasna referencje - nie zwalniamy
|
// pobiera wlasna referencje - nie zwalniamy
|
||||||
auto *value{PyGetBool(datapair.second)};
|
auto *value{PyGetBool(datavalue)};
|
||||||
PyDict_SetItemString(input, datapair.first.c_str(), value);
|
PyDict_SetItemString(input, dataname.c_str(), value);
|
||||||
}
|
}
|
||||||
for (auto const &datapair : m_input->strings)
|
for (auto const &[dataname, datavalue] : m_input->strings)
|
||||||
{
|
{
|
||||||
// Nazwy scenerii/wagonow (asName, SceneryFile, asCarName, cCode...) moga
|
// Nazwy scenerii/wagonow (asName, SceneryFile, asCarName, cCode...) moga
|
||||||
// byc albo w UTF-8, albo w starym kodowaniu Windows-1250. PyUnicode_FromString
|
// byc albo w UTF-8, albo w starym kodowaniu Windows-1250. PyUnicode_FromString
|
||||||
@@ -68,8 +68,8 @@ void render_task::run()
|
|||||||
//
|
//
|
||||||
// Strategia: najpierw probujemy UTF-8 (strict). Jesli sie nie uda - probujemy
|
// Strategia: najpierw probujemy UTF-8 (strict). Jesli sie nie uda - probujemy
|
||||||
// cp1250. Jesli oba zawioda - pomijamy klucz, ale nie wywracamy symulatora.
|
// cp1250. Jesli oba zawioda - pomijamy klucz, ale nie wywracamy symulatora.
|
||||||
char const *const str{datapair.second.c_str()};
|
char const *const str{datavalue.c_str()};
|
||||||
Py_ssize_t const len{static_cast<Py_ssize_t>(datapair.second.size())};
|
Py_ssize_t const len{static_cast<Py_ssize_t>(datavalue.size())};
|
||||||
|
|
||||||
auto *value{PyUnicode_DecodeUTF8(str, len, "strict")};
|
auto *value{PyUnicode_DecodeUTF8(str, len, "strict")};
|
||||||
if (value == nullptr)
|
if (value == nullptr)
|
||||||
@@ -82,16 +82,16 @@ void render_task::run()
|
|||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PyDict_SetItemString(input, datapair.first.c_str(), value);
|
PyDict_SetItemString(input, dataname.c_str(), value);
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
}
|
}
|
||||||
for (auto const &datapair : m_input->vec2_lists)
|
for (auto const &[dataname, datavalue] : m_input->vec2_lists)
|
||||||
{
|
{
|
||||||
PyObject *list = PyList_New(datapair.second.size());
|
PyObject *list = PyList_New(datavalue.size());
|
||||||
|
|
||||||
for (size_t i = 0; i < datapair.second.size(); i++)
|
for (size_t i = 0; i < datavalue.size(); i++)
|
||||||
{
|
{
|
||||||
auto const &vec = datapair.second[i];
|
auto const &vec = datavalue[i];
|
||||||
WriteLog("passing " + glm::to_string(vec));
|
WriteLog("passing " + glm::to_string(vec));
|
||||||
|
|
||||||
PyObject *tuple = PyTuple_New(2);
|
PyObject *tuple = PyTuple_New(2);
|
||||||
@@ -101,7 +101,7 @@ void render_task::run()
|
|||||||
PyList_SetItem(list, i, tuple); // steals ref
|
PyList_SetItem(list, i, tuple); // steals ref
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDict_SetItemString(input, datapair.first.c_str(), list);
|
PyDict_SetItemString(input, dataname.c_str(), list);
|
||||||
Py_DECREF(list);
|
Py_DECREF(list);
|
||||||
}
|
}
|
||||||
m_input = nullptr;
|
m_input = nullptr;
|
||||||
@@ -376,9 +376,9 @@ void python_taskqueue::exit()
|
|||||||
// reclaim cached python objects while the interpreter is still alive,
|
// reclaim cached python objects while the interpreter is still alive,
|
||||||
// so no Py_DECREF lands on a finalized interpreter during later teardown
|
// so no Py_DECREF lands on a finalized interpreter during later teardown
|
||||||
acquire_lock();
|
acquire_lock();
|
||||||
for (auto &entry : m_renderers)
|
for (auto &[renderername, rendererobject] : m_renderers)
|
||||||
{
|
{
|
||||||
Py_XDECREF(entry.second);
|
Py_XDECREF(rendererobject);
|
||||||
}
|
}
|
||||||
m_renderers.clear();
|
m_renderers.clear();
|
||||||
Py_XDECREF(m_stderr);
|
Py_XDECREF(m_stderr);
|
||||||
@@ -437,13 +437,13 @@ auto python_taskqueue::insert(task_request const &Task) -> bool
|
|||||||
auto python_taskqueue::run_file(std::string const &File, std::string const &Path) -> bool
|
auto python_taskqueue::run_file(std::string const &File, std::string const &Path) -> bool
|
||||||
{
|
{
|
||||||
|
|
||||||
auto const lookup{FileExists({Path + File, "python/local/" + File}, {".py"})};
|
auto const [filepath, fileextension]{FileExists({Path + File, "python/local/" + File}, {".py"})};
|
||||||
if (lookup.first.empty())
|
if (filepath.empty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream inputfile{lookup.first + lookup.second};
|
std::ifstream inputfile{filepath + fileextension};
|
||||||
std::string input;
|
std::string input;
|
||||||
input.assign(std::istreambuf_iterator<char>(inputfile), std::istreambuf_iterator<char>());
|
input.assign(std::istreambuf_iterator<char>(inputfile), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ basic_controller::deserialize_operation( cParser &Input ) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( false == operationparameter.empty() ) {
|
if( false == operationparameter.empty() ) {
|
||||||
auto const parameter{ split_string_and_number( operationparameter ) };
|
auto const [parametertype, parameterindex]{ split_string_and_number( operationparameter ) };
|
||||||
operation.parameter1 = static_cast<short>( parameter.second );
|
operation.parameter1 = static_cast<short>( parameterindex );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_program.emplace_back( operation );
|
m_program.emplace_back( operation );
|
||||||
@@ -380,12 +380,12 @@ basic_controller::log_error( std::string const &Error, int const Line ) const {
|
|||||||
auto
|
auto
|
||||||
basic_controller::guess_element_type_from_name( std::string const &Name ) const -> basic_element::type_e {
|
basic_controller::guess_element_type_from_name( std::string const &Name ) const -> basic_element::type_e {
|
||||||
|
|
||||||
auto const name { split_string_and_number( Name ) };
|
auto const [nametype, nameindex]{ split_string_and_number( Name ) };
|
||||||
|
|
||||||
if( name.first == "t" || name.first == "ton" || name.first.find("timer.") == 0 ) {
|
if( nametype == "t" || nametype == "ton" || nametype.find("timer.") == 0 ) {
|
||||||
return basic_element::type_e::timer;
|
return basic_element::type_e::timer;
|
||||||
}
|
}
|
||||||
if( name.first == "c" || name.first.find("counter.") == 0 ) {
|
if( nametype == "c" || nametype.find("counter.") == 0 ) {
|
||||||
return basic_element::type_e::counter;
|
return basic_element::type_e::counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ void TGauge::Init(TSubModel *Submodel, TSubModel *Submodelon, TGaugeAnimation Ty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for( auto &soundfx : m_soundfxvalues ) {
|
for( auto &[soundfxkey, soundfxsource] : m_soundfxvalues ) {
|
||||||
if( soundfx.second.offset() == nulloffset ) {
|
if( soundfxsource.offset() == nulloffset ) {
|
||||||
soundfx.second.offset( offset );
|
soundfxsource.offset( offset );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -166,9 +166,9 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu
|
|||||||
if( !m_soundfxoff.soundproofing() ) {
|
if( !m_soundfxoff.soundproofing() ) {
|
||||||
m_soundfxoff.soundproofing() = scratchpad.soundproofing;
|
m_soundfxoff.soundproofing() = scratchpad.soundproofing;
|
||||||
}
|
}
|
||||||
for( auto &soundfxrecord : m_soundfxvalues ) {
|
for( auto &[soundfxkey, soundfxsource] : m_soundfxvalues ) {
|
||||||
if( !soundfxrecord.second.soundproofing() ) {
|
if( !soundfxsource.soundproofing() ) {
|
||||||
soundfxrecord.second.soundproofing() = scratchpad.soundproofing;
|
soundfxsource.soundproofing() = scratchpad.soundproofing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,8 +180,8 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu
|
|||||||
m_soundfxdecrease.owner( Owner );
|
m_soundfxdecrease.owner( Owner );
|
||||||
m_soundfxon.owner( Owner );
|
m_soundfxon.owner( Owner );
|
||||||
m_soundfxoff.owner( Owner );
|
m_soundfxoff.owner( Owner );
|
||||||
for( auto &soundfxrecord : m_soundfxvalues ) {
|
for( auto &[soundfxkey, soundfxsource] : m_soundfxvalues ) {
|
||||||
soundfxrecord.second.owner( Owner );
|
soundfxsource.owner( Owner );
|
||||||
}
|
}
|
||||||
|
|
||||||
scale *= static_cast<float>(mul);
|
scale *= static_cast<float>(mul);
|
||||||
|
|||||||
@@ -10110,11 +10110,11 @@ void TTrain::update_sounds_radio()
|
|||||||
}
|
}
|
||||||
// adjust audibility of remaining messages based on current radio conditions
|
// adjust audibility of remaining messages based on current radio conditions
|
||||||
auto const radioenabled{true == mvOccupied->Radio && (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable)};
|
auto const radioenabled{true == mvOccupied->Radio && (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable)};
|
||||||
for (auto &message : m_radiomessages)
|
for (auto &[messagechannel, messagesound] : m_radiomessages)
|
||||||
{
|
{
|
||||||
auto const volume{true == radioenabled && Dynamic()->Mechanik != nullptr && message.first == RadioChannel() ? m_radiovolume : 0.0};
|
auto const volume{true == radioenabled && Dynamic()->Mechanik != nullptr && messagechannel == RadioChannel() ? m_radiovolume : 0.0};
|
||||||
message.second->gain(static_cast<float>(volume));
|
messagesound->gain(static_cast<float>(volume));
|
||||||
radio_message_played |= true == radioenabled && Dynamic()->Mechanik != nullptr && message.first == RadioChannel();
|
radio_message_played |= true == radioenabled && Dynamic()->Mechanik != nullptr && messagechannel == RadioChannel();
|
||||||
}
|
}
|
||||||
// radiostop
|
// radiostop
|
||||||
if (m_radiostop)
|
if (m_radiostop)
|
||||||
@@ -10229,9 +10229,9 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
|||||||
{"huntingnoise:", {rsHuntingNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}},
|
{"huntingnoise:", {rsHuntingNoise, sound_placement::internal, EU07_SOUND_GLOBALRANGE, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}},
|
||||||
{"rainsound:", {m_rainsound, sound_placement::internal, -1, sound_type::single, 0, 100.0}},
|
{"rainsound:", {m_rainsound, sound_placement::internal, -1, sound_type::single, 0, 100.0}},
|
||||||
};
|
};
|
||||||
for (auto &soundconfig : internalsounds)
|
for (auto &[soundname, soundsource] : internalsounds)
|
||||||
{
|
{
|
||||||
std::get<std::optional<sound_source> &>(soundconfig.second).reset();
|
std::get<std::optional<sound_source> &>(soundsource).reset();
|
||||||
}
|
}
|
||||||
// NOTE: since radiosound is an incomplete template not using std::optional it gets a special treatment
|
// NOTE: since radiosound is an incomplete template not using std::optional it gets a special treatment
|
||||||
m_radiosound.owner(DynamicObject);
|
m_radiosound.owner(DynamicObject);
|
||||||
@@ -10343,11 +10343,11 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_radiosound.offset(nullvector);
|
m_radiosound.offset(nullvector);
|
||||||
for (auto &sound : CabSoundLocations)
|
for (auto &[soundsource, soundoffset] : CabSoundLocations)
|
||||||
{
|
{
|
||||||
if (sound.first.get() && sound.first.get()->offset() == nullvector)
|
if (soundsource.get() && soundsource.get()->offset() == nullvector)
|
||||||
{
|
{
|
||||||
sound.first.get()->offset(sound.second);
|
soundsource.get()->offset(soundoffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// reset view angles
|
// reset view angles
|
||||||
@@ -10636,19 +10636,19 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
{m_rainsound, caboffset},
|
{m_rainsound, caboffset},
|
||||||
{m_radiostop, m_radiosound.offset()},
|
{m_radiostop, m_radiosound.offset()},
|
||||||
};
|
};
|
||||||
for (auto &sound : soundlocations)
|
for (auto &[soundsource, soundoffset] : soundlocations)
|
||||||
{
|
{
|
||||||
if (sound.first.get() && sound.first.get()->offset() == nullvector)
|
if (soundsource.get() && soundsource.get()->offset() == nullvector)
|
||||||
{
|
{
|
||||||
sound.first.get()->offset(sound.second);
|
soundsource.get()->offset(soundoffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// second pass, in case some items received no positioning due to missing submodels etc
|
// second pass, in case some items received no positioning due to missing submodels etc
|
||||||
for (auto &sound : soundlocations)
|
for (auto &[soundsource, soundoffset] : soundlocations)
|
||||||
{
|
{
|
||||||
if (sound.first.get() && sound.first.get()->offset() == nullvector)
|
if (soundsource.get() && soundsource.get()->offset() == nullvector)
|
||||||
{
|
{
|
||||||
sound.first.get()->offset(caboffset);
|
soundsource.get()->offset(caboffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -489,10 +489,10 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
|||||||
if( entry.front() != 'R' ) {
|
if( entry.front() != 'R' ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto const entrysplit { split_string_and_number( entry ) };
|
auto const [entrytype, entrynumber]{ split_string_and_number( entry ) };
|
||||||
if( entrysplit.first == "R"
|
if( entrytype == "R"
|
||||||
&& entrysplit.second <= 10 ) {
|
&& entrynumber <= 10 ) {
|
||||||
auto const radiochannel { entrysplit.second };
|
auto const radiochannel { entrynumber };
|
||||||
if( record->radio_channel == -1
|
if( record->radio_channel == -1
|
||||||
|| radiochannel != activeradiochannel ) {
|
|| radiochannel != activeradiochannel ) {
|
||||||
// if the station has more than one radiochannel listed,
|
// if the station has more than one radiochannel listed,
|
||||||
@@ -610,17 +610,17 @@ TTrainParameters::load_sounds() {
|
|||||||
station.StationName.substr( 0, station.StationName.size() - 3 ) :
|
station.StationName.substr( 0, station.StationName.size() - 3 ) :
|
||||||
station.StationName ) };
|
station.StationName ) };
|
||||||
|
|
||||||
auto const lookup {
|
auto const [filepath, fileextension]{
|
||||||
FileExists(
|
FileExists(
|
||||||
{ Global.asCurrentSceneryPath + stationname, std::string{ paths::sounds } + "sip/" + stationname },
|
{ Global.asCurrentSceneryPath + stationname, std::string{ paths::sounds } + "sip/" + stationname },
|
||||||
{ ".ogg", ".flac", ".wav" } ) };
|
{ ".ogg", ".flac", ".wav" } ) };
|
||||||
if( lookup.first.empty() ) {
|
if( filepath.empty() ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// wczytanie dźwięku odjazdu w wersji radiowej (słychać tylko w kabinie)
|
// wczytanie dźwięku odjazdu w wersji radiowej (słychać tylko w kabinie)
|
||||||
station.name_sound =
|
station.name_sound =
|
||||||
sound_source{ sound_placement::engine, EU07_SOUND_CABANNOUNCEMENTCUTOFFRANGE }
|
sound_source{ sound_placement::engine, EU07_SOUND_CABANNOUNCEMENTCUTOFFRANGE }
|
||||||
.deserialize( lookup.first + lookup.second, sound_type::single );
|
.deserialize( filepath + fileextension, sound_type::single );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user