From f7bfc3829e6a823e590c976498868553d97691a4 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Thu, 19 Mar 2020 08:11:38 +0000 Subject: [PATCH] clang -Wimplicit-int-float-conversion fixes (#38886) --- 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 c4acec7ab7cb7..62fe8d8f99910 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -1239,8 +1239,12 @@ float fastexp( float x ) float f; int i; } u, v; +#pragma GCC diagnostic push +#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 ); +#pragma GCC diagnostic pop return u.f / v.f; } diff --git a/src/monmove.cpp b/src/monmove.cpp index 8570316d25b2c..74d1fd3ec1feb 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 276cfb511e5d1..550b331180b4b 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "activity_handlers.h" #include "avatar.h" @@ -215,7 +216,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..c616da3c76277 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;