From 9c6b45a11b40f05055773e1c22d6f356278d2653 Mon Sep 17 00:00:00 2001 From: Steven Noonan Date: Wed, 18 Mar 2020 23:39:41 +0000 Subject: [PATCH 1/4] clang -Wimplicit-int-float-conversion fixes --- src/lightmap.cpp | 4 ++++ src/monmove.cpp | 11 ++++++----- src/npcmove.cpp | 3 ++- src/options.cpp | 5 +++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lightmap.cpp b/src/lightmap.cpp index d1c758ee44057..d7bb6d680640a 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -1237,8 +1237,12 @@ float fastexp( float x ) float f; int i; } u, v; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion" u.i = static_cast( 6051102 * x + 1056478197 ); v.i = static_cast( 1056478197 - 6051102 * x ); +#pragma GCC diagnostic pop return u.f / v.f; } diff --git a/src/monmove.cpp b/src/monmove.cpp index 8570316d25b2c..59cf9d0c31022 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "avatar.h" #include "bionics.h" @@ -246,16 +247,16 @@ float monster::rate_target( Creature &c, float best, bool smart ) const { const auto d = rl_dist_fast( pos(), c.pos() ); if( d <= 0 ) { - return INT_MAX; + return FLT_MAX; } // Check a very common and cheap case first if( !smart && d >= best ) { - return INT_MAX; + return FLT_MAX; } if( !sees( c ) ) { - return INT_MAX; + return FLT_MAX; } if( !smart ) { @@ -273,7 +274,7 @@ float monster::rate_target( Creature &c, float best, bool smart ) const return int( d ) / power; } - return INT_MAX; + return FLT_MAX; } void monster::plan() @@ -467,7 +468,7 @@ void monster::plan() wandf = 2; target = nullptr; // Swarm to the furthest ally you can see - } else if( rating < INT_MAX && rating > dist && wandf <= 0 ) { + } else if( rating < FLT_MAX && rating > dist && wandf <= 0 ) { target = &mon; dist = rating; } diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 9a6019d53a2b9..e5fb01c38dd92 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "activity_handlers.h" #include "avatar.h" @@ -194,7 +195,7 @@ tripoint npc::good_escape_direction( bool include_pos ) return rating; }; - float best_rating = include_pos ? rate_pt( pos(), 0.0f ) : INT_MAX; + float best_rating = include_pos ? rate_pt( pos(), 0.0f ) : FLT_MAX; candidates.emplace_back( pos() ); std::map adj_map; diff --git a/src/options.cpp b/src/options.cpp index 56c98df973363..d749ae5c942cd 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "cata_utility.h" #include "catacharset.h" @@ -218,8 +219,8 @@ void options_manager::add_external( const std::string &sNameIn, const std::strin thisOpt.iSet = 0; break; case cOpt::CVT_FLOAT: - thisOpt.fMin = INT_MIN; - thisOpt.fMax = INT_MAX; + thisOpt.fMin = FLT_MIN; + thisOpt.fMax = FLT_MAX; thisOpt.fDefault = 0; thisOpt.fSet = 0; thisOpt.fStep = 1; From f47ffe4fbe3fea347996d7d5f37c9030ee9f0bb7 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Thu, 19 Mar 2020 01:38:06 +0000 Subject: [PATCH 2/4] Update src/lightmap.cpp --- src/lightmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightmap.cpp b/src/lightmap.cpp index d7bb6d680640a..381bf25dd25a4 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -1238,7 +1238,7 @@ float fastexp( float x ) int i; } u, v; #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wno-pragmas" #pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion" u.i = static_cast( 6051102 * x + 1056478197 ); v.i = static_cast( 1056478197 - 6051102 * x ); From 7f54e3777481399865842b49d61541eef1a14f2b Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Thu, 19 Mar 2020 02:41:53 +0000 Subject: [PATCH 3/4] Update src/lightmap.cpp --- src/lightmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightmap.cpp b/src/lightmap.cpp index 381bf25dd25a4..6241cde9e5f50 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -1238,7 +1238,7 @@ float fastexp( float x ) int i; } u, v; #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wno-pragmas" +#pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion" u.i = static_cast( 6051102 * x + 1056478197 ); v.i = static_cast( 1056478197 - 6051102 * x ); From 5b395542b36c61bde574dd2f2689dcab4a0aebc2 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Thu, 19 Mar 2020 06:58:03 +0000 Subject: [PATCH 4/4] Apply suggestions from code review Co-Authored-By: ZhilkinSerg --- src/monmove.cpp | 2 +- src/npcmove.cpp | 2 +- src/options.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/monmove.cpp b/src/monmove.cpp index 59cf9d0c31022..74d1fd3ec1feb 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "avatar.h" #include "bionics.h" diff --git a/src/npcmove.cpp b/src/npcmove.cpp index e5fb01c38dd92..28f4513fc728f 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "activity_handlers.h" #include "avatar.h" diff --git a/src/options.cpp b/src/options.cpp index d749ae5c942cd..c616da3c76277 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "cata_utility.h" #include "catacharset.h"