From 58ab55a6aaa4ad08a4697042d481f960cf87ac89 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 6 Sep 2010 06:22:08 +0000 Subject: [PATCH] - cleaned up some compiler warnings --- .../shared_lib/include/platform/posix/socket.h | 4 ++-- source/shared_lib/include/platform/sdl/window.h | 6 +++--- .../sources/platform/common/platform_common.cpp | 2 +- .../shared_lib/sources/platform/posix/socket.cpp | 10 +++++----- .../shared_lib/sources/platform/sdl/window.cpp | 16 ++++++++-------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/source/shared_lib/include/platform/posix/socket.h b/source/shared_lib/include/platform/posix/socket.h index 4d126530c..4b6970ef8 100644 --- a/source/shared_lib/include/platform/posix/socket.h +++ b/source/shared_lib/include/platform/posix/socket.h @@ -94,7 +94,7 @@ protected: std::string ipAddress; SimpleTaskThread *pingThread; - std::map pingCache; + std::map pingCache; time_t lastThreadedPing; Mutex pingThreadAccessor; @@ -136,7 +136,7 @@ public: bool isSocketValid() const; static bool isSocketValid(const PLATFORM_SOCKET *validateSocket); - static float getAveragePingMS(std::string host, int pingCount=5); + static double getAveragePingMS(std::string host, int pingCount=5); float getThreadedPingMS(std::string host); virtual std::string getIpAddress(); diff --git a/source/shared_lib/include/platform/sdl/window.h b/source/shared_lib/include/platform/sdl/window.h index 0ecf38f80..d111785eb 100644 --- a/source/shared_lib/include/platform/sdl/window.h +++ b/source/shared_lib/include/platform/sdl/window.h @@ -112,15 +112,15 @@ private: int lastMouseX[mbCount]; int lastMouseY[mbCount]; - static unsigned int lastMouseEvent; /** for use in mouse hover calculations */ + static int64 lastMouseEvent; /** for use in mouse hover calculations */ static MouseState mouseState; static Vec2i mousePos; static bool isKeyPressedDown; static bool isFullScreen; static SDL_keysym keystate; - static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;} - static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;} + static void setLastMouseEvent(int64 lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;} + static int64 getLastMouseEvent() {return Window::lastMouseEvent;} static const MouseState &getMouseState() {return Window::mouseState;} static void setMouseState(MouseButton b, bool state) {Window::mouseState.set(b, state);} diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 8a50bb8d2..857d51651 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -26,7 +26,7 @@ #endif #ifdef WIN32 - #define S_ISDIR(mode) ((mode) & _S_IFDIR) + #define S_ISDIR(mode) (((mode) & _S_IFDIR) == _S_IFDIR) #elif defined(__GNUC__) #else diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 8a0c232e1..4ec31c98b 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -266,11 +266,11 @@ Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned c Ip::Ip(const string& ipString){ - int offset= 0; + size_t offset= 0; int byteIndex= 0; for(byteIndex= 0; byteIndex<4; ++byteIndex){ - int dotPos= ipString.find_first_of('.', offset); + size_t dotPos= ipString.find_first_of('.', offset); bytes[byteIndex]= atoi(ipString.substr(offset, dotPos-offset).c_str()); offset= dotPos+1; @@ -759,7 +759,7 @@ void Socket::simpleTask() { //printf("Pinging hosts...\n"); - for(std::map::iterator iterMap = pingCache.begin(); + for(std::map::iterator iterMap = pingCache.begin(); iterMap != pingCache.end(); iterMap++) { MutexSafeWrapper safeMutex(&pingThreadAccessor); iterMap->second = getAveragePingMS(iterMap->first, 1); @@ -1024,7 +1024,7 @@ int Socket::send(const void *data, int dataSize) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] need to send more data, trying again getLastSocketError() = %d, bytesSent = %d, dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketError(),bytesSent,dataSize); MutexSafeWrapper safeMutex(&dataSynchAccessor); - int totalBytesSent = bytesSent; + ssize_t totalBytesSent = bytesSent; int attemptCount = 0; time_t tStartTimer = time(NULL); while(((bytesSent > 0 && totalBytesSent < dataSize) || @@ -1910,7 +1910,7 @@ void BroadCastSocketThread::execute() { setRunningStatus(false); } -float Socket::getAveragePingMS(std::string host, int pingCount) { +double Socket::getAveragePingMS(std::string host, int pingCount) { double result = -1; return result; diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 84d5f77f6..e5b78fcca 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -41,7 +41,7 @@ namespace Shared{ namespace Platform{ // Matze: hack for now... static Window* global_window = 0; static int oldX=0,oldY=0; -unsigned int Window::lastMouseEvent = 0; /** for use in mouse hover calculations */ +int64 Window::lastMouseEvent = 0; /** for use in mouse hover calculations */ Vec2i Window::mousePos; MouseState Window::mouseState; bool Window::isKeyPressedDown = false; @@ -153,9 +153,9 @@ bool Window::handleEvent() { //ms.centerMouse = (event.motion.state & SDL_BUTTON_MMASK) != 0; codeLocation = "h"; - setMouseState(mbLeft, event.motion.state & SDL_BUTTON_LMASK); - setMouseState(mbRight, event.motion.state & SDL_BUTTON_RMASK); - setMouseState(mbCenter, event.motion.state & SDL_BUTTON_MMASK); + setMouseState(mbLeft, (event.motion.state & SDL_BUTTON_LMASK) == SDL_BUTTON_LMASK); + setMouseState(mbRight, (event.motion.state & SDL_BUTTON_RMASK) == SDL_BUTTON_RMASK); + setMouseState(mbCenter, (event.motion.state & SDL_BUTTON_MMASK) == SDL_BUTTON_MMASK); if(global_window) { global_window->eventMouseMove(event.motion.x, event.motion.y, &getMouseState()); //&ms); @@ -219,7 +219,7 @@ bool Window::handleEvent() { } */ // Check if the program has lost window focus - if (event.active.state & SDL_APPACTIVE == SDL_APPACTIVE) { + if ((event.active.state & SDL_APPACTIVE) == SDL_APPACTIVE) { if (event.active.gain == 0) { Window::isActive = false; } @@ -249,9 +249,9 @@ bool Window::handleEvent() { showCursor(willShowCursor); } */ - if (event.active.state & SDL_APPMOUSEFOCUS != SDL_APPMOUSEFOCUS && - event.active.state & SDL_APPINPUTFOCUS != SDL_APPINPUTFOCUS && - event.active.state & SDL_APPACTIVE != SDL_APPACTIVE) { + if ((event.active.state & SDL_APPMOUSEFOCUS) != SDL_APPMOUSEFOCUS && + (event.active.state & SDL_APPINPUTFOCUS) != SDL_APPINPUTFOCUS && + (event.active.state & SDL_APPACTIVE) != SDL_APPACTIVE) { if (event.active.gain == 0) { Window::isActive = false; }