From 13c7317f6e0803587dc70ce62901512544907758 Mon Sep 17 00:00:00 2001 From: docentYT <63965954+docentYT@users.noreply.github.com> Date: Sun, 3 May 2026 15:49:29 +0200 Subject: [PATCH] Do not allow implicit cast for inline std::string to_string(bool Value) and change to_string to std::string for non boolean values --- McZapkie/Mover.cpp | 8 ++++---- application/driveruipanels.cpp | 32 ++++++++++++++++---------------- application/editoruipanels.cpp | 8 ++++---- input/messaging.cpp | 18 +++++++++--------- scripting/ladderlogic.cpp | 2 +- utilities/utilities.cpp | 2 +- utilities/utilities.h | 3 ++- vehicle/Driver.cpp | 4 ++-- vehicle/DynObj.cpp | 8 ++++---- world/EvLaunch.cpp | 6 +++--- world/Event.cpp | 28 ++++++++++++++-------------- 11 files changed, 60 insertions(+), 59 deletions(-) diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 89a16d91..a8abecc7 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -10122,7 +10122,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath) modernDimmerPosition = modernDimmerDefaultPosition; } - WriteLog("CERROR: " + to_string(ConversionError) + ", SUCCES: " + to_string(result)); + WriteLog("CERROR: " + std::to_string(ConversionError) + ", SUCCES: " + to_string(result)); return result; } @@ -10860,9 +10860,9 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line) void TMoverParameters::LoadFIZ_Blending(std::string const &line) { - extract_value(MED_Vmax, "MED_Vmax", line, to_string(Vmax)); + extract_value(MED_Vmax, "MED_Vmax", line, std::to_string(Vmax)); extract_value(MED_Vmin, "MED_Vmin", line, "0"); - extract_value(MED_Vref, "MED_Vref", line, to_string(Vmax)); + extract_value(MED_Vref, "MED_Vref", line, std::to_string(Vmax)); extract_value(MED_amax, "MED_amax", line, "9.81"); extract_value(MED_EPVC, "MED_EPVC", line, ""); extract_value(MED_Ncor, "MED_Ncor", line, ""); @@ -11160,7 +11160,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input) extract_value(eimc[eimc_f_DU], "DU", Input, ""); extract_value(eimc[eimc_f_I0], "I0", Input, ""); extract_value(eimc[eimc_f_cfu], "fcfu", Input, ""); - extract_value(eimc[eimc_f_cfuH], "fcfuH", Input, to_string(eimc[eimc_f_cfu])); + extract_value(eimc[eimc_f_cfuH], "fcfuH", Input, std::to_string(eimc[eimc_f_cfu])); extract_value(eimc[eimc_p_F0], "F0", Input, ""); extract_value(eimc[eimc_p_a1], "a1", Input, ""); extract_value(eimc[eimc_p_Pmax], "Pmax", Input, ""); diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 538ce8f7..10c25861 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -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 &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 &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 &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 &Output ) { + ", FPS: " + std::to_string( static_cast(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( Global.AudioVolume * 100 ) ) + "%###volumemain" ).c_str(), &Global.AudioVolume, 0.0f, 2.0f, "Main audio volume" ); - if( ImGui::SliderFloat( ( to_string( static_cast( Global.VehicleVolume * 100 ) ) + "%###volumevehicle" ).c_str(), &Global.VehicleVolume, 0.0f, 1.0f, "Vehicle sounds" ) ) { + ImGui::SliderFloat( ( std::to_string( static_cast( Global.AudioVolume * 100 ) ) + "%###volumemain" ).c_str(), &Global.AudioVolume, 0.0f, 2.0f, "Main audio volume" ); + if( ImGui::SliderFloat( ( std::to_string( static_cast( 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( Global.EnvironmentPositionalVolume * 100 ) ) + "%###volumepositional" ).c_str(), &Global.EnvironmentPositionalVolume, 0.0f, 1.0f, "Positional sounds" ) ) { + if( ImGui::SliderFloat( ( std::to_string( static_cast( 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( Global.EnvironmentAmbientVolume * 100 ) ) + "%###volumeambient" ).c_str(), &Global.EnvironmentAmbientVolume, 0.0f, 1.0f, "Ambient sounds" ) ) { + if( ImGui::SliderFloat( ( std::to_string( static_cast( 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( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) { + if( ImGui::SliderFloat( ( std::to_string( static_cast( 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); } diff --git a/application/editoruipanels.cpp b/application/editoruipanels.cpp index e2de630c..25028a8d 100644 --- a/application/editoruipanels.cpp +++ b/application/editoruipanels.cpp @@ -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(nodegroup.nodes.size())) + "\nevents: " + to_string(static_cast(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); } diff --git a/input/messaging.cpp b/input/messaging.cpp index 23f4dbb1..b3c48f40 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -80,7 +80,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) { int i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty) CommLog( - Now() + " " + to_string(pRozkaz->iComm) + " " + + Now() + " " + std::to_string(pRozkaz->iComm) + " " + std::string(pRozkaz->cString + 11 + i, (unsigned)(pRozkaz->cString[10 + i])) + " rcvd"); // nazwa pojazdu jest druga @@ -98,7 +98,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) break; case 4: // badanie zajętości toru { - CommLog(Now() + " " + to_string(pRozkaz->iComm) + " " + + CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " " + std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); auto *track = simulation::Paths.find( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) ); @@ -110,7 +110,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) break; case 5: // ustawienie parametrów { - CommLog(Now() + " " + to_string(pRozkaz->iComm) + " params " + to_string(*pRozkaz->iPar) + " rcvd"); + CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " params " + std::to_string(*pRozkaz->iPar) + " rcvd"); if (*pRozkaz->iPar == 0) // sprawdzenie czasu if (*pRozkaz->iPar & 1) // ustawienie czasu { @@ -133,7 +133,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) // Ra 2014-12: to ma działać również dla pojazdów bez obsady CommLog( Now() + " " - + to_string( pRozkaz->iComm ) + " " + + std::to_string( pRozkaz->iComm ) + " " + std::string{ pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) } + " rcvd" ); if (pRozkaz->cString[0]) { @@ -153,15 +153,15 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) } break; case 8: // ponowne wysłanie informacji o zajętych odcinkach toru - CommLog(Now() + " " + to_string(pRozkaz->iComm) + " all busy track" + " rcvd"); + CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " all busy track" + " rcvd"); simulation::Paths.TrackBusyList(); break; case 9: // ponowne wysłanie informacji o zajętych odcinkach izolowanych - CommLog(Now() + " " + to_string(pRozkaz->iComm) + " all busy isolated" + " rcvd"); + CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " all busy isolated" + " rcvd"); simulation::Paths.IsolatedBusyList(); break; case 10: // badanie zajętości jednego odcinka izolowanego - CommLog(Now() + " " + to_string(pRozkaz->iComm) + " " + + CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " " + std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); simulation::Paths.IsolatedBusy( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) ); break; @@ -169,12 +169,12 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) // Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0]))); break; case 12: // skrocona ramka parametrow pojazdow AI (wszystkich!!) - CommLog(Now() + " " + to_string(pRozkaz->iComm) + " obsadzone" + " rcvd"); + CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " obsadzone" + " rcvd"); WyslijObsadzone(); // Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0]))); break; case 13: // ramka uszkodzenia i innych stanow pojazdu, np. wylaczenie CA, wlaczenie recznego itd. - CommLog(Now() + " " + to_string(pRozkaz->iComm) + " " + + CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " " + std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); if( pRozkaz->cString[ 1 ] ) // jeśli długość nazwy jest niezerowa diff --git a/scripting/ladderlogic.cpp b/scripting/ladderlogic.cpp index 56699818..37a209d0 100644 --- a/scripting/ladderlogic.cpp +++ b/scripting/ladderlogic.cpp @@ -378,7 +378,7 @@ basic_controller::log_error( std::string const &Error, int const Line ) const { "Bad plc program: \"" + m_programfilename + "\" " + Error + ( Line > 0 ? - " (line " + to_string( Line ) + ")" : + " (line " + std::to_string( Line ) + ")" : "" ) ); } diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp index 639292a9..46d74e07 100644 --- a/utilities/utilities.cpp +++ b/utilities/utilities.cpp @@ -212,7 +212,7 @@ std::string to_minutes_str(float const Minutes, bool const Leadingzero, int cons float minutesintegral; auto const minutesfractional{std::modf(Minutes, &minutesintegral)}; auto const width{Width - 1}; - auto minutes = (std::string(width - 1, ' ') + (Leadingzero ? to_string(100 + minutesintegral).substr(1, 2) : to_string(minutesintegral, 0))); + auto minutes = (std::string(width - 1, ' ') + (Leadingzero ? std::to_string(100 + minutesintegral).substr(1, 2) : to_string(minutesintegral, 0))); return (minutes.substr(minutes.size() - width, width) + fractionlabels[static_cast(std::floor(minutesfractional * 10 + 0.1))]); } diff --git a/utilities/utilities.h b/utilities/utilities.h index 73754f58..fafb708e 100644 --- a/utilities/utilities.h +++ b/utilities/utilities.h @@ -123,7 +123,8 @@ std::string to_string(double Value, int precision, int width); std::string to_hex_str(int const Value, int const width = 4); std::string to_minutes_str(float const Minutes, bool const Leadingzero, int const Width); -inline std::string to_string(bool Value) +template T> // Without this line this function can be used with other types implicit casted to boolean which may create hard to debug bugs. +inline std::string to_string(T Value) { return (Value == true ? "true" : "false"); } diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 57aeeaeb..bf9d99fc 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -353,8 +353,8 @@ std::string TSpeedPos::GetName() const else if( iFlags & spEvent ) // jeśli event return evEvent->m_name - + " [" + to_string( static_cast( evEvent->input_value( 1 ) ) ) - + ", " + to_string( static_cast( evEvent->input_value( 2 ) ) ) + + " [" + std::to_string( static_cast( evEvent->input_value( 1 ) ) ) + + ", " + std::to_string( static_cast( evEvent->input_value( 2 ) ) ) + "]"; else return ""; diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index 63df5603..cc2a9389 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -2023,7 +2023,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" if (ConversionError == 666) ErrorLog( "Bad vehicle: failed to locate definition file \"" + BaseDir + "/" + Type_Name + ".fiz" + "\"" ); else { - ErrorLog( "Bad vehicle: failed to load definition from file \"" + BaseDir + "/" + Type_Name + ".fiz\" (error " + to_string( ConversionError ) + ")" ); + ErrorLog( "Bad vehicle: failed to load definition from file \"" + BaseDir + "/" + Type_Name + ".fiz\" (error " + std::to_string( ConversionError ) + ")" ); } return 0.0; // zerowa długość to brak pojazdu } @@ -2466,11 +2466,11 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" if( mdModel ) { // jeśli ma w czym szukać for( int i = 0; i < 2; i++ ) { - asAnimName = std::string( "buffer_left0" ) + to_string( i + 1 ); + asAnimName = std::string( "buffer_left0" ) + std::to_string( i + 1 ); smBuforLewy[ i ] = mdModel->GetFromName( asAnimName ); if( smBuforLewy[ i ] ) smBuforLewy[ i ]->WillBeAnimated(); // ustawienie flagi animacji - asAnimName = std::string( "buffer_right0" ) + to_string( i + 1 ); + asAnimName = std::string( "buffer_right0" ) + std::to_string( i + 1 ); smBuforPrawy[ i ] = mdModel->GetFromName( asAnimName ); if( smBuforPrawy[ i ] ) smBuforPrawy[ i ]->WillBeAnimated(); @@ -3379,7 +3379,7 @@ bool TDynamicObject::Update(double dt, double dt1) if ((Fzad > 1) && (!MEDLogFile.is_open()) && (MoverParameters->Vel > 1)) { MEDLogFile.open( - "MEDLOGS/" + MoverParameters->Name + "_" + to_string( ++MEDLogCount ) + ".csv", + "MEDLOGS/" + MoverParameters->Name + "_" + std::to_string( ++MEDLogCount ) + ".csv", std::ios::in | std::ios::out | std::ios::trunc ); MEDLogFile << "t\tVel\tMasa\tOsie\tFmaxPN\tFmaxED\tFfulED\tFrED\tFzad\tFzadED\tFzadPN"; for(int k=1;k<=np;k++) diff --git a/world/EvLaunch.cpp b/world/EvLaunch.cpp index 01c56dd6..eebc4255 100644 --- a/world/EvLaunch.cpp +++ b/world/EvLaunch.cpp @@ -150,7 +150,7 @@ bool TEventLauncher::Load(cParser *parser) WriteLog( "EventLauncher at " + std::to_string( iHour ) + ":" - + ( iMinute < 10 ? "0" : "" ) + to_string( iMinute ) + + ( iMinute < 10 ? "0" : "" ) + std::to_string( iMinute ) + " (" + asEvent1Name + ( asEvent2Name != "none" ? " / " + asEvent2Name : "" ) + ")" ); // wyświetlenie czasu @@ -316,8 +316,8 @@ TEventLauncher::export_as_text_( std::ostream &Output ) const { << "condition " << asMemCellName << ' ' << szText << ' ' - << ( ( iCheckMask & basic_event::flags::value1 ) != 0 ? to_string( fVal1 ) : "*" ) << ' ' - << ( ( iCheckMask & basic_event::flags::value2 ) != 0 ? to_string( fVal2 ) : "*" ) << ' '; + << ( ( iCheckMask & basic_event::flags::value1 ) != 0 ? std::to_string( fVal1 ) : "*" ) << ' ' + << ( ( iCheckMask & basic_event::flags::value2 ) != 0 ? std::to_string( fVal2 ) : "*" ) << ' '; } // footer Output diff --git a/world/Event.cpp b/world/Event.cpp index 350a6a48..fad60bc4 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -275,8 +275,8 @@ basic_event::event_conditions::export_as_text( std::ostream &Output ) const { Output << "memcompareex " << ( ( flags & flags::text ) == 0 ? "*" : memcompare_text + ' ' + to_string( memcompare_text_operator ) ) << ' ' - << ( ( flags & flags::value1 ) == 0 ? "*" : to_string( memcompare_value1 ) + ' ' + to_string( memcompare_value1_operator ) ) << ' ' - << ( ( flags & flags::value2 ) == 0 ? "*" : to_string( memcompare_value2 ) + ' ' + to_string( memcompare_value2_operator ) ) << ' '; + << ( ( flags & flags::value1 ) == 0 ? "*" : std::to_string( memcompare_value1 ) + ' ' + to_string( memcompare_value1_operator ) ) << ' ' + << ( ( flags & flags::value2 ) == 0 ? "*" : std::to_string( memcompare_value2 ) + ' ' + to_string( memcompare_value2_operator ) ) << ' '; } } } @@ -557,8 +557,8 @@ updatevalues_event::export_as_text_( std::ostream &Output ) const { Output << ( ( m_input.flags & flags::text ) == 0 ? "*" : m_input.data_text ) << ' ' - << ( ( m_input.flags & flags::value1 ) == 0 ? "*" : to_string( m_input.data_value_1 ) ) << ' ' - << ( ( m_input.flags & flags::value2 ) == 0 ? "*" : to_string( m_input.data_value_2 ) ) << ' '; + << ( ( m_input.flags & flags::value1 ) == 0 ? "*" : std::to_string( m_input.data_value_1 ) ) << ' ' + << ( ( m_input.flags & flags::value2 ) == 0 ? "*" : std::to_string( m_input.data_value_2 ) ) << ' '; m_conditions.export_as_text( Output ); } @@ -1052,7 +1052,7 @@ whois_event::run_() { m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( - "Type: WhoIs (" + to_string( m_input.flags ) + ") - " + "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " + "[next station: " + nextstop + "], " + "[X], " + "[stop at next station: " + ( isstop != 0 ? "yes" : "no" ) + "]" ); @@ -1066,7 +1066,7 @@ whois_event::run_() { m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( - "Type: WhoIs (" + to_string( m_input.flags ) + ") - " + "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " + "[name: " + m_activator->asName + "], " + "[X], " + "[X]" ); @@ -1098,7 +1098,7 @@ whois_event::run_() { m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( - "Type: WhoIs (" + to_string( m_input.flags ) + ") - " + "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " + "[type: " + m_activator->MoverParameters->TypeName + "], " + "[consist brake level: " + to_string( consistbrakelevel, 2 ) + "], " + "[obstacle distance: " + to_string( collisiondistance, 2 ) + " m]" ); @@ -1112,7 +1112,7 @@ whois_event::run_() { m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( - "Type: WhoIs (" + to_string( m_input.flags ) + ") - " + "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " + "[load type: " + m_activator->MoverParameters->LoadType.name + "], " + "[current load: " + to_string( m_activator->MoverParameters->LoadAmount, 2 ) + "], " + "[max load: " + to_string( m_activator->MoverParameters->MaxLoad, 2 ) + "]" ); @@ -1127,9 +1127,9 @@ whois_event::run_() { m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( - "Type: WhoIs (" + to_string( m_input.flags ) + ") - " + "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " + "[destination: " + m_activator->asDestination + "], " - + "[direction: " + to_string( m_activator->DirectionGet() ) + "], " + + "[direction: " + std::to_string( m_activator->DirectionGet() ) + "], " + "[engine power: " + to_string( m_activator->MoverParameters->Power, 2 ) + "]" ); } // +0 @@ -1143,9 +1143,9 @@ whois_event::run_() { 0, // 1, gdy ma tu zatrzymanie m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( - "Type: WhoIs (" + to_string( m_input.flags ) + ") - " + "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " + "[train: " + m_activator->Mechanik->TrainName() + "], " - + "[stations left: " + to_string( m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex() ) + "], " + + "[stations left: " + std::to_string( m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex() ) + "], " + "[stop at next station: " + ( m_activator->Mechanik->IsStop() ? "yes" : "no") + "]" ); } } @@ -1395,7 +1395,7 @@ sound_event::run_() { WriteLog( "Type: Sound - [" + std::string( m_soundmode == 1 ? "play" : m_soundmode == -1 ? "loop" : "stop" ) + "]" - + ( m_soundradiochannel > 0 ? " [channel " + to_string( m_soundradiochannel ) + "]" : "" ) ); + + ( m_soundradiochannel > 0 ? " [channel " + std::to_string( m_soundradiochannel ) + "]" : "" ) ); for( auto &target : m_sounds ) { auto *targetsound = std::get( target ); if( targetsound == nullptr ) { continue; } @@ -1771,7 +1771,7 @@ lights_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { Input >> m_lights[ lightidx++ ]; } else { - ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") with more than " + to_string( lightcountlimit ) + " parameters" ); + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") with more than " + std::to_string( lightcountlimit ) + " parameters" ); } } while( lightidx < lightcountlimit ) {