From 634e299e81544f1b872914d9b54c0e4c2ef70342 Mon Sep 17 00:00:00 2001 From: BlockMen Date: Fri, 14 Apr 2017 03:41:30 +0200 Subject: [PATCH] Fix MSVC not compiling --- src/content_mapblock.cpp | 9 +++++++++ src/socket.cpp | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 50af991..ca9be12 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -35,6 +35,15 @@ #include "sound.h" #ifndef SERVER + +// For all MSVC versions before Visual Studio 2013 +#if defined(_MSC_VER) && _MSC_VER < 1800 + float roundf(float x) + { + return float((x < 0) ? (ceil((x) - 0.5)) : (floor((x) + 0.5))); + } +#endif + static const v3s16 corners[8] = { v3s16(-1, 1, 1), v3s16( 1, 1, 1), diff --git a/src/socket.cpp b/src/socket.cpp index 94a156c..3734bbf 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -312,7 +312,7 @@ bool UDPSocket::WaitData(int timeout_ms) // Initialize time out struct struct timeval tv; - tv.tv_sec = floor(timeout_ms / 1000) ; + tv.tv_sec = floor((float)timeout_ms / 1000) ; tv.tv_usec = 1000 * (timeout_ms % 1000); // select() result = select(m_handle+1, &readset, NULL, NULL, &tv); @@ -574,7 +574,7 @@ bool TCPSocket::WaitData(int timeout_ms) // Initialize time out struct struct timeval tv; - tv.tv_sec = floor(timeout_ms / 1000); + tv.tv_sec = floor((float)timeout_ms / 1000); tv.tv_usec = 1000 * (timeout_ms % 1000); if (m_bstart != m_bend)