From 411405feb50245796f45f103de08bb38a975da6e Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 24 Oct 2010 20:23:15 +0200 Subject: [PATCH] Changed: #825 Remove all warning when compiling Ryzom --- code/ryzom/client/src/animation_state.cpp | 2 +- .../ryzom/client/src/bg_downloader_access.cpp | 2 + code/ryzom/client/src/cdb_branch.cpp | 3 ++ code/ryzom/client/src/debug_client.cpp | 2 +- code/ryzom/client/src/http_client_curl.cpp | 5 ++ code/ryzom/client/src/impulse_decoder.cpp | 2 + code/ryzom/client/src/login.cpp | 10 ++-- code/ryzom/client/src/login_patch.cpp | 54 ++++++++++++++++--- .../client/src/login_progress_post_thread.cpp | 2 +- code/ryzom/client/src/main_loop.cpp | 2 +- code/ryzom/client/src/micro_life_manager.cpp | 4 +- .../ryzom/client/src/motion/user_controls.cpp | 9 ++++ code/ryzom/client/src/net_manager.cpp | 7 ++- code/ryzom/client/src/progress.cpp | 2 + .../ryzom/client/src/session_browser_impl.cpp | 2 +- .../client/src/string_manager_client.cpp | 2 +- .../client/src/weather_manager_client.cpp | 2 +- 17 files changed, 89 insertions(+), 23 deletions(-) diff --git a/code/ryzom/client/src/animation_state.cpp b/code/ryzom/client/src/animation_state.cpp index cd823c1cc..91bd8753a 100644 --- a/code/ryzom/client/src/animation_state.cpp +++ b/code/ryzom/client/src/animation_state.cpp @@ -275,7 +275,7 @@ CAnimation::TAnimId CAnimationState::chooseAnim(uint32 jobSpecialisation, EGSPD: else { uint i; - uint best; + uint best = 0; const uint count = (uint)_Animations.size (); double bestAng = 1000.0; // Big value to be > to the first element. for (i=0; iisVerboseLog()) { - nlinfo ("Exploded, with nl, %zu res", lines.size()); + nlinfo ("Exploded, with nl, %u res", (uint)lines.size()); /* for (uint i = 0; i < lines.size(); i++) { nlinfo (" > '%s'", lines[i].c_str()); @@ -2832,7 +2832,7 @@ string checkLogin(const string &login, const string &password, const string &cli if(lines.size() != nbs+1) { - nlwarning("bad shard lines number %zu != %d", lines.size(), nbs+1); + nlwarning("bad shard lines number %u != %d", (uint)lines.size(), nbs+1); nlwarning("'%s'", res.c_str()); return "bad lines numbers (error code 5)"; } @@ -2844,7 +2844,7 @@ string checkLogin(const string &login, const string &password, const string &cli if(pPM->isVerboseLog()) { - nlinfo ("Exploded with '%s', %zu res", "|", res.size()); + nlinfo ("Exploded with '%s', %u res", "|", (uint)res.size()); /* for (uint i = 0; i < res.size(); i++) { nlinfo (" > '%s'", res[i].c_str()); @@ -2853,7 +2853,7 @@ string checkLogin(const string &login, const string &password, const string &cli if (res.size() < 7 && res.size() > 8) { - nlwarning("bad | numbers %zu != %d", res.size(), 8); + nlwarning("bad | numbers %u != %d", (uint)res.size(), 8); nlwarning("'%s'", lines[i].c_str()); return "bad pipe numbers (error code 6)"; } diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 3a8cac886..912249d6b 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -254,7 +254,7 @@ void CPatchManager::init(const std::vector& patchURIs, const std::s } srand(NLMISC::CTime::getSecondsSince1970()); - UsedServer = rand() * (sint)PatchServers.size() / (RAND_MAX+1); + UsedServer = (sint)((float)(rand() / (RAND_MAX+1)) * (sint)PatchServers.size()); ServerPath = CPath::standardizePath (sServerPath); ServerVersion = sServerVersion; @@ -1700,29 +1700,58 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector &Fi nlfseek64 (f, 0, SEEK_END); uint32 nFileSize = NLMISC::CFile::getFileSize (SourceName); nlfseek64 (f, nFileSize-sizeof(uint32), SEEK_SET); + uint32 nOffsetFromBegining; - fread (&nOffsetFromBegining, sizeof(uint32), 1, f); - if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0) + if (fread (&nOffsetFromBegining, sizeof(uint32), 1, f) != 1) + { + fclose(f); return false; + } + + if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0) + { + fclose(f); + return false; + } uint32 nNbFile; if (fread (&nNbFile, sizeof(uint32), 1, f) != 1) + { + fclose(f); return false; + } + for (uint32 i = 0; i < nNbFile; ++i) { uint8 nStringSize; - char sName[256]; if (fread (&nStringSize, 1, 1, f) != 1) + { + fclose(f); return false; + } + + char sName[256]; if (fread (sName, 1, nStringSize, f) != nStringSize) + { + fclose(f); return false; + } sName[nStringSize] = 0; + SBNPFile tmpBNPFile; tmpBNPFile.Name = sName; if (fread (&tmpBNPFile.Size, sizeof(uint32), 1, f) != 1) + { + fclose(f); return false; + } + if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1) + { + fclose(f); return false; + } + Files.push_back (tmpBNPFile); } fclose (f); @@ -1778,7 +1807,13 @@ bool CPatchManager::bnpUnpack(const string &srcBigfile, const string &dstPath, v { nlfseek64 (bnp, rBNPFile.Pos, SEEK_SET); uint8 *ptr = new uint8[rBNPFile.Size]; - fread (ptr, rBNPFile.Size, 1, bnp); + + if (fread (ptr, rBNPFile.Size, 1, bnp) != 1) + { + fclose(out); + return false; + } + bool writeError = fwrite (ptr, rBNPFile.Size, 1, out) != 1; if (writeError) { @@ -2399,7 +2434,12 @@ void CCheckThread::run () CHashKey sha1BNPFile; nlfseek64 (bnp, rBNPFile.Pos, SEEK_SET); uint8 *pPtr = new uint8[rBNPFile.Size]; - fread (pPtr, rBNPFile.Size, 1, bnp); + if (fread (pPtr, rBNPFile.Size, 1, bnp) != 1) + { + delete [] pPtr; + break; + } + sha1BNPFile = getSHA1(pPtr, rBNPFile.Size); delete [] pPtr; CHashKey sha1RealFile = getSHA1(sRealFilename, true); @@ -3196,7 +3236,7 @@ bool CPatchManager::download(const std::string& patchFullname, const std::string pPM->deleteFile(sourceFullname); } // file will be save to a .tmp file - std::string extension = ""; + std::string extension; if (patchFullname.size() >= zsStrLength && patchFullname.substr(patchFullname.size() - zsStrLength) == zsStr) { extension = zsStr; diff --git a/code/ryzom/client/src/login_progress_post_thread.cpp b/code/ryzom/client/src/login_progress_post_thread.cpp index 9b6e351da..1c38fdd88 100644 --- a/code/ryzom/client/src/login_progress_post_thread.cpp +++ b/code/ryzom/client/src/login_progress_post_thread.cpp @@ -34,7 +34,7 @@ using namespace NLMISC; static std::string uint64ToHex(uint64 size) { char data[256]; - sprintf(data, "%llX", size); + sprintf(data, "%"NL_I64"X", size); return std::string(data); } diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index f085844dc..3e7fefdd3 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -1071,7 +1071,7 @@ void renderAll(bool forceFullDetail) uint maxFullDetailChar = Scene->getMaxSkeletonsInNotCLodForm(); UScene *skyScene = getSkyScene(); UScene::TPolygonBalancingMode oldBalancingMode = Scene->getPolygonBalancingMode(); - UScene::TPolygonBalancingMode oldSkyBalancingMode; + UScene::TPolygonBalancingMode oldSkyBalancingMode = UScene::PolygonBalancingOff; if (skyScene) { oldSkyBalancingMode = skyScene->getPolygonBalancingMode(); diff --git a/code/ryzom/client/src/micro_life_manager.cpp b/code/ryzom/client/src/micro_life_manager.cpp index 3dc00d6c0..59bfce76d 100644 --- a/code/ryzom/client/src/micro_life_manager.cpp +++ b/code/ryzom/client/src/micro_life_manager.cpp @@ -602,7 +602,7 @@ void CMicroLifeManager::tileAdded(const NL3D::CTileAddedInfo &infos) // K ^ Normal resolves to [-y x 0] // if z is near from 1.f or -1.f then no rotation is performed (because [-y x 0] tends to 0 and can't be normalized) CVector rotAxis; // rotation axis to match Z of model with normal - float angle; // angle of rotation to match Z of model with normal + float angle = 0.f; // angle of rotation to match Z of model with normal // see if want rotation if (!sfs.DontRotate) { @@ -623,7 +623,7 @@ void CMicroLifeManager::tileAdded(const NL3D::CTileAddedInfo &infos) } } - float angleAroundNormal; + float angleAroundNormal = 0.f; // see if want rotation around normal if (!sfs.DontRotateAroundLocalZ) { diff --git a/code/ryzom/client/src/motion/user_controls.cpp b/code/ryzom/client/src/motion/user_controls.cpp index d681fd9cd..0ab04ae10 100644 --- a/code/ryzom/client/src/motion/user_controls.cpp +++ b/code/ryzom/client/src/motion/user_controls.cpp @@ -247,6 +247,9 @@ void CUserControls::update() case ThirdMode: thirdMode(); break; + + default: + break; } _LastFrameForward = Actions.valide("forward") && !_NeedReleaseForward; @@ -1094,6 +1097,9 @@ void CUserControls::mode(const TMoveMode mode) case ThirdMode: thirdModeStop(); break; + + default: + break; } // Backup the last Mode. @@ -1127,6 +1133,9 @@ void CUserControls::mode(const TMoveMode mode) case ThirdMode: thirdModeStart(); break; + + default: + break; } }// mode // diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index dc9d3d756..46c7bbed9 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -881,7 +881,7 @@ void CInterfaceChatDisplayer::clearChannel(CChatGroup::TGroupType mode, uint32 d else if (mode == CChatGroup::dyn_chat) { // if correct dbIndex, clear - if(dynChatDbIndex>=0 && dynChatDbIndexrunActionHandler("r2_stop_live", NULL); break; + default: + break; } } diff --git a/code/ryzom/client/src/progress.cpp b/code/ryzom/client/src/progress.cpp index dc164ef8e..14c62795c 100644 --- a/code/ryzom/client/src/progress.cpp +++ b/code/ryzom/client/src/progress.cpp @@ -127,10 +127,12 @@ void drawLoadingBitmap (float progress) float y2 = 1; if ((ww > 1024) || (wh > 768)) + { if ((ww - 1024) > (wh - 768)) x1 = ((ww - (wh * 1024.f) / 768.f) / 2.f) / ww; else y1 = ((wh - (ww * 768.f) / 1024.f) / 2.f) / wh; + } if (x1 != 0) x2 = 1 - x1; diff --git a/code/ryzom/client/src/session_browser_impl.cpp b/code/ryzom/client/src/session_browser_impl.cpp index 692b60838..4f39db901 100644 --- a/code/ryzom/client/src/session_browser_impl.cpp +++ b/code/ryzom/client/src/session_browser_impl.cpp @@ -655,7 +655,7 @@ void CSessionBrowserImpl::charsFill(const std::vector &chars // **************************************************************************** -inline double ecoRingPoints(const std::string & ecoPoints, char * c) +inline double ecoRingPoints(const std::string & ecoPoints, const char * c) { std::string::size_type cPlace = ecoPoints.find(c); if(cPlace==string::npos) diff --git a/code/ryzom/client/src/string_manager_client.cpp b/code/ryzom/client/src/string_manager_client.cpp index 3e93c7957..90df72bec 100644 --- a/code/ryzom/client/src/string_manager_client.cpp +++ b/code/ryzom/client/src/string_manager_client.cpp @@ -1199,7 +1199,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) STRING_MANAGER::readExcelSheet(ucs, ws); // Get the Key and Data ColIndex. - uint nameColIndex, keyColIndex; + uint nameColIndex = 0, keyColIndex = 0; if( !ws.findCol(ucstring("name"), nameColIndex) ) continue; if( !ws.findCol(ucstring(specialWords[i*3+1]), keyColIndex) ) diff --git a/code/ryzom/client/src/weather_manager_client.cpp b/code/ryzom/client/src/weather_manager_client.cpp index 7ff6edfa7..fc32dae1c 100644 --- a/code/ryzom/client/src/weather_manager_client.cpp +++ b/code/ryzom/client/src/weather_manager_client.cpp @@ -604,7 +604,7 @@ void CWeatherManagerClient::updateThunder(uint64 day, float hour, const CWeather CThunderTime t1; - float manualThunderThreshold; + float manualThunderThreshold = 0.f; if (manual) { if (wc.WF)