diff --git a/src/addons/network_http.cpp b/src/addons/network_http.cpp index 569e2e6dc..977197d21 100644 --- a/src/addons/network_http.cpp +++ b/src/addons/network_http.cpp @@ -35,7 +35,6 @@ #include "utils/string_utils.hpp" #include "utils/time.hpp" #include "utils/translation.hpp" -#include "utils/vs.hpp" // ---------------------------------------------------------------------------- /** Create a thread that handles all network functions independent of the diff --git a/src/audio/sfx_openal.cpp b/src/audio/sfx_openal.cpp index fb73fd969..a08d9b63b 100644 --- a/src/audio/sfx_openal.cpp +++ b/src/audio/sfx_openal.cpp @@ -25,6 +25,7 @@ #include "config/user_config.hpp" #include "io/file_manager.hpp" #include "race/race_manager.hpp" +#include "utils/vs.hpp" #ifdef __APPLE__ # include @@ -33,16 +34,10 @@ #endif #include +#include #include #include -#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) -# define isnan _isnan -#else -# include -#endif - - SFXOpenAL::SFXOpenAL(SFXBuffer* buffer, bool positional, float gain, bool ownsBuffer) : SFXBase() { m_soundBuffer = buffer; diff --git a/src/guiengine/layout_manager.cpp b/src/guiengine/layout_manager.cpp index ed65a6c17..714a2b7de 100644 --- a/src/guiengine/layout_manager.cpp +++ b/src/guiengine/layout_manager.cpp @@ -323,10 +323,10 @@ void LayoutManager::applyCoords(Widget* self, AbstractTopLevelContainer* topLeve else if (self->m_relative_y > -1) self->m_y = (int)(parent_y + parent_h*self->m_relative_y/100); if (self->m_absolute_w > -1) self->m_w = self->m_absolute_w; - else if (self->m_relative_w > -1) self->m_w = (int)roundf(parent_w*self->m_relative_w/100.0); + else if (self->m_relative_w > -1) self->m_w = (int)roundf(parent_w*self->m_relative_w/100.0f); if (self->m_absolute_h > -1) self->m_h = self->m_absolute_h; - else if (self->m_relative_h > -1) self->m_h = (int)roundf(parent_h*self->m_relative_h/100.0); + else if (self->m_relative_h > -1) self->m_h = (int)roundf(parent_h*self->m_relative_h/100.0f); // ---- can't make widget bigger than parent if (self->m_h > (int)parent_h) diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.cpp b/src/guiengine/widgets/dynamic_ribbon_widget.cpp index 05f7a53f0..0c408d757 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.cpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.cpp @@ -265,8 +265,6 @@ void DynamicRibbonWidget::add() assert(m_row_amount != -1); } - // m_row_amount = (int)round((m_h - m_label_height) / (float)m_child_height); - if (m_properties[PROP_MAX_ROWS].size() > 0) { const int max_rows = atoi(m_properties[PROP_MAX_ROWS].c_str()); diff --git a/src/guiengine/widgets/rating_bar_widget.cpp b/src/guiengine/widgets/rating_bar_widget.cpp index 3444aed98..e6135d0f4 100644 --- a/src/guiengine/widgets/rating_bar_widget.cpp +++ b/src/guiengine/widgets/rating_bar_widget.cpp @@ -19,20 +19,12 @@ #include "guiengine/modaldialog.hpp" #include "guiengine/widgets/rating_bar_widget.hpp" #include "utils/string_utils.hpp" +#include "utils/vs.hpp" #include #include #include #include - -#if defined(WIN32) && _MSC_VER < 1800 -// VS up to and including VS 2012 do not provide the normal round function -static inline float round(float val) -{ - return floor(val + 0.5f); -} -#endif - #include using namespace GUIEngine; @@ -87,7 +79,7 @@ void RatingBarWidget::setStepValues(float float_rating) m_star_values[star] = m_steps-1; else { - m_star_values[star] =(int)round((float_rating * (m_steps-1)) - (star*(m_steps-1))); + m_star_values[star] =(int)roundf((float_rating * (m_steps-1)) - (star*(m_steps-1))); } } } @@ -109,7 +101,7 @@ void RatingBarWidget::setStepValuesByMouse(const core::position2di & mouse_posit { m_hovering = true; float exact_hover = (float)(mouse_position.X - stars_rect.UpperLeftCorner.X) / (float)stars_rect.getWidth() * (float)m_stars; - m_hover_rating = round(exact_hover * (m_steps-1)) / (m_steps-1); + m_hover_rating = roundf(exact_hover * (m_steps-1)) / (m_steps-1); setStepValues(m_hover_rating); } else if(m_hovering) diff --git a/src/online/http_manager.cpp b/src/online/http_manager.cpp index e36b1613b..7c65a9f65 100644 --- a/src/online/http_manager.cpp +++ b/src/online/http_manager.cpp @@ -30,7 +30,6 @@ #if defined(WIN32) && !defined(__CYGWIN__) # include -# define isnan _isnan #else # include # include diff --git a/src/utils/vs.hpp b/src/utils/vs.hpp index 68045956b..b97a6a4f4 100644 --- a/src/utils/vs.hpp +++ b/src/utils/vs.hpp @@ -1,12 +1,12 @@ -// Visual studio workarounds in one place +/** Visual studio workarounds in one place + * Note that Visual Studio 2013 does have the maths functions defined, + * so we define the work arounds only for compiler versions before 18.00 + */ -#if defined(_MSC_VER) -# include -# include +#if defined(WIN32) && _MSC_VER < 1800 # include # define isnan _isnan -//# define round(x) (floor(x + 0.5f)) -# define roundf(x) (floor(x + 0.5f)) +# define roundf(x) (floorf(x + 0.5f)) #endif