mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-04 18:49:26 +01:00
refactor(sonar): more small fixes
- std::format instead of iostream manipulators in to_string/to_hex_str (cpp:S6495); output verified identical, negative hex values keep the unsigned form - remove an empty compound statement (cpp:S108) - drop an always-false unsigned < 0 branch (cpp:S1768) - explicit lambda capture (cpp:S3608) - std::make_unique (cpp:S5950)
This commit is contained in:
@@ -38,7 +38,7 @@ void
|
|||||||
TController::remove_hint( driver_hint const Value ) {
|
TController::remove_hint( driver_hint const Value ) {
|
||||||
|
|
||||||
m_hints.remove_if(
|
m_hints.remove_if(
|
||||||
[=]( auto const &Hint ) {
|
[Value]( auto const &Hint ) {
|
||||||
return std::get<driver_hint>(Hint) == Value; } );
|
return std::get<driver_hint>(Hint) == Value; } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
std::unique_ptr<gfx_renderer> null_renderer::create_func()
|
std::unique_ptr<gfx_renderer> null_renderer::create_func()
|
||||||
{
|
{
|
||||||
return std::unique_ptr<null_renderer>(new null_renderer());
|
return std::make_unique<null_renderer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool null_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("null", null_renderer::create_func);
|
bool null_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("null", null_renderer::create_func);
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ scenario_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yea
|
|||||||
int
|
int
|
||||||
scenario_time::julian_day() const {
|
scenario_time::julian_day() const {
|
||||||
|
|
||||||
int yy = static_cast<int>(( m_time.wYear < 0 ? m_time.wYear + 1 : m_time.wYear ) - std::floor( ( 12 - m_time.wMonth ) / 10.f ));
|
int yy = static_cast<int>( m_time.wYear - std::floor( ( 12 - m_time.wMonth ) / 10.f ));
|
||||||
int mm = m_time.wMonth + 9;
|
int mm = m_time.wMonth + 9;
|
||||||
if( mm >= 12 ) { mm -= 12; }
|
if( mm >= 12 ) { mm -= 12; }
|
||||||
|
|
||||||
|
|||||||
@@ -249,23 +249,18 @@ std::string to_string(int Value, int width)
|
|||||||
|
|
||||||
std::string to_string(double Value, int precision)
|
std::string to_string(double Value, int precision)
|
||||||
{
|
{
|
||||||
std::ostringstream o;
|
return std::format("{:.{}f}", Value, precision);
|
||||||
o << std::fixed << std::setprecision(precision) << Value;
|
|
||||||
return std::move(o).str();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string to_string(double const Value, int const Precision, int const Width)
|
std::string to_string(double const Value, int const Precision, int const Width)
|
||||||
{
|
{
|
||||||
std::ostringstream o;
|
return std::format("{:>{}.{}f}", Value, Width, Precision);
|
||||||
o << std::setw(Width) << std::fixed << std::setprecision(Precision) << Value;
|
|
||||||
return std::move(o).str();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string to_hex_str(int const Value, int const Width)
|
std::string to_hex_str(int const Value, int const Width)
|
||||||
{
|
{
|
||||||
std::ostringstream o;
|
// iostreams print negative values in hex as their unsigned representation
|
||||||
o << "0x" << std::uppercase << std::setfill('0') << std::setw(Width) << std::hex << Value;
|
return std::format("0x{:0{}X}", static_cast<unsigned int>(Value), Width);
|
||||||
return o.str();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string const fractionlabels[] = {U8(" "), U8("¹"), U8("²"), U8("³"), U8("⁴"), U8("⁵"), U8("⁶"), U8("⁷"), U8("⁸"), U8("⁹")};
|
std::string const fractionlabels[] = {U8(" "), U8("¹"), U8("²"), U8("³"), U8("⁴"), U8("⁵"), U8("⁶"), U8("⁷"), U8("⁸"), U8("⁹")};
|
||||||
|
|||||||
@@ -10033,8 +10033,6 @@ void TTrain::update_sounds(double const Deltatime)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Console::BitsClear(1 << 14); // ustawienie bitu 16 na PoKeys
|
Console::BitsClear(1 << 14); // ustawienie bitu 16 na PoKeys
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dsbBuzzerShp && dsbBuzzerShp->is_playing())
|
if (dsbBuzzerShp && dsbBuzzerShp->is_playing())
|
||||||
|
|||||||
Reference in New Issue
Block a user