From 7ddb0835d6debd01dfbb837b7518a8b969946281 Mon Sep 17 00:00:00 2001 From: joveeater Date: Wed, 10 May 2023 18:53:50 +0100 Subject: [PATCH 1/4] Update Makefile --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 4ca78e5e0c5b..958d9dac6028 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,7 @@ WARNINGS = \ -Wunused-macros \ -Wzero-as-null-pointer-constant \ -Wno-unknown-warning-option \ + -Wno-dangling-reference \ -Wno-range-loop-analysis # TODO: Fix warnings instead of disabling # Uncomment below to disable warnings #WARNINGS = -w From c0a5c703728cf1a70258066f5701bc8bed3cdde5 Mon Sep 17 00:00:00 2001 From: joveeater Date: Wed, 10 May 2023 18:55:18 +0100 Subject: [PATCH 2/4] Update weather_gen.cpp --- src/weather_gen.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index ee390ab5f0ce..b8658a40d414 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -214,40 +214,40 @@ const weather_type_id &weather_generator::get_weather_conditions( const w_point w_point wp2 = w; const weather_type_id *current_conditions = &weather_type_id::NULL_ID(); for( const weather_type_id &type : weather_types ) { - const weather_requirements &requires = type->requirements; - weather_requirements rq2 = requires; + const weather_requirements &wrequires = type->requirements; + weather_requirements rq2 = wrequires; bool test_pressure = - requires.pressure_max > w.pressure && - requires.pressure_min < w.pressure; + wrequires.pressure_max > w.pressure && + wrequires.pressure_min < w.pressure; bool test_humidity = - requires.humidity_max > w.humidity && - requires.humidity_min < w.humidity; - if( ( requires.humidity_and_pressure && !( test_pressure && test_humidity ) ) || - ( !requires.humidity_and_pressure && !( test_pressure || test_humidity ) ) ) { + wrequires.humidity_max > w.humidity && + wrequires.humidity_min < w.humidity; + if( ( wrequires.humidity_and_pressure && !( test_pressure && test_humidity ) ) || + ( !wrequires.humidity_and_pressure && !( test_pressure || test_humidity ) ) ) { continue; } bool test_temperature = - requires.temperature_max > units::to_fahrenheit( w.temperature ) && - requires.temperature_min < units::to_fahrenheit( w.temperature ); + wrequires.temperature_max > units::to_fahrenheit( w.temperature ) && + wrequires.temperature_min < units::to_fahrenheit( w.temperature ); bool test_windspeed = - requires.windpower_max > w.windpower && - requires.windpower_min < w.windpower; - bool test_acidic = !requires.acidic || w.acidic; + wrequires.windpower_max > w.windpower && + wrequires.windpower_min < w.windpower; + bool test_acidic = !wrequires.acidic || w.acidic; if( !( test_temperature && test_windspeed && test_acidic ) ) { continue; } - if( !requires.required_weathers.empty() ) { - if( std::find( requires.required_weathers.begin(), requires.required_weathers.end(), - *current_conditions ) == requires.required_weathers.end() ) { + if( !wrequires.required_weathers.empty() ) { + if( std::find( wrequires.required_weathers.begin(), wrequires.required_weathers.end(), + *current_conditions ) == wrequires.required_weathers.end() ) { continue; } } - if( requires.time != weather_time_requirement_type::both ) { + if( wrequires.time != weather_time_requirement_type::both ) { bool day = is_day( calendar::turn ); - if( ( requires.time == weather_time_requirement_type::day && !day ) || - ( requires.time == weather_time_requirement_type::night && day ) ) { + if( ( wrequires.time == weather_time_requirement_type::day && !day ) || + ( wrequires.time == weather_time_requirement_type::night && day ) ) { continue; } } From 561e2180b39b6f40eae61011d692bc9d91f1231e Mon Sep 17 00:00:00 2001 From: joveeater Date: Wed, 10 May 2023 18:55:51 +0100 Subject: [PATCH 3/4] Update string_utils.cpp --- src/string_utils.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/string_utils.cpp b/src/string_utils.cpp index fc763dc14e03..6817c5a513cb 100644 --- a/src/string_utils.cpp +++ b/src/string_utils.cpp @@ -11,8 +11,9 @@ bool lcmatch( const std::string &str, const std::string &qry ) { - if( std::locale().name() != "en_US.UTF-8" && std::locale().name() != "C" ) { - auto &f = std::use_facet>( std::locale() ); + std::locale temp_locale = std::locale(); + if( temp_locale.name() != "en_US.UTF-8" && temp_locale.name() != "C" ) { + auto &f = std::use_facet>( temp_locale ); std::wstring wneedle = utf8_to_wstr( qry ); std::wstring whaystack = utf8_to_wstr( str ); @@ -225,30 +226,32 @@ std::string trim_punctuation_marks( const std::string &s ) using char_t = std::string::value_type; std::string to_upper_case( const std::string &s ) { - if( std::locale().name() != "en_US.UTF-8" && std::locale().name() != "C" ) { - const auto &f = std::use_facet>( std::locale() ); + auto temp_locale = std::locale(); + if( temp_locale.name() != "en_US.UTF-8" && temp_locale.name() != "C" ) { + const auto &f = std::use_facet>( temp_locale ); std::wstring wstr = utf8_to_wstr( s ); f.toupper( &wstr[0], &wstr[0] + wstr.size() ); return wstr_to_utf8( wstr ); } std::string res; - std::transform( s.begin(), s.end(), std::back_inserter( res ), []( char_t ch ) { - return std::use_facet>( std::locale() ).toupper( ch ); + std::transform( s.begin(), s.end(), std::back_inserter( res ), [&temp_locale]( char_t ch ) { + return std::use_facet>( temp_locale ).toupper( ch ); } ); return res; } std::string to_lower_case( const std::string &s ) { - if( std::locale().name() != "en_US.UTF-8" && std::locale().name() != "C" ) { - const auto &f = std::use_facet>( std::locale() ); + auto temp_locale = std::locale(); + if( temp_locale.name() != "en_US.UTF-8" && temp_locale.name() != "C" ) { + const auto &f = std::use_facet>( temp_locale ); std::wstring wstr = utf8_to_wstr( s ); f.tolower( &wstr[0], &wstr[0] + wstr.size() ); return wstr_to_utf8( wstr ); } std::string res; - std::transform( s.begin(), s.end(), std::back_inserter( res ), []( char_t ch ) { - return std::use_facet>( std::locale() ).tolower( ch ); + std::transform( s.begin(), s.end(), std::back_inserter( res ), [&temp_locale]( char_t ch ) { + return std::use_facet>( temp_locale ).tolower( ch ); } ); return res; } From 02769804f4f017aac1958f0819af73ccedbf7208 Mon Sep 17 00:00:00 2001 From: joveeater Date: Wed, 10 May 2023 23:52:37 +0100 Subject: [PATCH 4/4] Update src/string_utils.cpp Co-authored-by: scarf --- src/string_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string_utils.cpp b/src/string_utils.cpp index 6817c5a513cb..4c7c6d108577 100644 --- a/src/string_utils.cpp +++ b/src/string_utils.cpp @@ -11,7 +11,7 @@ bool lcmatch( const std::string &str, const std::string &qry ) { - std::locale temp_locale = std::locale(); + auto temp_locale = std::locale{}; if( temp_locale.name() != "en_US.UTF-8" && temp_locale.name() != "C" ) { auto &f = std::use_facet>( temp_locale ); std::wstring wneedle = utf8_to_wstr( qry );