16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 00:09:18 +02:00

Do not allow implicit cast for inline std::string to_string(bool Value) and change to_string to std::string for non boolean values

This commit is contained in:
docentYT
2026-05-03 15:49:29 +02:00
parent 1e8b3d554a
commit 13c7317f6e
11 changed files with 60 additions and 59 deletions

View File

@@ -421,11 +421,11 @@ timetable_panel::update() {
.substr( 0, 34 - tableline->StationWare.size() ) };
auto const arrival { (
tableline->Ah >= 0 ?
to_string( int( 100 + tableline->Ah ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Am, true, 3 ) :
std::to_string( int( 100 + tableline->Ah ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Am, true, 3 ) :
"" ) };
auto const departure { (
tableline->Dh >= 0 ?
to_string( int( 100 + tableline->Dh ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Dm, true, 3 ) :
std::to_string( int( 100 + tableline->Dh ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Dm, true, 3 ) :
"" ) };
auto const candepart { (
( table.StationStart < table.StationIndex )
@@ -721,9 +721,9 @@ debug_panel::render_section_scenario() {
ImGui::PopStyleColor();
auto time = simulation::Time.data().wHour * 60 + simulation::Time.data().wMinute;
auto const timestring {
std::string( to_string( int( 100 + simulation::Time.data().wHour ) ).substr( 1, 2 )
std::string( std::to_string( int( 100 + simulation::Time.data().wHour ) ).substr( 1, 2 )
+ ":"
+ std::string( to_string( int( 100 + simulation::Time.data().wMinute ) ).substr( 1, 2 ) ) ) };
+ std::string( std::to_string( int( 100 + simulation::Time.data().wMinute ) ).substr( 1, 2 ) ) ) };
if( ImGui::SliderInt( ( timestring + " (" + Global.Period + ")###simulationtime" ).c_str(), &time, 0, 1439, "Time of day" ) ) {
command_relay relay;
relay.post(
@@ -1210,8 +1210,8 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) {
+ ", corrected: " + to_string( mechanik.AccDesired * mechanik.BrakeAccFactor(), 2 )
+ "\n current: " + to_string( mechanik.AbsAccS + 0.001f, 2 )
+ ", slope: " + to_string( mechanik.fAccGravity + 0.001f, 2 ) + " (" + ( mechanik.fAccGravity > 0.01 ? "\\" : ( mechanik.fAccGravity < -0.01 ? "/" : "-" ) ) + ")"
+ "\n desired diesel percentage: " + to_string(mechanik.DizelPercentage)
+ "/" + to_string(mechanik.DizelPercentage_Speed)
+ "\n desired diesel percentage: " + std::to_string(mechanik.DizelPercentage)
+ "/" + std::to_string(mechanik.DizelPercentage_Speed)
+ "/" + to_string(100.4*mechanik.mvControlling->eimic_real, 0);
Output.emplace_back( textline, Global.UITextColor );
@@ -1222,7 +1222,7 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) {
+ "\n activation threshold: " + to_string( mechanik.fAccThreshold, 2 )
+ ", delays: " + to_string( mechanik.fBrake_a0[ 0 ], 2 ) + " + " + to_string( mechanik.fBrake_a1[ 0 ], 2 )
+ "\n virtual brake position: " + to_string( mechanik.BrakeCtrlPosition, 2 )
+ "\n test stage: " + to_string( mechanik.DynamicBrakeTest )
+ "\n test stage: " + std::to_string( mechanik.DynamicBrakeTest )
+ ", applied at: " + to_string( mechanik.DBT_VelocityBrake, 0 )
+ ", release at: " + to_string( mechanik.DBT_VelocityRelease, 0 )
+ ", done at: " + to_string( mechanik.DBT_VelocityFinish, 0 );
@@ -1393,7 +1393,7 @@ debug_panel::update_section_powergrid( std::vector<text_line> &Output ) {
+ " " + to_string( powerstation->FuseTimer, 1, 8 )
+ ( powerstation->FuseCounter == 0 ?
"" :
" (x" + to_string( powerstation->FuseCounter ) + ")" );
" (x" + std::to_string( powerstation->FuseCounter ) + ")" );
Output.emplace_back(
textline,
@@ -1445,7 +1445,7 @@ debug_panel::update_section_renderer( std::vector<text_line> &Output ) {
+ ", FPS: " + std::to_string( static_cast<int>(std::round(GfxRenderer->Framerate())) )
+ ( Global.VSync ? " (vsync on)" : "" );
if( Global.iSlowMotion ) {
textline += " (slowmotion " + to_string( Global.iSlowMotion ) + ")";
textline += " (slowmotion " + std::to_string( Global.iSlowMotion ) + ")";
}
Output.emplace_back( textline, Global.UITextColor );
@@ -1548,8 +1548,8 @@ debug_panel::render_section_settings() {
ImGui::TextUnformatted( "Graphics" );
ImGui::PopStyleColor();
// reflection fidelity
ImGui::SliderInt( ( to_string( Global.reflectiontune.fidelity ) + "###reflectionfidelity" ).c_str(), &Global.reflectiontune.fidelity, 0, 2, "Reflection fidelity" );
ImGui::SliderInt( ( to_string( Global.gfx_shadow_rank_cutoff ) + "###shadowrankcutoff" ).c_str(), &Global.gfx_shadow_rank_cutoff, 1, 3, "Shadow ranks" );
ImGui::SliderInt( ( std::to_string( Global.reflectiontune.fidelity ) + "###reflectionfidelity" ).c_str(), &Global.reflectiontune.fidelity, 0, 2, "Reflection fidelity" );
ImGui::SliderInt( ( std::to_string( Global.gfx_shadow_rank_cutoff ) + "###shadowrankcutoff" ).c_str(), &Global.gfx_shadow_rank_cutoff, 1, 3, "Shadow ranks" );
if( ImGui::SliderFloat( ( to_string( std::abs( Global.gfx_shadow_angle_min ), 2 ) + "###shadowanglecutoff" ).c_str(), &Global.gfx_shadow_angle_min, -1.0, -0.2, "Shadow angle cutoff" ) ) {
Global.gfx_shadow_angle_min = quantize( Global.gfx_shadow_angle_min, 0.05f );
};
@@ -1569,19 +1569,19 @@ debug_panel::render_section_settings() {
ImGui::TextUnformatted( "Sound" );
ImGui::PopStyleColor();
// audio volume sliders
ImGui::SliderFloat( ( to_string( static_cast<int>( Global.AudioVolume * 100 ) ) + "%###volumemain" ).c_str(), &Global.AudioVolume, 0.0f, 2.0f, "Main audio volume" );
if( ImGui::SliderFloat( ( to_string( static_cast<int>( Global.VehicleVolume * 100 ) ) + "%###volumevehicle" ).c_str(), &Global.VehicleVolume, 0.0f, 1.0f, "Vehicle sounds" ) ) {
ImGui::SliderFloat( ( std::to_string( static_cast<int>( Global.AudioVolume * 100 ) ) + "%###volumemain" ).c_str(), &Global.AudioVolume, 0.0f, 2.0f, "Main audio volume" );
if( ImGui::SliderFloat( ( std::to_string( static_cast<int>( Global.VehicleVolume * 100 ) ) + "%###volumevehicle" ).c_str(), &Global.VehicleVolume, 0.0f, 1.0f, "Vehicle sounds" ) ) {
audio::event_volume_change = true;
}
if( ImGui::SliderFloat( ( to_string( static_cast<int>( Global.EnvironmentPositionalVolume * 100 ) ) + "%###volumepositional" ).c_str(), &Global.EnvironmentPositionalVolume, 0.0f, 1.0f, "Positional sounds" ) ) {
if( ImGui::SliderFloat( ( std::to_string( static_cast<int>( Global.EnvironmentPositionalVolume * 100 ) ) + "%###volumepositional" ).c_str(), &Global.EnvironmentPositionalVolume, 0.0f, 1.0f, "Positional sounds" ) ) {
audio::event_volume_change = true;
}
if( ImGui::SliderFloat( ( to_string( static_cast<int>( Global.EnvironmentAmbientVolume * 100 ) ) + "%###volumeambient" ).c_str(), &Global.EnvironmentAmbientVolume, 0.0f, 1.0f, "Ambient sounds" ) ) {
if( ImGui::SliderFloat( ( std::to_string( static_cast<int>( Global.EnvironmentAmbientVolume * 100 ) ) + "%###volumeambient" ).c_str(), &Global.EnvironmentAmbientVolume, 0.0f, 1.0f, "Ambient sounds" ) ) {
audio::event_volume_change = true;
}
if (simulation::Train) {
float val = simulation::Train->get_radiovolume();
if( ImGui::SliderFloat( ( to_string( static_cast<int>( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) {
if( ImGui::SliderFloat( ( std::to_string( static_cast<int>( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) {
command_relay relay;
relay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
}

View File

@@ -80,7 +80,7 @@ void itemproperties_panel::update(scene::basic_node const *Node)
textline += '[';
for (int lightidx = 0; lightidx < subnode->iNumLights; ++lightidx)
{
textline += to_string(subnode->lsLights[lightidx]);
textline += std::to_string(subnode->lsLights[lightidx]);
if (lightidx < subnode->iNumLights - 1)
{
textline += ", ";
@@ -125,8 +125,8 @@ void itemproperties_panel::update(scene::basic_node const *Node)
}
// basic attributes
textline = "isolated: " + (!isolatedlist.empty() ? isolatedlist : "(none)") + "\nvelocity: " + to_string(subnode->SwitchExtension ? subnode->SwitchExtension->fVelocity : subnode->fVelocity) +
"\nwidth: " + to_string(subnode->fTrackWidth) + " m" + "\nfriction: " + to_string(subnode->fFriction, 2) + "\nquality: " + to_string(subnode->iQualityFlag);
textline = "isolated: " + (!isolatedlist.empty() ? isolatedlist : "(none)") + "\nvelocity: " + std::to_string(subnode->SwitchExtension ? subnode->SwitchExtension->fVelocity : subnode->fVelocity) +
"\nwidth: " + std::to_string(subnode->fTrackWidth) + " m" + "\nfriction: " + to_string(subnode->fFriction, 2) + "\nquality: " + std::to_string(subnode->iQualityFlag);
text_lines.emplace_back(textline, Global.UITextColor);
// textures
auto texturefile{((subnode->m_material1 != null_handle) ? GfxRenderer->Material(subnode->m_material1)->GetName() : "(none)")};
@@ -256,7 +256,7 @@ void itemproperties_panel::update_group()
m_grouphandle = grouphandle;
}
m_grouplines.emplace_back("nodes: " + to_string(static_cast<int>(nodegroup.nodes.size())) + "\nevents: " + to_string(static_cast<int>(nodegroup.events.size())), Global.UITextColor);
m_grouplines.emplace_back("nodes: " + std::to_string(nodegroup.nodes.size()) + "\nevents: " + std::to_string(nodegroup.events.size()), Global.UITextColor);
m_grouplines.emplace_back("names prefix: " + (m_groupprefix.empty() ? "(none)" : m_groupprefix), Global.UITextColor);
}