From 06b9d7eef7afdda8bbdfb6b15619e14c6c8d2d05 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 21 Oct 2010 15:21:46 +0000 Subject: [PATCH] - cleaned up a whole pile of compiler warnings --- source/shared_lib/include/map/map_preview.h | 2 +- source/shared_lib/include/util/conversion.h | 5 ++++- source/shared_lib/sources/lua/lua_script.cpp | 2 +- source/shared_lib/sources/map/map_preview.cpp | 14 +++++++------- .../shared_lib/sources/platform/posix/socket.cpp | 10 +++++----- source/shared_lib/sources/util/conversion.cpp | 2 +- source/shared_lib/sources/xml/xml_parser.cpp | 12 ++++++------ 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/source/shared_lib/include/map/map_preview.h b/source/shared_lib/include/map/map_preview.h index adf20a6d..aa201119 100644 --- a/source/shared_lib/include/map/map_preview.h +++ b/source/shared_lib/include/map/map_preview.h @@ -42,7 +42,7 @@ static const int MAX_MAP_CELL_DIMENSION = 1024; static const int MIN_MAP_CELL_HEIGHT = 0; static const int MAX_MAP_CELL_HEIGHT = 20; -static const int DEFAULT_MAP_CELL_HEIGHT = 10; +static const int DEFAULT_MAP_CELL_HEIGHT = 10; static const int MIN_MAP_FACTIONCOUNT = 1; static const int MAX_MAP_FACTIONCOUNT = 8; diff --git a/source/shared_lib/include/util/conversion.h b/source/shared_lib/include/util/conversion.h index fc4ca71f..2c430b16 100644 --- a/source/shared_lib/include/util/conversion.h +++ b/source/shared_lib/include/util/conversion.h @@ -13,10 +13,13 @@ #define _SHARED_UTIL_CONVERSION_H_ #include +#include "types.h" #include "leak_dumper.h" using std::string; +using namespace Shared::Platform; + namespace Shared { namespace Util { bool strToBool(const string &s); @@ -28,7 +31,7 @@ bool strToInt(const string &s, int *i); bool strToFloat(const string &s, float *f); string boolToStr(bool b); -string intToStr(int i); +string intToStr(int64 i); string intToHex(int i); string floatToStr(float f,int precsion=2); string doubleToStr(double f,int precsion=2); diff --git a/source/shared_lib/sources/lua/lua_script.cpp b/source/shared_lib/sources/lua/lua_script.cpp index 433d86ab..a936fcfa 100644 --- a/source/shared_lib/sources/lua/lua_script.cpp +++ b/source/shared_lib/sources/lua/lua_script.cpp @@ -203,7 +203,7 @@ void * LuaArguments::getGenericData(int argumentIndex) const{ // return (void *)result; //} else if(lua_isnumber(luaState, argumentIndex)) { - int result = luaL_checkinteger(luaState, argumentIndex); + lua_Integer result = luaL_checkinteger(luaState, argumentIndex); printf("\nGENERIC param %d is an int, %d!\n",argumentIndex,result); return (void *)result; } diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index 02c3a28e..2044be19 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -35,7 +35,7 @@ MapPreview::MapPreview() { cells.clear(); //startLocations = NULL; startLocations.clear(); - reset(DEFAULT_MAP_CELL_WIDTH, DEFAULT_MAP_CELL_LENGTH, DEFAULT_MAP_CELL_HEIGHT, DEFAULT_MAP_CELL_SURFACE_TYPE); + reset(DEFAULT_MAP_CELL_WIDTH, DEFAULT_MAP_CELL_LENGTH, (float)DEFAULT_MAP_CELL_HEIGHT, DEFAULT_MAP_CELL_SURFACE_TYPE); resetFactions(DEFAULT_MAP_FACTIONCOUNT); title = ""; desc = ""; @@ -144,22 +144,22 @@ void MapPreview::pirateChangeHeight(int x, int y, int height, int radius) { int indexJ = 0; for (int j = y - radius; j <= y + radius; j += radius) { // round off the corners - int ti, tj; + int ti=0, tj=0; if (abs(i - x) == abs(j - y)) { - ti = (i - x) * 0.707 + x + 0.5; - tj = (j - y) * 0.707 + y + 0.5; + ti = (int)((i - x) * 0.707 + x + 0.5); + tj = (int)((j - y) * 0.707 + y + 0.5); } else { ti = i; tj = j; } if (inside(ti, tj)) { - gradient[indexI][indexJ] = (cells[ti][tj].height - goalAlt) / radius; + gradient[indexI][indexJ] = (cells[ti][tj].height - (float)goalAlt) / (float)radius; //} else if (dist == 0) { //gradient[indexI][indexJ] = 0; } else { // assume outside the map bounds is height 10 - gradient[indexI][indexJ] = (10.0 - goalAlt) / radius; + gradient[indexI][indexJ] = (10.0f - (float)goalAlt) / (float)radius; } //std::cout << "gradient[" << indexI << "][" << indexJ << "] = " << gradient[indexI][indexJ] << std::endl; //std::cout << "derived from height " << cells[ti][tj].height << " at " << ti << " " << tj << std::endl; @@ -658,7 +658,7 @@ void MapPreview::loadFromFile(const string &path) { } //read Heights - reset(header.width, header.height, DEFAULT_MAP_CELL_HEIGHT, DEFAULT_MAP_CELL_SURFACE_TYPE); + reset(header.width, header.height, (float)DEFAULT_MAP_CELL_HEIGHT, DEFAULT_MAP_CELL_SURFACE_TYPE); for (int j = 0; j < h; ++j) { for (int i = 0; i < w; ++i) { bytes = fread(&cells[i][j].height, sizeof(float), 1, f1); diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index a4d92033..f9ab1325 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -838,7 +838,7 @@ bool Socket::hasDataToRead(std::map &socketTriggeredList) int retval = 0; { //MutexSafeWrapper safeMutex(&dataSynchAccessor); - retval = select(imaxsocket + 1, &rfds, NULL, NULL, &tv); + retval = select((int)imaxsocket + 1, &rfds, NULL, NULL, &tv); } if(retval < 0) { @@ -899,7 +899,7 @@ bool Socket::hasDataToRead(PLATFORM_SOCKET socket) int retval = 0; { //MutexSafeWrapper safeMutex(&dataSynchAccessor); - retval = select(socket + 1, &rfds, NULL, NULL, &tv); + retval = select((int)socket + 1, &rfds, NULL, NULL, &tv); } if(retval) { @@ -1188,7 +1188,7 @@ bool Socket::isReadable() { int i = 0; { //MutexSafeWrapper safeMutex(&dataSynchAccessor); - i= select(sock+1, &set, NULL, NULL, &tv); + i= select((int)sock + 1, &set, NULL, NULL, &tv); } if(i < 0) { if(difftime(time(NULL),lastDebugEvent) >= 1) { @@ -1218,7 +1218,7 @@ bool Socket::isWritable(bool waitOnDelayedResponse) { int i = 0; { //MutexSafeWrapper safeMutex(&dataSynchAccessor); - i = select(sock+1, NULL, &set, NULL, &tv); + i = select((int)sock + 1, NULL, &set, NULL, &tv); } if(i < 0 ) { if(difftime(time(NULL),lastDebugEvent) >= 1) { @@ -1395,7 +1395,7 @@ void ClientSocket::connect(const Ip &ip, int port) { MutexSafeWrapper safeMutex(&dataSynchAccessor); - err = select(sock+1, NULL, &myset, NULL, &tv); + err = select((int)sock + 1, NULL, &myset, NULL, &tv); } if (err < 0 && getLastSocketError() != PLATFORM_SOCKET_INTERRUPTED) diff --git a/source/shared_lib/sources/util/conversion.cpp b/source/shared_lib/sources/util/conversion.cpp index e50affc5..de7f2eec 100644 --- a/source/shared_lib/sources/util/conversion.cpp +++ b/source/shared_lib/sources/util/conversion.cpp @@ -104,7 +104,7 @@ string boolToStr(bool b){ } } -string intToStr(int i){ +string intToStr(int64 i){ char str[strSize]=""; sprintf(str, "%d", i); return str; diff --git a/source/shared_lib/sources/xml/xml_parser.cpp b/source/shared_lib/sources/xml/xml_parser.cpp index cd302dcd..3d4cf941 100644 --- a/source/shared_lib/sources/xml/xml_parser.cpp +++ b/source/shared_lib/sources/xml/xml_parser.cpp @@ -41,7 +41,7 @@ public: char msgStr[strSize], fileStr[strSize]; XMLString::transcode(domError.getMessage(), msgStr, strSize-1); XMLString::transcode(domError.getLocation()->getURI(), fileStr, strSize-1); - int lineNumber= domError.getLocation()->getLineNumber(); + XMLFileLoc lineNumber= domError.getLocation()->getLineNumber(); throw runtime_error("Error parsing XML, file: " + string(fileStr) + ", line: " + intToStr(lineNumber) + ": " + string(msgStr)); } return true; @@ -54,23 +54,23 @@ public: bool XmlIo::initialized= false; -XmlIo::XmlIo(){ +XmlIo::XmlIo() { try{ XMLPlatformUtils::Initialize(); } catch(const XMLException &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error initializing XML system\n",__FILE__,__FUNCTION__,__LINE__); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error initializing XML system, msg %s\n",__FILE__,__FUNCTION__,__LINE__,e.getMessage()); throw runtime_error("Error initializing XML system"); } - try{ + try { XMLCh str[strSize]; XMLString::transcode("LS", str, strSize-1); implementation = DOMImplementationRegistry::getDOMImplementation(str); } - catch(const DOMException &ex){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while creating XML parser\n",__FILE__,__FUNCTION__,__LINE__); + catch(const DOMException &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while creating XML parser, msg: %s\n",__FILE__,__FUNCTION__,__LINE__,ex.getMessage()); throw runtime_error("Exception while creating XML parser"); } }