diff --git a/code/nel/include/nel/net/message.h b/code/nel/include/nel/net/message.h index ee70eea82..608c24076 100644 --- a/code/nel/include/nel/net/message.h +++ b/code/nel/include/nel/net/message.h @@ -52,6 +52,13 @@ public: LongFormat : 1, // true if the message format is long (d'ho ? all message are long !?!, always true) MessageType : 2; // type of the message (from TMessageType), classical message are 'OneWay' + TFormat() + { + StringMode = 0; + LongFormat = 0; + MessageType = 0; + } + void serial(NLMISC::IStream &s) { if (s.isReading()) diff --git a/code/nel/src/3d/lighting_manager.cpp b/code/nel/src/3d/lighting_manager.cpp index 33f7cb08a..95e769ee1 100644 --- a/code/nel/src/3d/lighting_manager.cpp +++ b/code/nel/src/3d/lighting_manager.cpp @@ -486,6 +486,7 @@ void CLightingManager::computeModelLightContributions(NLMISC::CRGBA sunAmbient, v= NLMISC::OptFastFloor(mergedAmbient.R); fastClamp8(v); amb.R= v; v= NLMISC::OptFastFloor(mergedAmbient.G); fastClamp8(v); amb.G= v; v= NLMISC::OptFastFloor(mergedAmbient.B); fastClamp8(v); amb.B= v; + amb.R = 255; lightContrib.MergedPointLight= amb; // Indicate we use the merged pointLight => the model must recompute lighting each frame diff --git a/code/nel/src/3d/mrm_builder.cpp b/code/nel/src/3d/mrm_builder.cpp index 640aee743..233c1dc50 100644 --- a/code/nel/src/3d/mrm_builder.cpp +++ b/code/nel/src/3d/mrm_builder.cpp @@ -136,7 +136,7 @@ float CMRMBuilder::getDeltaFaceNormals(sint numvertex) // return a positive value of Somme(|DeltaNormals|) / NNormals. CMRMVertex &vert= TmpVertices[numvertex]; float delta=0; - CVector refNormal; + CVector refNormal(0.f, 0.f, 0.f); sint nfaces=(sint)vert.SharedFaces.size(); for(sint i=0;i &leaves, { CMatrix instanceMatrix; igs[k]->getInstanceMatrix(l, instanceMatrix); - if (NLMISC::strlwr(NLMISC::CFile::getExtension(igs[k]->getShapeName(l))) == "pacs_prim") continue; + if (NLMISC::toLower(NLMISC::CFile::getExtension(igs[k]->getShapeName(l))) == "pacs_prim") continue; std::string stdShapeName = standardizeShapeName(igs[k]->getShapeName(l)); TShapeCache::const_iterator it = shapeCache.find(stdShapeName); if (it != shapeCache.end()) diff --git a/code/nel/src/3d/shape_info.cpp b/code/nel/src/3d/shape_info.cpp index 743cb936a..76aa3d195 100644 --- a/code/nel/src/3d/shape_info.cpp +++ b/code/nel/src/3d/shape_info.cpp @@ -226,7 +226,7 @@ void CShapeInfo::build(const CMeshBase &meshBase, const CMeshMRMGeom &meshGeom) // *************************************************************************** std::string standardizeShapeName(const std::string &name) { - std::string result = NLMISC::strlwr(name); + std::string result = NLMISC::toLower(name); if (CFile::getExtension(result).empty()) { result += ".shape"; diff --git a/code/nel/src/misc/buf_fifo.cpp b/code/nel/src/misc/buf_fifo.cpp index 5c6624213..94faf8d22 100644 --- a/code/nel/src/misc/buf_fifo.cpp +++ b/code/nel/src/misc/buf_fifo.cpp @@ -558,25 +558,25 @@ void CBufFIFO::display () { if (_Rewinder != NULL && _Rewinder >= pos && _Rewinder < pos + gran) { - strncat (str, "*", 1024); + strncat (str, "*", 1); } else { - strncat (str, "@", 1024); + strncat (str, "@", 1); } } else { - strncat (str, "T", 1024); + strncat (str, "T", 1); } } else if (_Head >= pos && _Head < pos + gran) { - strncat (str, "H", 1024); + strncat (str, "H", 1); } else if (_Rewinder != NULL && _Rewinder >= pos && _Rewinder < pos + gran) { - strncat (str, "R", 1024); + strncat (str, "R", 1); } else { @@ -595,12 +595,12 @@ void CBufFIFO::display () for (; i < s; i+= gran) { - strncat (str, " ", 1024); + strncat (str, " ", 1); } #ifdef NL_DEBUG - strncat (str, "\n", 1024); + strncat (str, "\n", 1); #else - strncat (str, "\r", 1024); + strncat (str, "\r", 1); #endif DebugLog->display (str); } diff --git a/code/nel/src/misc/eid_translator.cpp b/code/nel/src/misc/eid_translator.cpp index c5b1bcff8..3d1a81bf1 100644 --- a/code/nel/src/misc/eid_translator.cpp +++ b/code/nel/src/misc/eid_translator.cpp @@ -440,7 +440,7 @@ void cbInvalidEntityNamesFilename(const std::string &invalidEntityNamesFilename) for(;;) { char str[512]; - if (fgets(str, 511, fp) == NULL) + if (!fgets(str, 511, fp)) break; if(feof(fp)) break; diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 01e0404d0..09cebbaa6 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1523,13 +1523,13 @@ void CFileContainer::removeBigFiles(const std::vector &bnpFilenames TFiles::iterator fileIt, fileCurrIt; for (uint k = 0; k < bnpFilenames.size(); ++k) { - std::string completeBNPName = strlwr(bnpFilenames[k]) + "@"; + std::string completeBNPName = toLower(bnpFilenames[k]) + "@"; if (SSMpath.isAdded(completeBNPName)) { bnpStrIds.insert(SSMpath.add(completeBNPName)); } CBigFile::getInstance().remove(bnpFilenames[k]); - fileIt = _Files.find(strlwr(bnpFilenames[k])); + fileIt = _Files.find(toLower(bnpFilenames[k])); if (fileIt != _Files.end()) { _Files.erase(fileIt); diff --git a/code/nel/src/net/buf_server.cpp b/code/nel/src/net/buf_server.cpp index e850537cc..57df165c8 100644 --- a/code/nel/src/net/buf_server.cpp +++ b/code/nel/src/net/buf_server.cpp @@ -26,6 +26,7 @@ # include #elif defined NL_OS_UNIX # include +# include # include # include #endif @@ -125,7 +126,10 @@ void CListenTask::init( uint16 port, sint32 maxExpectedBlockSize ) CServerTask::CServerTask() : NbLoop (0), _ExitRequired(false) { #ifdef NL_OS_UNIX - pipe( _WakeUpPipeHandle ); + if (pipe( _WakeUpPipeHandle ) == -1) + { + nlwarning("LNETL1: pipe() failed: code=%d '%s'", errno, strerror(errno)); + } #endif } @@ -981,7 +985,10 @@ void CServerReceiveTask::run() #if defined NL_OS_UNIX // POLL7 - nice( 2 ); // is this really useful as long as select() sleeps? + if (nice( 2 ) == -1) // is this really useful as long as select() sleeps? + { + nlwarning("LNETL1: nice() failed: code=%d '%s'", errno, strerror(errno)); + } #endif // NL_OS_UNIX // Copy of _Connections diff --git a/code/nel/src/net/stdin_monitor_thread.cpp b/code/nel/src/net/stdin_monitor_thread.cpp index 50c2f5ede..dfe24c7ab 100644 --- a/code/nel/src/net/stdin_monitor_thread.cpp +++ b/code/nel/src/net/stdin_monitor_thread.cpp @@ -79,7 +79,11 @@ namespace NLNET // get the next command from the command line char theCommand[1024] = ""; - fgets(theCommand, sizeofarray(theCommand), stdin); + if (!fgets(theCommand, sizeofarray(theCommand), stdin)) + { + nlwarning("fgets failed"); + break; + } // push the command to allow reader thread to deal with it pushCommand(theCommand); diff --git a/code/nel/src/pacs/local_retriever.h b/code/nel/src/pacs/local_retriever.h index 2f794f47a..a5e78bda1 100644 --- a/code/nel/src/pacs/local_retriever.h +++ b/code/nel/src/pacs/local_retriever.h @@ -208,6 +208,9 @@ public: _Retriever = retriever; _Chain = uint16(chain); _OChainIndex = 0; + _IndexInOChain = 0; + _MaxIndexInOChain = 0; + _OChainForward = 0; setupIndex(); } diff --git a/code/nel/src/sound/driver/music_buffer_vorbis.cpp b/code/nel/src/sound/driver/music_buffer_vorbis.cpp index a02226046..3624f98d7 100644 --- a/code/nel/src/sound/driver/music_buffer_vorbis.cpp +++ b/code/nel/src/sound/driver/music_buffer_vorbis.cpp @@ -87,7 +87,7 @@ static ov_callbacks OV_CALLBACKS_NLMISC_STREAM = { }; CMusicBufferVorbis::CMusicBufferVorbis(NLMISC::IStream *stream, bool loop) -: _Stream(stream), _Loop(loop), _StreamSize(0), _IsMusicEnded(false) +: _Stream(stream), _Loop(loop), _IsMusicEnded(false) { _StreamOffset = stream->getPos(); stream->seek(0, NLMISC::IStream::end); diff --git a/code/nel/tools/3d/build_clodtex/main.cpp b/code/nel/tools/3d/build_clodtex/main.cpp index f92a0c703..d92a8f7d2 100644 --- a/code/nel/tools/3d/build_clodtex/main.cpp +++ b/code/nel/tools/3d/build_clodtex/main.cpp @@ -212,10 +212,8 @@ int main(int argc, char *argv[]) for(j=0;j &D FILE *f = fopen (ScriptName,"rb"); fseek (f, 0, SEEK_END); - int file_size = ftell (f); + sint file_size = ftell (f); fseek (f, 0, SEEK_SET); char *file_buf = (char*)malloc(file_size+1); - fread (file_buf, 1, file_size, f); + if (fread (file_buf, 1, file_size, f) != file_size) + nlwarning("Can't read %d elements", file_size); + file_buf[file_size] = 0; ++file_size; fclose (f); char *buf_ptr = file_buf; - int nLastNbPlus = 0; + sint nLastNbPlus = 0; vector pile; pile.clear (); do { char Line[256], *line_ptr; - int nNbPlus = 0; + sint nNbPlus = 0; line_ptr = &Line[0]; buf_ptr = readLine (line_ptr, buf_ptr); diff --git a/code/nel/tools/3d/crash_log_analyser/main.cpp b/code/nel/tools/3d/crash_log_analyser/main.cpp index 592f09e19..8073aa08e 100644 --- a/code/nel/tools/3d/crash_log_analyser/main.cpp +++ b/code/nel/tools/3d/crash_log_analyser/main.cpp @@ -298,8 +298,7 @@ void statRyzomBug(const char *dirSrc) } else if(str.compare(0, nel3dIdTok.size(), nel3dIdTok)==0) { - string tmp= str; - strlwr(tmp); + string tmp= toLower(str); if(tmp.find("opengl")!=string::npos) precNel3DMode= 0; else if(tmp.find("direct3d")!=string::npos) diff --git a/code/nel/tools/3d/ig_info/ig_info.cpp b/code/nel/tools/3d/ig_info/ig_info.cpp index 0e47775cb..8de0bcf19 100644 --- a/code/nel/tools/3d/ig_info/ig_info.cpp +++ b/code/nel/tools/3d/ig_info/ig_info.cpp @@ -66,8 +66,8 @@ int main(int argc, char **argv) printf("---------\n"); // IGSurfaceLight info. const CIGSurfaceLight::TRetrieverGridMap &rgm= ig.getIGSurfaceLight().getRetrieverGridMap(); - printf("IGSurfaceLighting: CellSize: %f. NumGridRetriever: %d\n", - ig.getIGSurfaceLight().getCellSize(), rgm.size() ); + printf("IGSurfaceLighting: CellSize: %f. NumGridRetriever: %u\n", + ig.getIGSurfaceLight().getCellSize(), (uint)rgm.size() ); uint rgmInst= 0; uint totalCells= 0; CIGSurfaceLight::TRetrieverGridMap::const_iterator it= rgm.begin(); @@ -85,6 +85,6 @@ int main(int argc, char **argv) } catch (std::exception &e) { - printf(e.what()); + printf("%s\n", e.what()); } } diff --git a/code/nel/tools/3d/ig_lighter/ig_lighter.cpp b/code/nel/tools/3d/ig_lighter/ig_lighter.cpp index bc00ba718..f1c30fc20 100644 --- a/code/nel/tools/3d/ig_lighter/ig_lighter.cpp +++ b/code/nel/tools/3d/ig_lighter/ig_lighter.cpp @@ -83,8 +83,7 @@ public: for (i=(uint)strlen(msg); i<79; i++) msg[i]=' '; msg[i]=0; - printf (msg); - printf ("\r"); + printf ("%s\r", msg); } protected: diff --git a/code/nel/tools/3d/lightmap_optimizer/main.cpp b/code/nel/tools/3d/lightmap_optimizer/main.cpp index 293f34ac7..c62501b4e 100644 --- a/code/nel/tools/3d/lightmap_optimizer/main.cpp +++ b/code/nel/tools/3d/lightmap_optimizer/main.cpp @@ -413,7 +413,7 @@ int main(int nNbArg, char **ppArgs) CTextureFile *pTF = dynamic_cast(pIT); if (pTF != NULL) { - string sTexName = NLMISC::strlwr(pTF->getFileName()); + string sTexName = NLMISC::toLower(pTF->getFileName()); if(pTF->getUploadFormat()==ITexture::Luminance) setLM8Bit.insert(sTexName); } @@ -462,7 +462,7 @@ int main(int nNbArg, char **ppArgs) tmpLMs.clear(); for (i = 0; i < (sint32)AllLightmapNames.size(); ++i) { - bool lm8Bit= setLM8Bit.find( NLMISC::strlwr(AllLightmapNames[i]) ) !=setLM8Bit.end(); + bool lm8Bit= setLM8Bit.find( NLMISC::toLower(AllLightmapNames[i]) ) !=setLM8Bit.end(); // if same mode if( lm8Bit == (lmc8bitMode==1) ) { @@ -756,13 +756,13 @@ int main(int nNbArg, char **ppArgs) CTextureFile *pTF = dynamic_cast(pIT); if (pTF != NULL) { - string sTexName = NLMISC::strlwr(getBaseName(pTF->getFileName())); - string sTexNameMoved = NLMISC::strlwr(getBaseName(AllLightmapNames[i])); + string sTexName = NLMISC::toLower(getBaseName(pTF->getFileName())); + string sTexNameMoved = NLMISC::toLower(getBaseName(AllLightmapNames[i])); if (sTexName == sTexNameMoved) { // We must remap the name and indicate to remap uvs bMustRemapUV = true; - //string sNewTexName = NLMISC::strlwr(getBaseName(AllLightmapNames[j])); + //string sNewTexName = NLMISC::toLower(getBaseName(AllLightmapNames[j])); //sNewTexName += NLMISC::toString(getLayerNb(pTF->getFileName())) + ".tga"; //pTF->setFileName (sNewTexName); } @@ -823,11 +823,11 @@ int main(int nNbArg, char **ppArgs) CTextureFile *pTF = dynamic_cast(pIT); if (pTF != NULL) { - string sTexName = NLMISC::strlwr(getBaseName(pTF->getFileName())); - string sTexNameMoved = NLMISC::strlwr(getBaseName(AllLightmapNames[i])); + string sTexName = NLMISC::toLower(getBaseName(pTF->getFileName())); + string sTexNameMoved = NLMISC::toLower(getBaseName(AllLightmapNames[i])); if (sTexName == sTexNameMoved) { - string sNewTexName = NLMISC::strlwr(getBaseName(AllLightmapNames[j])); + string sNewTexName = NLMISC::toLower(getBaseName(AllLightmapNames[j])); sNewTexName += NLMISC::toString(getLayerNb(pTF->getFileName())) + ".tga"; pTF->setFileName (sNewTexName); } diff --git a/code/nel/tools/3d/object_viewer/object_viewer.cpp b/code/nel/tools/3d/object_viewer/object_viewer.cpp index 5efa70010..322e6b7c4 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer/object_viewer.cpp @@ -3703,7 +3703,7 @@ void CObjectViewer::shootScene() string extension = NLMISC::CFile::getExtension ((const char*)fileDlg.GetPathName ()); // The file name without extension - bool jpeg = strlwr (extension) == "jpg"; + bool jpeg = toLower (extension) == "jpg"; // Activate the driver CNELU::Driver->activate (); diff --git a/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp b/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp index 8d4612da1..836f120e4 100644 --- a/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/snapshot_tool_dlg.cpp @@ -454,7 +454,7 @@ void CSnapshotToolDlg::OnGo() CString wildCard; m_Filters.GetText(l, wildCard); wildCard.MakeLower(); - if (testWildCard(strlwr(NLMISC::CFile::getFilename(files[k]).c_str()), (LPCTSTR) wildCard)) + if (testWildCard(toLower(NLMISC::CFile::getFilename(files[k])).c_str(), (LPCTSTR) wildCard)) { _FilteredFiles.push_back(files[k]); break; diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp index f6d523e6a..0e61183c2 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.cpp @@ -1220,7 +1220,7 @@ void VertexPaintData::SynchVerts(Mesh &m) } else - assert(0); + nlassert(0); } } } @@ -1293,7 +1293,7 @@ void VertexPaintRestore::Restore(int isUndo) { if(isUndo) { - assert(pPaintData->colordata); + nlassert(pPaintData->colordata); redoColordata = pPaintData->colordata; redonumcolors = pPaintData->numColors; @@ -1310,7 +1310,7 @@ void VertexPaintRestore::Restore(int isUndo) void VertexPaintRestore::Redo() { - assert(pPaintData->colordata); + nlassert(pPaintData->colordata); colordata = pPaintData->colordata; numcolors = pPaintData->numColors; diff --git a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp index 75f7aef18..2585e762b 100644 --- a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp +++ b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp @@ -877,7 +877,8 @@ bool ShapesExporter::createThumbnail(const string &filename, const string &path) if(fp) { char str[100]; - fgets(str, 100, fp); + if (!fgets(str, 100, fp)) + strcpy(str, "0"); fclose(fp); selectedFrame = atoi(str)/2; } diff --git a/code/nel/tools/3d/zone_dependencies/zone_dependencies.cpp b/code/nel/tools/3d/zone_dependencies/zone_dependencies.cpp index 504058f07..51714eb98 100644 --- a/code/nel/tools/3d/zone_dependencies/zone_dependencies.cpp +++ b/code/nel/tools/3d/zone_dependencies/zone_dependencies.cpp @@ -82,8 +82,7 @@ void progress (const char *message, float progress) for (i=(uint)strlen(msg); i<79; i++) msg[i]=' '; msg[i]=0; - printf (msg); - printf ("\r"); + printf ("%s\r", msg); } class CZoneDependencies @@ -523,7 +522,7 @@ int main (int argc, char* argv[]) // Write the dependencies file FILE *outputFile; - if ((outputFile=fopen (strlwr (outputFileName).c_str(), "w"))) + if ((outputFile=fopen (toLower (outputFileName).c_str(), "w"))) { // Add a dependency entry fprintf (outputFile, "dependencies =\n{\n"); @@ -538,7 +537,7 @@ int main (int argc, char* argv[]) // Write it string message="\t\""+zoneName+"\""; - fprintf (outputFile, strlwr (message).c_str()); + fprintf (outputFile, "%s", toLower (message).c_str()); // Next ite; ite++; @@ -705,7 +704,7 @@ static void computeIGBBox(const NL3D::CInstanceGroup &ig, CLightingBBox &result, static void computeZoneIGBBox(const char *zoneName, CLightingBBox &result, TShapeMap &shapeMap, const TString2LightingBBox &additionnalIG) { result = CLightingBBox(); // starts with a void box - std::string lcZoneName = NLMISC::strlwr(std::string(zoneName)); + std::string lcZoneName = NLMISC::toLower(std::string(zoneName)); TString2LightingBBox::const_iterator zoneIt = additionnalIG.find(lcZoneName); if (zoneIt != additionnalIG.end()) { @@ -895,7 +894,7 @@ static void computeIGBBoxFromContinent(NLMISC::CConfigFile ¶meter, nlwarning("Couldn't get zone name of village %d in continent %s", continentName.c_str(), k); continue; } - zoneName = NLMISC::strlwr(CFile::getFilenameWithoutExtension(zoneName)); + zoneName = NLMISC::toLower(CFile::getFilenameWithoutExtension(zoneName)); CLightingBBox result; // ok, it is in the dependant zones computeBBoxFromVillage(currVillage, continentName, k, shapeMap, result); diff --git a/code/nel/tools/3d/zone_ig_lighter/zone_ig_lighter.cpp b/code/nel/tools/3d/zone_ig_lighter/zone_ig_lighter.cpp index 61ae5b388..bdf564a66 100644 --- a/code/nel/tools/3d/zone_ig_lighter/zone_ig_lighter.cpp +++ b/code/nel/tools/3d/zone_ig_lighter/zone_ig_lighter.cpp @@ -75,11 +75,10 @@ class CMyIgZoneLighter : public CInstanceLighter pgId= min(pgId, (uint)(BAR_LENGTH-1)); sprintf (msg, "\r%s: %s", message, progressbar[pgId]); uint i; - for (i=strlen(msg); i<79; i++) + for (i=(uint)strlen(msg); i<79; i++) msg[i]=' '; msg[i]=0; - printf (msg); - printf ("\r"); + printf ("%s\r", msg); } }; @@ -114,7 +113,7 @@ int main(int argc, char* argv[]) if (inputFile.open (argv[1])) { // Zone name - string zoneName=strlwr (string ("zone_"+getName (argv[1]))); + string zoneName=toLower (string ("zone_"+getName (argv[1]))); // Load the zone try diff --git a/code/nel/tools/3d/zone_lighter/zone_lighter.cpp b/code/nel/tools/3d/zone_lighter/zone_lighter.cpp index 20df515bd..6df94365d 100644 --- a/code/nel/tools/3d/zone_lighter/zone_lighter.cpp +++ b/code/nel/tools/3d/zone_lighter/zone_lighter.cpp @@ -85,8 +85,7 @@ class CMyZoneLighter : public CZoneLighter for (i=strlen(msg); i<79; i++) msg[i]=' '; msg[i]=0; - printf (msg); - printf ("\r"); + printf ("%s\r", msg); } }; @@ -138,7 +137,7 @@ static void loadIGFromVillage(const NLGEORGES::UFormElm *villageItem, const std: // verify that the ig is not already added (case of tr_water.ig in additional_igs) for(uint igAdd= 0;igAdd<(uint)additionalIgNames.size();igAdd++) { - if( strlwr(additionalIgNames.asString()) == strlwr(igName) ) + if( toLower(additionalIgNames.asString()) == toLower(igName) ) { nlwarning("Skipping Village Ig %s, cause already exist in additional ig", igName.c_str()); continue; @@ -313,7 +312,7 @@ int main(int argc, char* argv[]) if (inputFile.open (argv[1])) { // Zone name - string zoneName=strlwr (string ("zone_"+getName (argv[1]))); + string zoneName=toLower (string ("zone_"+getName (argv[1]))); // Load the zone try @@ -701,7 +700,7 @@ int main(int argc, char* argv[]) continue; // PS ? - if (strlwr (CFile::getExtension (name)) == "ps") + if (toLower (CFile::getExtension (name)) == "ps") continue; // Add a .shape at the end ? diff --git a/code/nel/tools/3d/zone_welder/zone_welder.cpp b/code/nel/tools/3d/zone_welder/zone_welder.cpp index 59ab33972..028549cff 100644 --- a/code/nel/tools/3d/zone_welder/zone_welder.cpp +++ b/code/nel/tools/3d/zone_welder/zone_welder.cpp @@ -346,7 +346,7 @@ void weldZones(const char *center) } } - fprintf(fdbg,"(before) zone %d bordervertices size : %d\n",i,adjZoneBorderVertices.size()); + fprintf(fdbg,"(before) zone %u bordervertices size : %u\n",i,(uint)adjZoneBorderVertices.size()); // delete border vertices of the adjacent zone if their neighbour zoneId // is equal to current zone zoneId @@ -360,7 +360,7 @@ void weldZones(const char *center) else itborder++; } - fprintf(fdbg,"(after) zone %d bordervertices size : %d\n",i,adjZoneBorderVertices.size()); + fprintf(fdbg,"(after) zone %u bordervertices size : %u\n",i,(uint)adjZoneBorderVertices.size()); // A set for storing base vertex index already added in the quad tree std::set adjBaseVertexIndexSet; diff --git a/code/nel/tools/3d/zviewer/zviewer.cpp b/code/nel/tools/3d/zviewer/zviewer.cpp index 1250aac38..01a1c36c1 100644 --- a/code/nel/tools/3d/zviewer/zviewer.cpp +++ b/code/nel/tools/3d/zviewer/zviewer.cpp @@ -447,12 +447,9 @@ void displayZones() } catch(Exception &e) { - printf(e.what ()); + printf("%s\n", e.what ()); } } - - - // Load instance group. CNELU::clearBuffers(CRGBA(0,0,0)); @@ -472,7 +469,7 @@ void displayZones() } catch(Exception &e) { - printf(e.what ()); + printf("%s\n", e.what ()); } } diff --git a/code/nel/tools/all.sln b/code/nel/tools/all.sln index 044f17c1a..2409e840c 100644 --- a/code/nel/tools/all.sln +++ b/code/nel/tools/all.sln @@ -401,6 +401,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_exporter", "3d\shape EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "georges2csv", "georges\georges2csv\georges2csv.vcproj", "{885542B1-BE3C-401A-A2A4-DA49E48DF0AB}" + ProjectSection(ProjectDependencies) = postProject + {44B21233-EFCC-4825-B5E5-3A3BD6CC5516} = {44B21233-EFCC-4825-B5E5-3A3BD6CC5516} + {9D284C6B-BE12-4549-87E5-2337D64F31BE} = {9D284C6B-BE12-4549-87E5-2337D64F31BE} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/code/nel/tools/georges/georges2csv/georges2csv.cpp b/code/nel/tools/georges/georges2csv/georges2csv.cpp index 6a4e6ce5a..826299455 100644 --- a/code/nel/tools/georges/georges2csv/georges2csv.cpp +++ b/code/nel/tools/georges/georges2csv/georges2csv.cpp @@ -44,13 +44,14 @@ #include "nel/georges/u_form_loader.h" #include "nel/georges/load_form.h" // Georges, bypassing interface -#include "georges/stdgeorges.h" -#include "georges/form.h" +#include "../../../src/georges/stdgeorges.h" +#include "../../../src/georges/form.h" // Basic C++ #include //#include #include +#include //#include // stl @@ -695,14 +696,18 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType return; } + if (!fgets(lineBuffer, BUFFER_SIZE, s)) + { + nlwarning("fgets() failed"); + return; + } + loadSheetPath(); UFormLoader *formLoader = UFormLoader::createLoader (); NLMISC::CSmartPtr form; NLMISC::CSmartPtr formDfn; - - fgets(lineBuffer, BUFFER_SIZE, s); explode(std::string(lineBuffer), std::string(SEPARATOR), fields); vector activeFields( fields.size(), true ); @@ -728,7 +733,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType } else if ( nlstricmp( fields[i], "parent" ) == 0 ) { - strlwr( fields[i] ); // non-const version + fields[i] = toLower( fields[i] ); } else { @@ -748,7 +753,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType } string addExtension = "." + sheetType; - uint dirmapLetterIndex = ~0; + uint dirmapLetterIndex = std::numeric_limits::max(); bool dirmapLetterBackward = false; vector dirmapDirs; string dirmapSheetCode; @@ -812,7 +817,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType nlinfo( "Sheet code: %s", dirmapSheetCode.c_str() ); if ( ! dirmapLetterBackward ) - dirmapLetterIndex += dirmapSheetCode.size(); + dirmapLetterIndex += (uint)dirmapSheetCode.size(); CConfigFile::CVar *wep = dirmapcfg.getVarPtr( "WriteEmptyProperties" ); if ( wep ) @@ -849,7 +854,12 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType while (!feof(s)) { lineBuffer[0] = '\0'; - fgets(lineBuffer, BUFFER_SIZE, s); + if (!fgets(lineBuffer, BUFFER_SIZE, s)) + { + nlwarning("fgets() failed"); + break; + } + explode(std::string(lineBuffer), std::string(SEPARATOR), args); if (args.size() < 1) @@ -868,7 +878,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType { filebase += "." + sheetType; } - strlwr (filebase); + filebase = toLower(filebase); string filename, dirbase; bool isNewSheet=true; @@ -890,7 +900,7 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType else { // Load template sheet - filename = strlwr( static_cast(filebase) ); + filename = toLower(filebase); form = (CForm*)formLoader->loadForm( (string("_empty.") + sheetType).c_str() ); if (form == NULL) { @@ -898,14 +908,14 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType } // Deduce directory from sheet name - if ( dirmapLetterIndex != ~0 ) + if ( dirmapLetterIndex != std::numeric_limits::max() ) { if ( dirmapLetterIndex < filebase.size() ) { uint letterIndex; char c; if ( dirmapLetterBackward ) - letterIndex = filebase.size() - 1 - (CFile::getExtension( filebase ).size()+1) - dirmapLetterIndex; + letterIndex = (uint)(filebase.size() - 1 - (CFile::getExtension( filebase ).size()+1)) - dirmapLetterIndex; else letterIndex = dirmapLetterIndex; c = tolower( filebase[letterIndex] ); diff --git a/code/nel/tools/misc/bnp_make/main.cpp b/code/nel/tools/misc/bnp_make/main.cpp index d2a64b2c7..952616aa9 100644 --- a/code/nel/tools/misc/bnp_make/main.cpp +++ b/code/nel/tools/misc/bnp_make/main.cpp @@ -39,7 +39,7 @@ bool keepFile (const char *fileName) uint i; bool ifPresent = false; bool ifTrue = false; - string file = strlwr(CFile::getFilename (fileName)); + string file = toLower(CFile::getFilename (fileName)); for (i=0; i +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + // data_mirror.cpp : Defines the class behaviors for the application. // @@ -89,21 +105,21 @@ BOOL CData_mirrorApp::InitInstance() cf.load (path); MainDirectory = cf.getVar ("MainDirectory").asString (); - MainDirectory = strlwr (CPath::standardizePath (MainDirectory)); + MainDirectory = toLower (CPath::standardizePath (MainDirectory)); MirrorDirectory = cf.getVar ("MirrorDirectory").asString (); - MirrorDirectory = strlwr (CPath::standardizePath (MirrorDirectory)); + MirrorDirectory = toLower (CPath::standardizePath (MirrorDirectory)); LogDirectory = cf.getVar ("LogDirectory").asString (); - LogDirectory = strlwr (CPath::standardizePath (LogDirectory)); + LogDirectory = toLower (CPath::standardizePath (LogDirectory)); IgnoreDirectory = cf.getVar ("IgnoreDirectory").asString (); - IgnoreDirectory = strlwr (CPath::standardizePath (IgnoreDirectory)); + IgnoreDirectory = toLower (CPath::standardizePath (IgnoreDirectory)); if (IgnoreDirectory.empty()) IgnoreDirectory = MainDirectory; string sBinaryCompare = cf.getVar ("BinaryCompare").asString (); - sBinaryCompare = strlwr (sBinaryCompare); + sBinaryCompare = toLower (sBinaryCompare); BinaryCompare = false; if ((sBinaryCompare == "true") || (sBinaryCompare=="1")) BinaryCompare = true; @@ -126,12 +142,12 @@ BOOL CData_mirrorApp::InitInstance() if (NLMISC::CFile::isDirectory (CurrentDir)) { directory = true; - CurrentDir = strlwr (CPath::standardizePath (CurrentDir)); + CurrentDir = toLower(CPath::standardizePath (CurrentDir)); } else if (NLMISC::CFile::fileExists (CurrentDir)) { directory = false; - CurrentDir = strlwr (CPath::standardizePath (NLMISC::CFile::getPath (CurrentDir))); + CurrentDir = toLower(CPath::standardizePath (NLMISC::CFile::getPath (CurrentDir))); } else { diff --git a/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp b/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp index 4ae3b1fdc..e614be89e 100644 --- a/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp +++ b/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp @@ -1,5 +1,18 @@ -// data_mirrorDlg.cpp : implementation file +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited // +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #include "stdafx.h" #include "data_mirror.h" @@ -600,8 +613,7 @@ void CData_mirrorDlg::buildSourceFiles () { // Get the filename string &str = fileSource[i]; - str = strlwr (str); - str = str.substr (MainDirectory.size (), str.size ()); + str = toLower(str.substr (MainDirectory.size (), str.size ())); // In the ignore list ? if (IgnoreFiles.find (str) == IgnoreFiles.end () && (str != "ignore_list.txt")) @@ -689,8 +701,7 @@ void CData_mirrorDlg::buildSourceFiles () { // Get the filename string &str = fileSource[i]; - str = strlwr (str); - str = str.substr (MirrorDirectory.size (), str.size ()); + str = toLower(str.substr (MirrorDirectory.size (), str.size ())); // In the ignore list ? if (IgnoreFiles.find (str) == IgnoreFiles.end () && (str != "ignore_list.txt")) diff --git a/code/nel/tools/misc/extract_filename/extract_filename.cpp b/code/nel/tools/misc/extract_filename/extract_filename.cpp index 926ac359c..a6844be0f 100644 --- a/code/nel/tools/misc/extract_filename/extract_filename.cpp +++ b/code/nel/tools/misc/extract_filename/extract_filename.cpp @@ -23,7 +23,11 @@ using namespace NLMISC; #ifdef NL_DEBUG #define INFO nlinfo #else // NL_DEBUG -#define INFO ((void)0) +# if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) +# define INFO __noop +# else +# define INFO 0&& +# endif #endif // NL_DEBUG bool readTheFile (const char *filename, vector &fileArray) @@ -207,7 +211,7 @@ void extractStringsFromBinary (const vector &fileArray, set &filen if (str != "") { // Lower case - str = strlwr (str); + str = toLower (str); // Filter extensions if (filterExtension (str.c_str(), extensions)) @@ -273,7 +277,7 @@ void extractStringsFromASCII (const vector &fileArray, set &filena temp[c] = begin[c]; // Lower case - temp = strlwr (temp); + temp = toLower (temp); // Filter extensions if (filterExtension (temp.c_str(), extensions)) @@ -317,15 +321,12 @@ bool loadConfigFiles (const char *ext, const char *input_files, const char *avai char name[512]; while (fgets (name, 512, file)) { - // To string - temp = name; + // To string and lower + temp = toLower (string(name)); // Remove return removeChar (temp, '\n'); - // Lower - strlwr (temp); - // Valid extension ? if (temp.size() && temp[0] == '.') // Add the extension @@ -369,12 +370,9 @@ bool loadConfigFiles (const char *ext, const char *input_files, const char *avai char name[512]; while (fgets (name, 512, file)) { - temp = name; - temp2 = name; - // To lower - temp = strlwr (temp); - temp2 = strlwr (temp2); + temp = toLower (string(name)); + temp2 = toLower (string(name)); // Remove space removeBeginEndSpaces (temp); @@ -596,7 +594,7 @@ int main(int argc, char* argv[]) // It is used ? if (usedFiles.find (available->first) == usedFiles.end()) { - string temp = strlwr (available->second.c_str()); + string temp = toLower (available->second); fprintf (stderr, "UNUSED: %s\n", temp.c_str()); } @@ -610,7 +608,7 @@ int main(int argc, char* argv[]) } else { - printf ("extract_filename.exe [extensions.txt] [inputFiles.txt] [availableFiles.txt]\n"); + printf ("extract_filename [extensions.txt] [inputFiles.txt] [availableFiles.txt]\n"); } return 0; } diff --git a/code/nel/tools/misc/xml_packer/xml_packer.cpp b/code/nel/tools/misc/xml_packer/xml_packer.cpp index f6f806e69..3e96f4615 100644 --- a/code/nel/tools/misc/xml_packer/xml_packer.cpp +++ b/code/nel/tools/misc/xml_packer/xml_packer.cpp @@ -326,31 +326,36 @@ int main(int argc, char *argv[]) // read the first line char buffer[MaxLineSize]; - fgets(buffer, MaxLineSize, fp); - linecount++; - if (strcmp(buffer, "\n") != 0) + if (!fgets(buffer, MaxLineSize, fp) || strcmp(buffer, "\n") != 0) { printf ("Error : invalid pack file '%s'\n", filename.c_str()); - exit(-1); + return -1; } - + + linecount++; + char *result = NULL; do { // read a file line - fgets(buffer, MaxLineSize, fp); - CSString parser(buffer); linecount++; + if (!fgets(buffer, MaxLineSize, fp)) + { + fclose(fp); + printf ("Error : invalid pack file '%s' at line %u", filename.c_str(), linecount); + return -1; + } + CSString parser(buffer); if (parser.find(" ") == 0) - { - // end of pack file - fclose(fp); break; - } + printf ("Error : invalid pack file '%s' at line %u", filename.c_str(), linecount); - exit(-1); + return -1; } CSString subFileName = parser.leftCrop(sizeof(" IsBorder = true; - if ((oppositeSurfId != UnaffectedSurfaceId && (next == NULL || (next->SurfaceId != oppositeSurfId && next->SurfaceId != currentSurfId))) || - (oppositeSurfId == UnaffectedSurfaceId && (next != NULL && next->SurfaceId != currentSurfId || next == NULL && current->getZoneIdOnEdge(nextEdge) != oppositeZid)) || - ((current->EdgeFlag[nextEdge] || zoneTessel->VerticesFlags[current->Tri[pivot]]!=0) && !allowThis)) + if (((oppositeSurfId != UnaffectedSurfaceId) && (next == NULL || (next->SurfaceId != oppositeSurfId && next->SurfaceId != currentSurfId))) || + ((oppositeSurfId == UnaffectedSurfaceId) && ((next != NULL && next->SurfaceId != currentSurfId) || (next == NULL && current->getZoneIdOnEdge(nextEdge) != oppositeZid))) || + ((current->EdgeFlag[nextEdge] || (zoneTessel->VerticesFlags[current->Tri[pivot]]!=0)) && !allowThis)) { // if reaches the end of the border, then quits. loop = (absoluteEquals(vstore.front(), vstore.back(), 1e-2f) && loopCount != 1); @@ -1296,7 +1296,7 @@ void NLPACS::CZoneTessellation::compile() if ((bits0 & CPrimChecker::Water)!=0 || (bits1 & CPrimChecker::Water)!=0 || (bits2 & CPrimChecker::Water)!=0) { - uint ws; + uint ws = 0; uint16 ws0 = PrimChecker.index((uint)v0.x, (uint)v0.y); uint16 ws1 = PrimChecker.index((uint)v1.x, (uint)v1.y); diff --git a/code/nel/tools/pacs/build_rbank/build_surf.h b/code/nel/tools/pacs/build_rbank/build_surf.h index 0e8849bb5..4bf962fcc 100644 --- a/code/nel/tools/pacs/build_rbank/build_surf.h +++ b/code/nel/tools/pacs/build_rbank/build_surf.h @@ -394,7 +394,9 @@ public: void floodFill(CSurfElement *first, sint32 surfId, const A &cmp, CZoneTessellation *zoneTessel) { if (Verbose) + { nldebug("flood fill surface %d", surfId); + } std::vector stack; sint i; @@ -436,7 +438,9 @@ public: } if (Verbose) + { nldebug("%d elements added", Elements.size()); + } Center = NLMISC::CVector::Null; for (i=0; i<(sint)Elements.size(); ++i) diff --git a/code/nel/tools/pacs/build_rbank/surface_splitter.h b/code/nel/tools/pacs/build_rbank/surface_splitter.h index 3d74659a4..4af9af932 100644 --- a/code/nel/tools/pacs/build_rbank/surface_splitter.h +++ b/code/nel/tools/pacs/build_rbank/surface_splitter.h @@ -19,8 +19,8 @@ #include "nel/misc/types_nl.h" -#include "nel/../../src/pacs/local_retriever.h" -#include "nel/../../src/pacs/quad_grid.h" +#include "../../../src/pacs/local_retriever.h" +#include "../../../src/pacs/quad_grid.h" #include @@ -394,6 +394,7 @@ public: } bool operator != (const iterator &it) { return !(*this == it); } + // ++it iterator &operator ++ () { ChainVertex += ChainDirection; @@ -402,7 +403,23 @@ public: Chain += Direction; resetChain(); } - // FIXME add return value here! + + return *this; + } + + // it++ + iterator operator ++ (int) + { + iterator tmp(*this); + + ChainVertex += ChainDirection; + if (ChainVertex == 0 || ChainVertex == (sint)pChain->Vertices.size()-1) + { + Chain += Direction; + resetChain(); + } + + return tmp; } void resetChain()