From 9896c7ae3b7b6773037a542dd6eb1b748c782dd4 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Sun, 25 Aug 2013 12:02:18 +0000 Subject: [PATCH] Fixed usage of usleep and round for visual studio. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13561 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/guiengine/widgets/rating_bar_widget.cpp | 11 ++++++++++- src/network/protocol_manager.cpp | 4 ++-- src/network/stk_host.cpp | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/guiengine/widgets/rating_bar_widget.cpp b/src/guiengine/widgets/rating_bar_widget.cpp index efaaa5566..83b76a67d 100644 --- a/src/guiengine/widgets/rating_bar_widget.cpp +++ b/src/guiengine/widgets/rating_bar_widget.cpp @@ -19,13 +19,22 @@ #include "guiengine/modaldialog.hpp" #include "guiengine/widgets/rating_bar_widget.hpp" #include "utils/string_utils.hpp" -#include #include #include #include #include +#ifdef WIN32 +// VS up to and including VS 2012 do not provide the normal round function +static inline double round(double val) +{ + return floor(val + 0.5); +} +#endif + +#include + using namespace GUIEngine; using namespace irr::core; using namespace irr; diff --git a/src/network/protocol_manager.cpp b/src/network/protocol_manager.cpp index c18c2e094..b57fd3d62 100644 --- a/src/network/protocol_manager.cpp +++ b/src/network/protocol_manager.cpp @@ -34,7 +34,7 @@ void* protocolManagerUpdate(void* data) while(!manager->exit()) { manager->update(); - usleep(20000); + irr_driver->getDevice()->sleep(20); } return NULL; } @@ -44,7 +44,7 @@ void* protocolManagerAsynchronousUpdate(void* data) while(!manager->exit()) { manager->asynchronousUpdate(); - usleep(20000); + irr_driver->getDevice()->sleep(20); } return NULL; } diff --git a/src/network/stk_host.cpp b/src/network/stk_host.cpp index 817b58dea..1a2576a39 100644 --- a/src/network/stk_host.cpp +++ b/src/network/stk_host.cpp @@ -161,7 +161,7 @@ uint8_t* STKHost::receiveRawPacket() { i++; len = recv(m_host->socket,(char*)buffer,2048, 0); - usleep(1000); + irr_driver->getDevice()->sleep(1); } return buffer; } @@ -186,7 +186,7 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress* sender) { i++; len = recvfrom(m_host->socket, (char*)buffer, 2048, 0, &addr, &from_len); - usleep(1000); // wait 1 millisecond between two checks + irr_driver->getDevice()->sleep(1); // wait 1 millisecond between two checks } struct sockaddr_in *sin = (struct sockaddr_in *) (&addr); // we received the data @@ -226,7 +226,7 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender) { i++; len = recvfrom(m_host->socket, (char*)buffer, 2048, 0, &addr, &from_len); - usleep(1000); // wait 1 millisecond between two checks + irr_driver->getDevice()->sleep(1); // wait 1 millisecond between two checks } if (addr.sa_family == AF_INET) {