From 2af7301d7d2991ecb689a1be29b9617aab50ac3a Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 14:34:09 +0200 Subject: [PATCH 01/60] Fixed: #1132 Set the LanguageCode when client is creating a client.cfg --- code/ryzom/client/src/client_cfg.cpp | 36 ++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 172a24817..e1e5d9c7d 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -24,6 +24,7 @@ // Misc. #include "nel/misc/config_file.h" #include "nel/misc/bit_mem_stream.h" +#include "nel/misc/i18n.h" // Client. #include "client_cfg.h" #include "entities.h" @@ -44,6 +45,8 @@ # include "config.h" #endif // HAVE_CONFIG_H +#include + /////////// // MACRO // /////////// @@ -1895,15 +1898,34 @@ void CClientConfig::init(const string &configFileName) { // create the basic .cfg that link the default one FILE *fp = fopen(configFileName.c_str(), "w"); - if (fp == NULL) + + if (fp == NULL) + { + nlerror("CFG::init: Can't create config file '%s'", configFileName.c_str()); + } + else + { + nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ()); + } + + fprintf(fp, "RootConfigFilename = \"%s\";\n", defaultConfigFileName.c_str()); + + // get current locale + std::string lang = toLower(std::string(setlocale(LC_CTYPE, ""))); + lang = lang.substr(0, 2); + + const std::vector &languages = CI18N::getLanguageCodes(); + + // search if current locale is defined in language codes + for(uint i = 0; i < languages.size(); ++i) { - nlerror ("CFG::init: Can't create config file '%s'", configFileName.c_str()); + if (lang == languages[i]) + { + fprintf(fp, "LanguageCode = \"%s\";\n", lang.c_str()); + break; + } } - else - { - nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ()); - } - fprintf(fp, "RootConfigFilename = \"%s\";\n", defaultConfigFileName.c_str()); + fclose(fp); } else From 7cbb7da54ea78b3ac02b81c11fba0aa37903cccd Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 18:58:53 +0200 Subject: [PATCH 02/60] Changed: #825 Remove all warning when compiling Ryzom --- .../ryzom/tools/leveldesign/export/export.cpp | 98 +++--- code/ryzom/tools/leveldesign/export/export.h | 18 +- .../world_editor/land_export_lib/export.cpp | 301 +++++++++--------- 3 files changed, 208 insertions(+), 209 deletions(-) diff --git a/code/ryzom/tools/leveldesign/export/export.cpp b/code/ryzom/tools/leveldesign/export/export.cpp index e2dae2bea..bb3e384f1 100644 --- a/code/ryzom/tools/leveldesign/export/export.cpp +++ b/code/ryzom/tools/leveldesign/export/export.cpp @@ -154,7 +154,7 @@ void CExport::delAllIGZoneUnderPath (float fCellSize, CPrimPath *pPath, const st vSquare[3].x = x * fCellSize; vSquare[3].y = (y+1) * fCellSize; vSquare[3].z = 0.0f; - + // Is a vertex of the path inside the zone ? for (i = 0; i < pPath->VPoints.size(); ++i) { @@ -167,7 +167,7 @@ void CExport::delAllIGZoneUnderPath (float fCellSize, CPrimPath *pPath, const st CTools::chdir (sIGOutputDir); } } - + // Is an segment of the path cut an edge of the patat ? for (i = 0; i < pPath->VPoints.size()-1; ++i) for (j = 0; j < 4; ++j) @@ -249,7 +249,7 @@ void CExport::delAllIGZoneUnderPatat (float fCellSize, CPrimZone *pPatat, const CTools::chdir (sIGOutputDir); } } - + // Is a vertex of the patat inside the zone ? for (i = 0; i < pPatat->VPoints.size(); ++i) { @@ -262,7 +262,7 @@ void CExport::delAllIGZoneUnderPatat (float fCellSize, CPrimZone *pPatat, const CTools::chdir (sIGOutputDir); } } - + // Is an edge of the zone cut an edge of the patat ? for (i = 0; i < pPatat->VPoints.size(); ++i) for (j = 0; j < 4; ++j) @@ -342,11 +342,11 @@ bool CExport::isPatatNeedUpdate (float fCellSize, CPrimZone *pPatat, const strin if (pPatat->contains(vSquare[i])) { string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist + if (!CTools::fileExist(sTmp)) // If the file does not exist return true; // need update } } - + // Is a vertex of the patat inside the zone ? for (i = 0; i < pPatat->VPoints.size(); ++i) { @@ -356,11 +356,11 @@ bool CExport::isPatatNeedUpdate (float fCellSize, CPrimZone *pPatat, const strin (pPatat->VPoints[i].y <= ((y+1)*fCellSize))) { string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist + if (!CTools::fileExist(sTmp)) // If the file does not exist return true; // need update } } - + // Is an edge of the zone cut an edge of the patat ? for (i = 0; i < pPatat->VPoints.size(); ++i) for (j = 0; j < 4; ++j) @@ -378,7 +378,7 @@ bool CExport::isPatatNeedUpdate (float fCellSize, CPrimZone *pPatat, const strin if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) { string sTmp = CExport::getZoneNameFromXY (x, y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist + if (!CTools::fileExist(sTmp)) // If the file does not exist return true; // need update } } @@ -446,11 +446,11 @@ bool CExport::isPathNeedUpdate (float fCellSize, CPrimPath *pPath, const string (pPath->VPoints[i].y <= ((y+1)*fCellSize))) { string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist + if (!CTools::fileExist(sTmp)) // If the file does not exist return true; // need update } } - + // Is an edge of the zone cut an edge of the patat ? for (i = 0; i < (pPath->VPoints.size()-1); ++i) for (j = 0; j < 4; ++j) @@ -468,7 +468,7 @@ bool CExport::isPathNeedUpdate (float fCellSize, CPrimPath *pPath, const string if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) { string sTmp = CExport::getZoneNameFromXY (x, y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist + if (!CTools::fileExist(sTmp)) // If the file does not exist return true; // need update } } @@ -481,7 +481,7 @@ bool CExport::isPathNeedUpdate (float fCellSize, CPrimPath *pPath, const string bool CExport::isPointNeedUpdate (float fCellSize, CPrimPoint *pPoint, const string &sIGOutputDir) { CTools::chdir (sIGOutputDir); - + sint32 x, y; x = (sint32) floor (pPoint->Point.x / fCellSize); y = (sint32) floor (pPoint->Point.y / fCellSize); @@ -513,7 +513,7 @@ bool CExport::isPointNeedUpdate (float fCellSize, CPrimPoint *pPoint, const stri (pPoint->Point.y <= ((y+1)*fCellSize))) { string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist + if (!CTools::fileExist(sTmp)) // If the file does not exist return true; // need update } @@ -608,7 +608,7 @@ CExport::~CExport() _VCM->deleteEntity (_VCE); delete _VCM; } -} +} @@ -702,7 +702,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) HANDLE hFind; CTools::chdir (sContinentDir); - hFind = FindFirstFile ("*.*", &findData); + hFind = FindFirstFile ("*.*", &findData); while (hFind != INVALID_HANDLE_VALUE) { if (GetFileAttributes(findData.cFileName)&FILE_ATTRIBUTE_DIRECTORY) @@ -725,7 +725,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) } FindClose (hFind); - + // Process all regions uint32 nRegion; for (nRegion = 0; nRegion < vRegions.size(); ++nRegion) @@ -828,7 +828,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) { // Get all patats referenced by the flora and suppress zones under - // Load the .flora file + // Load the .flora file SFormFlora FormFlora; { // Get a loader @@ -860,7 +860,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) } // Delete zones under the old prims referenced by the old zone - + for (i = 0; i < FormFlora.IncludePatats.size(); ++i) { // Get the patat @@ -1020,13 +1020,13 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) // Interpretation of structure for update for (i = 0; i < vPrimToUpdate.size(); ++i) { - // Load all the .flora file + // Load all the .flora file vector vFormFloras; for (j = 0; j < vPrimToUpdate[i].FloraFile.size(); ++j) { // Create the loader UFormLoader *loader = UFormLoader::createLoader (); - + // Load the form CSmartPtr form = loader->loadForm (vPrimToUpdate[i].FloraFile[j].c_str ()); if (form) @@ -1051,7 +1051,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) } // Delete zones under the prims that has been referenced by a flora - + for (j = 0; j < PrimRegion.VZones.size(); ++j) { // Get the patat @@ -1098,7 +1098,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) } // End of process all regions - + // Check all patat to export (a patat that has no zone under itself (deleted or not present)) vector vExportPrimitives; vector vAllPrimFiles; // All prim files of a continent @@ -1115,7 +1115,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) CIXml input; input.init (fileIn); PrimRegion.serial (input); - } + } for (j = 0; j < PrimRegion.VZones.size(); ++j) { @@ -1160,7 +1160,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) _Options->PrimFloraDir = sContinentDir; sTmp = "Exporting"; if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - export (*_Options, _ExportCB, &vExportPrimitives); + doExport (*_Options, _ExportCB, &vExportPrimitives); // Copy new files for incremental purpose CTools::chdir (_ExeDir); @@ -1193,7 +1193,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) } // ------------------------------------------------------------------- - // If the new file do not exists anymore but the old file exists -> delete old file + // If the new file do not exists anymore but the old file exists -> delete old file CTools::chdir (_OutIGDir); CTools::dir (vRegions[nRegion] + "-*.prim", vFiles, false); for (i = 0; i < vFiles.size(); ++i) @@ -1212,7 +1212,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) } } - // If the new file do not exists anymore but the old file exists -> delete old file + // If the new file do not exists anymore but the old file exists -> delete old file CTools::dir (vRegions[nRegion] + "-*.flora", vFiles, false); for (i = 0; i < vFiles.size(); ++i) { @@ -1230,13 +1230,13 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) } } } - + CTools::chdir (_ExeDir); return true; } // --------------------------------------------------------------------------- -bool CExport::export (SExportOptions &opt, IExportCB *expCB, vector *selection) +bool CExport::doExport (SExportOptions &opt, IExportCB *expCB, vector *selection) { char sTmp[MAX_PATH]; GetCurrentDirectory (MAX_PATH, sTmp); @@ -1251,7 +1251,7 @@ bool CExport::export (SExportOptions &opt, IExportCB *expCB, vectordispInfo ("Nothing to export"); return true; } - + // If we want to generate flora then we have to load the landscape uint32 i; @@ -1265,7 +1265,7 @@ bool CExport::export (SExportOptions &opt, IExportCB *expCB, vectorcreateEntity (); _VCM->setLandscape (_Landscape); _VCE->setSnapToRenderedTesselation (false); - try + try { CIFile bankFile (_LandBankFile); _Landscape->TileBank.serial (bankFile); @@ -1313,7 +1313,7 @@ void CExport::getAllFiles (const string &ext, vector &files) GetCurrentDirectory (MAX_PATH, sCurDir); WIN32_FIND_DATA findData; - HANDLE hFind = FindFirstFile ("*.*", &findData); + HANDLE hFind = FindFirstFile ("*.*", &findData); while (hFind != INVALID_HANDLE_VALUE) { if (!((strcmp (findData.cFileName, ".") == 0) || (strcmp (findData.cFileName, "..") == 0))) @@ -1355,7 +1355,7 @@ bool CExport::searchFile (const std::string &plantName, std::string &dir) GetCurrentDirectory (MAX_PATH, sCurDir); WIN32_FIND_DATA findData; - HANDLE hFind = FindFirstFile ("*.*", &findData); + HANDLE hFind = FindFirstFile ("*.*", &findData); while (hFind != INVALID_HANDLE_VALUE) { string filename = findData.cFileName; @@ -1412,7 +1412,7 @@ bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vectorDfnDir, true, true); // CPath::addSearchPath (_Options->GameElemDir, true, true); // CPath::addSearchPath (_Options->LandTileNoiseDir, true, true); - + // Load the form CSmartPtr form = loader->loadForm (SrcFile.c_str ()); if (form == NULL) @@ -1454,7 +1454,7 @@ bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vectorgetRootNode ()); - // Load the .plant associated + // Load the .plant associated for (i = 0; i < formFlora.PlantInstances.size(); ++i) { const string &plantName = formFlora.PlantInstances[i].Name; @@ -1464,7 +1464,7 @@ bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vector form2 = loader->loadForm (tmpName.c_str()); if (form2) { @@ -1631,21 +1631,21 @@ bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vectordispWarning ("Cannot find " + formFlora.IncludePatats[i]); + _ExportCB->dispWarning ("Cannot find " + formFlora.IncludePatats[i]); continue; } if ((pPatat != NULL) && (pPatat->VPoints.size() <= 2)) { if (_ExportCB) - _ExportCB->dispWarning ("Patat " + pPatat->getName() + " has less than 3 points"); + _ExportCB->dispWarning ("Patat " + pPatat->getName() + " has less than 3 points"); continue; } if ((pPath != NULL) && (pPath->VPoints.size() <= 1)) { if (_ExportCB) - _ExportCB->dispWarning ("Path " + pPath->getName() + " has less than 2 points"); + _ExportCB->dispWarning ("Path " + pPath->getName() + " has less than 2 points"); continue; } @@ -1733,7 +1733,7 @@ bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vector -90000.0f) _FloraInsts.push_back (vi); - + } // End of Generate for a point // Generate for a path @@ -1891,7 +1891,7 @@ bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vectorCellSize) < _FloraInsts[k].Pos.x) && (_FloraInsts[k].Pos.x < ((i+1)*_Options->CellSize)) && + if (((i*_Options->CellSize) < _FloraInsts[k].Pos.x) && (_FloraInsts[k].Pos.x < ((i+1)*_Options->CellSize)) && ((j*_Options->CellSize) < _FloraInsts[k].Pos.y) && (_FloraInsts[k].Pos.y < ((j+1)*_Options->CellSize))) { vegZone.push_back (k); @@ -2071,7 +2071,7 @@ void CExport::writeFloraIG (const string &LandFile, bool bTestForWriting) continue; } - try + try { COFile outFile (ZoneName); IG.serial (outFile); @@ -2090,9 +2090,9 @@ void CExport::writeFloraIG (const string &LandFile, bool bTestForWriting) void CExport::loadLandscape (const string &LandFile) { CZoneRegion zoneRegion; - + CIFile inFile; - try + try { if (inFile.open (LandFile)) { diff --git a/code/ryzom/tools/leveldesign/export/export.h b/code/ryzom/tools/leveldesign/export/export.h index 032c274bb..05687edab 100644 --- a/code/ryzom/tools/leveldesign/export/export.h +++ b/code/ryzom/tools/leveldesign/export/export.h @@ -66,7 +66,7 @@ struct SExportOptions std::string GameElemDir; // Directory to get georges file (pipoti.plant) // ======================================================================= - + SExportOptions (); bool loadcf (NLMISC::CConfigFile &cf); bool save (FILE *f); @@ -122,21 +122,21 @@ public: CExport (); ~CExport (); - + // EXPORT one region : // Parse the SourceDir find the .land and .prim // newExport is the incremental export bool newExport (SExportOptions &options, IExportCB *expCB = NULL); - bool export (SExportOptions &options, IExportCB *expCB = NULL, std::vector *selection = NULL); + bool doExport (SExportOptions &options, IExportCB *expCB = NULL, std::vector *selection = NULL); // HELPERS // Get All files with the extension ext in the current directory and subdirectory static void getAllFiles (const std::string &ext, std::vector &files); // Search a file through all subdirectories of the current one (and in the current too) static bool searchFile (const std::string &plantName, std::string &dir); - + private: - + SExportOptions *_Options; IExportCB *_ExportCB; @@ -160,7 +160,7 @@ private: private: - struct SFloraToUpdate + struct SFloraToUpdate { std::string FloraFile; std::vector PrimFile; @@ -186,7 +186,7 @@ private: // Write zone by zone the instance group of the flora generated in the specific land void writeFloraIG (const std::string &LandFile, bool bTestForWriting = false); - + // Helpers // ******* @@ -204,11 +204,11 @@ private: public: - + static std::string getZoneNameFromXY (sint32 x, sint32 y); static sint32 getXFromZoneName (const std::string &ZoneName); static sint32 getYFromZoneName (const std::string &ZoneName); }; -#endif // LD_EXPORT_H \ No newline at end of file +#endif // LD_EXPORT_H diff --git a/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp b/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp index 1bdc43ec6..43f2c058c 100644 --- a/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp @@ -34,7 +34,6 @@ #include "nel/ligo/zone_region.h" #include "nel/ligo/zone_bank.h" - #include "nel/../../src/pacs/collision_mesh_build.h" @@ -81,7 +80,7 @@ void SExportOptions::serial (NLMISC::IStream& s) s.serial (OutZoneDir); s.serial (RefZoneDir); - + if (version > 0) s.serial (LigoBankDir); @@ -117,7 +116,7 @@ void SExportOptions::serial (NLMISC::IStream& s) { s.serial(ExportCollisions); s.serial(RefCMBDir, OutCMBDir); - s.serial(AdditionnalIGInDir, AdditionnalIGOutDir); + s.serial(AdditionnalIGInDir, AdditionnalIGOutDir); s.serial(ContinentFile); s.serial(DFNDir); } @@ -144,14 +143,14 @@ void SExportOptions::serial (NLMISC::IStream& s) // --------------------------------------------------------------------------- CExport::CExport () -{ - _ZeZoneBank = NULL; +{ + _ZeZoneBank = NULL; _FormLoader = UFormLoader::createLoader (); } // --------------------------------------------------------------------------- CExport::~CExport () -{ +{ UFormLoader::releaseLoader (_FormLoader); } @@ -171,12 +170,12 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) } // LOADING - // --- continent form + // --- continent form CPath::addSearchPath(_Options->DFNDir, true, false); CPath::addSearchPath(_Options->RefCMBDir, true, false); CPath::addSearchPath(_Options->ContinentsDir, true, false); CPath::addSearchPath(_Options->AdditionnalIGInDir, true, false); - + // --- ligozone if (_ExportCB != NULL) _ExportCB->dispPass ("Loading ligozone bank"); @@ -188,7 +187,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) if (_ExportCB != NULL) _ExportCB->dispPass ("Loading tile bank"); _ZeTileBank = new CTileBank; - try + try { CIFile inFile (_Options->TileBankFile); _ZeTileBank->serial (inFile); @@ -207,7 +206,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) if (_Options->HeightMapFile != "") { _HeightMap = new CBitmap; - try + try { CIFile inFile; if (inFile.open (_Options->HeightMapFile)) @@ -238,7 +237,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) if (_Options->HeightMapFile2 != "") { _HeightMap2 = new CBitmap; - try + try { CIFile inFile; if (inFile.open (_Options->HeightMapFile2)) @@ -269,7 +268,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) if (_Options->ColorMapFile != "") { _ColorMap = new CBitmap; - try + try { CIFile inFile; if (inFile.open (_Options->ColorMapFile)) @@ -329,9 +328,9 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) return false; } - // zones - - + // zones + + for (uint32 nFile = 0; nFile < allFiles.size(); ++nFile) { @@ -364,18 +363,18 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) if (!DeleteFile (allFiles[nFile].c_str())) { if (_ExportCB != NULL) - _ExportCB->dispWarning (string("Can't delete ") + fileName); + _ExportCB->dispWarning (string("Can't delete ") + fileName); } else - { + { if (_ExportCB != NULL) - _ExportCB->dispInfo (string("Deleted ") + fileName); + _ExportCB->dispInfo (string("Deleted ") + fileName); } - } + } } } - + CTools::chdir (sCurDir); @@ -394,9 +393,9 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) sint32 nNewMaxX = getXFromZoneName (_Options->ZoneMax); sint32 nNewMaxY = getYFromZoneName (_Options->ZoneMax); - if (nNewMinX > nNewMaxX) + if (nNewMinX > nNewMaxX) swap (nNewMinX, nNewMaxX); - if (nNewMinY > nNewMaxY) + if (nNewMinY > nNewMaxY) swap (nNewMinY, nNewMaxY); if (nNewMinX > nMinX) @@ -448,19 +447,19 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) _ExportCB->dispPass ("Finished"); delete _ZeZoneBank; delete _ZeTileBank; - + return true; } // --------------------------------------------------------------------------- -void CExport::treatPattern (sint32 x, sint32 y, +void CExport::treatPattern (sint32 x, sint32 y, vector &ZoneTreated, sint32 nMinX, sint32 nMinY, sint32 nStride) { CZoneRegion *pZR = _Options->ZoneRegion; const string &rSZone = pZR->getName (x, y); CZoneBankElement *pZBE = _ZeZoneBank->getElementByZoneName (rSZone); - + if (pZBE == NULL) return; @@ -514,7 +513,7 @@ void CExport::treatPattern (sint32 x, sint32 y, if (!CTools::fileExist(finalZoneName)) { bHaveToExportZone = true; // A file do not exist -> export it - + if (_ExportCB != NULL) _ExportCB->dispInfo (string("finalZone do not exist")); @@ -552,7 +551,7 @@ void CExport::treatPattern (sint32 x, sint32 y, _ExportCB->dispInfo (string("Cell date newer")); break; - } + } } // Check if we have to export the igs @@ -569,7 +568,7 @@ void CExport::treatPattern (sint32 x, sint32 y, if (!CTools::fileExist(finalIGName)) { bHaveToExportIG = true; // A file do not exist -> export it - + if (_ExportCB != NULL) _ExportCB->dispInfo (string("final instance group do not exist")); @@ -607,7 +606,7 @@ void CExport::treatPattern (sint32 x, sint32 y, _ExportCB->dispInfo (string("Cell date newer")); break; - } + } } @@ -616,7 +615,7 @@ void CExport::treatPattern (sint32 x, sint32 y, // Put the big zone at the right position CZone BigZone; - + // 1 - Load the zone and IG string BigZoneFileName; @@ -628,7 +627,7 @@ void CExport::treatPattern (sint32 x, sint32 y, BigZoneFileName = _Options->RefZoneDir + string("\\") + rSZone + string(".zone"); CIFile inFile ; if (inFile.open(BigZoneFileName)) - { + { BigZone.serial (inFile); } else @@ -658,7 +657,7 @@ void CExport::treatPattern (sint32 x, sint32 y, bigIGFileName = _Options->RefIGDir + string("\\") + rSZone + string(".ig"); CIFile inFile; if (inFile.open(bigIGFileName)) - { + { bigIG.serial (inFile); } else @@ -689,21 +688,21 @@ void CExport::treatPattern (sint32 x, sint32 y, { switch (rot) { - case 0: - transformZone (BigZone, x+deltaX, y+deltaY, rot, flip, true); - transformZone (BigZoneNoHeightmap, x+deltaX, y+deltaY, rot, flip, false); + case 0: + transformZone (BigZone, x+deltaX, y+deltaY, rot, flip, true); + transformZone (BigZoneNoHeightmap, x+deltaX, y+deltaY, rot, flip, false); break; - case 1: - transformZone (BigZone, x+deltaX+sizeY, y+deltaY, rot, flip, true); - transformZone (BigZoneNoHeightmap, x+deltaX+sizeY, y+deltaY, rot, flip, false); + case 1: + transformZone (BigZone, x+deltaX+sizeY, y+deltaY, rot, flip, true); + transformZone (BigZoneNoHeightmap, x+deltaX+sizeY, y+deltaY, rot, flip, false); break; - case 2: - transformZone (BigZone, x+deltaX+sizeX, y+deltaY+sizeY, rot, flip, true); - transformZone (BigZoneNoHeightmap, x+deltaX+sizeX, y+deltaY+sizeY, rot, flip, false); + case 2: + transformZone (BigZone, x+deltaX+sizeX, y+deltaY+sizeY, rot, flip, true); + transformZone (BigZoneNoHeightmap, x+deltaX+sizeX, y+deltaY+sizeY, rot, flip, false); break; - case 3: - transformZone (BigZone, x+deltaX, y+deltaY+sizeX, rot, flip, true); - transformZone (BigZoneNoHeightmap, x+deltaX, y+deltaY+sizeX, rot, flip, false); + case 3: + transformZone (BigZone, x+deltaX, y+deltaY+sizeX, rot, flip, true); + transformZone (BigZoneNoHeightmap, x+deltaX, y+deltaY+sizeX, rot, flip, false); break; } } @@ -711,21 +710,21 @@ void CExport::treatPattern (sint32 x, sint32 y, { switch (rot) { - case 0: - transformZone (BigZone, x+deltaX+sizeX, y+deltaY, rot, flip, true); - transformZone (BigZoneNoHeightmap, x+deltaX+sizeX, y+deltaY, rot, flip, false); + case 0: + transformZone (BigZone, x+deltaX+sizeX, y+deltaY, rot, flip, true); + transformZone (BigZoneNoHeightmap, x+deltaX+sizeX, y+deltaY, rot, flip, false); break; - case 1: - transformZone (BigZone, x+deltaX+sizeY, y+deltaY+sizeX, rot, flip, true); - transformZone (BigZoneNoHeightmap, x+deltaX+sizeY, y+deltaY+sizeX, rot, flip, false); + case 1: + transformZone (BigZone, x+deltaX+sizeY, y+deltaY+sizeX, rot, flip, true); + transformZone (BigZoneNoHeightmap, x+deltaX+sizeY, y+deltaY+sizeX, rot, flip, false); break; case 2: - transformZone (BigZone, x+deltaX, y+deltaY+sizeY, rot, flip, true); - transformZone (BigZoneNoHeightmap, x+deltaX, y+deltaY+sizeY, rot, flip, false); + transformZone (BigZone, x+deltaX, y+deltaY+sizeY, rot, flip, true); + transformZone (BigZoneNoHeightmap, x+deltaX, y+deltaY+sizeY, rot, flip, false); break; - case 3: - transformZone (BigZone, x+deltaX, y+deltaY, rot, flip, true); - transformZone (BigZoneNoHeightmap, x+deltaX, y+deltaY, rot, flip, false); + case 3: + transformZone (BigZone, x+deltaX, y+deltaY, rot, flip, true); + transformZone (BigZoneNoHeightmap, x+deltaX, y+deltaY, rot, flip, false); break; } } @@ -737,17 +736,17 @@ void CExport::treatPattern (sint32 x, sint32 y, { switch (rot) { - case 0: + case 0: transformIG (bigIG, x+deltaX, y+deltaY, rot, flip); break; - case 1: - transformIG (bigIG, x+deltaX+sizeY, y+deltaY, rot, flip); + case 1: + transformIG (bigIG, x+deltaX+sizeY, y+deltaY, rot, flip); break; - case 2: - transformIG (bigIG, x+deltaX+sizeX, y+deltaY+sizeY, rot, flip); + case 2: + transformIG (bigIG, x+deltaX+sizeX, y+deltaY+sizeY, rot, flip); break; - case 3: - transformIG (bigIG, x+deltaX, y+deltaY+sizeX, rot, flip); + case 3: + transformIG (bigIG, x+deltaX, y+deltaY+sizeX, rot, flip); break; } } @@ -755,17 +754,17 @@ void CExport::treatPattern (sint32 x, sint32 y, { switch (rot) { - case 0: - transformIG (bigIG, x+deltaX+sizeX, y+deltaY, rot, flip); + case 0: + transformIG (bigIG, x+deltaX+sizeX, y+deltaY, rot, flip); break; - case 1: - transformIG (bigIG, x+deltaX+sizeY, y+deltaY+sizeX, rot, flip); + case 1: + transformIG (bigIG, x+deltaX+sizeY, y+deltaY+sizeX, rot, flip); break; case 2: - transformIG (bigIG, x+deltaX, y+deltaY+sizeY, rot, flip); + transformIG (bigIG, x+deltaX, y+deltaY+sizeY, rot, flip); break; - case 3: - transformIG (bigIG, x+deltaX, y+deltaY, rot, flip); + case 3: + transformIG (bigIG, x+deltaX, y+deltaY, rot, flip); break; } } @@ -823,7 +822,7 @@ void CExport::treatPattern (sint32 x, sint32 y, if (bHaveToExportZone) { // Put all the patches contained in the square ... in the unit zone - cutZone (BigZone, BigZoneNoHeightmap, UnitZone, UnitZoneNoHeightmap, x+deltaX+i, y+deltaY+j, PatchTransfered, bb, SrcPI, SrcPINoHeightmap, + cutZone (BigZone, BigZoneNoHeightmap, UnitZone, UnitZoneNoHeightmap, x+deltaX+i, y+deltaY+j, PatchTransfered, bb, SrcPI, SrcPINoHeightmap, sMask, BorderVertices, BorderVerticesNoHeightmap, x+deltaX, y+deltaY); if (_Options->Light > 0) light (UnitZoneLighted, UnitZone); @@ -890,7 +889,7 @@ void CExport::treatPattern (sint32 x, sint32 y, _ExportCB->dispWarning (string("Cant write ") + dstIGFileName); } } - + // Set the zone as unused to not treat it the next time ZoneTreated[(x+deltaX+i)-nMinX + ((y+deltaY+j)-nMinY) * nStride] = true; @@ -899,11 +898,11 @@ void CExport::treatPattern (sint32 x, sint32 y, first = false; } - + } // --------------------------------------------------------------------------- -// Tile conversion +// Tile conversion int TransitionFlipLR[48] = { 0, // 0 @@ -1089,8 +1088,8 @@ bool transformTile (const CTileBank &bank, uint &tile, uint &tileRotation, bool const CTileSet *pTileSet = bank.getTileSet (tileSet); // Get border desc - CTileSet::TFlagBorder oriented[4] = - { + CTileSet::TFlagBorder oriented[4] = + { pTileSet->getOrientedBorder (CTileSet::left, CTileSet::getEdgeType ((CTileSet::TTransition)number, CTileSet::left)), pTileSet->getOrientedBorder (CTileSet::bottom, CTileSet::getEdgeType ((CTileSet::TTransition)number, CTileSet::bottom)), pTileSet->getOrientedBorder (CTileSet::right, CTileSet::getEdgeType ((CTileSet::TTransition)number, CTileSet::right)), @@ -1214,7 +1213,7 @@ void CExport::addColorMap (CZone &zeZone) dest = tmp.get565 (); } } - + zeZone.build (zeZone.getZoneId (), PatchInfos, BorderVertices); } } @@ -1307,7 +1306,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR angleAxis.Angle= (float)asin(angleAxis.Axis.norm()); angleAxis.Axis.normalize(); - // build the matrix which transform the old tgt/interior to his newValue: + // build the matrix which transform the old tgt/interior to his newValue: // newVertexPos+ rotate*(oldTgPos-oldVertexPos) tgMatrix[j].identity(); tgMatrix[j].translate(rPI.Patch.Vertices[j]); @@ -1317,7 +1316,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR // For all interior. for (j = 0; j < 4; ++j) - rPI.Patch.Interiors[j]= tgMatrix[j] * rPI.Patch.Interiors[j]; + rPI.Patch.Interiors[j]= tgMatrix[j] * rPI.Patch.Interiors[j]; // when j == 7 or 0 use vertex 0 for delta Z to ensure continuity of normals // when j == 1 or 2 use vertex 1 @@ -1409,7 +1408,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR bindedTangent= subTangents[vb*2+1]; // get the patch id. ngbId= rPI.BindEdges[j].Next[vb]; - bindVertexModified|= applyVertexBind(PatchInfos[ ngbId ], oldPatchInfos[ ngbId ], edgeToModify, + bindVertexModified|= applyVertexBind(PatchInfos[ ngbId ], oldPatchInfos[ ngbId ], edgeToModify, true, oldTgSpace, newTgSpace, bindedPos, bindedTangent); // The second patch (CCW) must change the vertex which ends on the edge (CCW) @@ -1418,7 +1417,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR bindedTangent= subTangents[vb*2+2]; // get the patch id. ngbId= rPI.BindEdges[j].Next[vb+1]; - bindVertexModified|= applyVertexBind(PatchInfos[ ngbId ], oldPatchInfos[ ngbId ], edgeToModify, + bindVertexModified|= applyVertexBind(PatchInfos[ ngbId ], oldPatchInfos[ ngbId ], edgeToModify, false, oldTgSpace, newTgSpace, bindedPos, bindedTangent); } } @@ -1493,7 +1492,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR angleAxis.Angle= (float)asin(angleAxis.Axis.norm()); angleAxis.Axis.normalize(); - // build the matrix which transform the old tgt/interior to his newValue: + // build the matrix which transform the old tgt/interior to his newValue: // newVertexPos+ rotate*(oldTgPos-oldVertexPos) tgMatrix[j].identity(); tgMatrix[j].translate(rPI.Patch.Vertices[j]); @@ -1595,7 +1594,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR bindedTangent= subTangents[vb*2+1]; // get the patch id. ngbId= rPI.BindEdges[j].Next[vb]; - bindVertexModified|= applyVertexBind(PatchInfos[ ngbId ], oldPatchInfos[ ngbId ], edgeToModify, + bindVertexModified|= applyVertexBind(PatchInfos[ ngbId ], oldPatchInfos[ ngbId ], edgeToModify, true, oldTgSpace, newTgSpace, bindedPos, bindedTangent); // The second patch (CCW) must change the vertex which ends on the edge (CCW) @@ -1604,7 +1603,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR bindedTangent= subTangents[vb*2+2]; // get the patch id. ngbId= rPI.BindEdges[j].Next[vb+1]; - bindVertexModified|= applyVertexBind(PatchInfos[ ngbId ], oldPatchInfos[ ngbId ], edgeToModify, + bindVertexModified|= applyVertexBind(PatchInfos[ ngbId ], oldPatchInfos[ ngbId ], edgeToModify, false, oldTgSpace, newTgSpace, bindedPos, bindedTangent); } } @@ -1679,7 +1678,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR swap(rPI.Tiles[j+k*rPI.OrderS], rPI.Tiles[(rPI.OrderS-1-j)+k*rPI.OrderS]); } } - + for (j = 0; j < (uint32)((rPI.OrderS+1)/2); ++j) { for (k = 0; k < (uint32)(rPI.OrderT+1); ++k) @@ -1698,7 +1697,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR for (i = 0; i < PatchInfos.size(); ++i) { CPatchInfo &rPI = PatchInfos[i]; - + for (j = 0; j < rPI.Tiles.size(); ++j) { @@ -1711,7 +1710,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR // Is the tile is painted ? if (rPI.Tiles[j].Tile[0] == 65535) continue; - + // Rotate Tiles // Invert rotation effect on transition for (pass = 0; pass < 3; ++pass) @@ -1749,7 +1748,7 @@ void CExport::transformZone (CZone &zeZone, sint32 nPosX, sint32 nPosY, uint8 nR } } } - + zeZone.build (nZoneId, PatchInfos, BorderVertices); }*/ @@ -1768,7 +1767,7 @@ void CExport::buildTransfo(sint32 nPosX, sint32 nPosY, uint8 nRot, uint8 nFlip, posTransfo.setRot(rotTransfo); posTransfo.setPos(CVector(nPosX * _Options->CellSize, (nPosY) * _Options->CellSize, 0.0f)); if (nFlip == 1) - posTransfo.scale(CVector(-1.0f, 1.0f, 1.0f)); + posTransfo.scale(CVector(-1.0f, 1.0f, 1.0f)); } // --------------------------------------------------------------------------- @@ -1777,8 +1776,8 @@ void CExport::transformIG (CInstanceGroup &ig, sint32 nPosX, sint32 nPosY, uint8 uint k; CQuat rotTransfo; CMatrix transformation; - - buildTransfo(nPosX, nPosY, nRot, nFlip, transformation, rotTransfo); + + buildTransfo(nPosX, nPosY, nRot, nFlip, transformation, rotTransfo); /////////////// // instances // @@ -1792,7 +1791,7 @@ void CExport::transformIG (CInstanceGroup &ig, sint32 nPosX, sint32 nPosY, uint8 // add height map influence //igi.Pos.z += getHeight(igi.Pos.x, igi.Pos.y); - + // Instance CInstanceGroup::CInstance &igi = ig.getInstance(k); @@ -1829,7 +1828,7 @@ void CExport::transformIG (CInstanceGroup &ig, sint32 nPosX, sint32 nPosY, uint8 plm.setPosition(transformation * plm.getPosition()); // add height map influence - // plm.setPosition(plm.getPosition() + CVector::K * getHeight(plm.getPosition().x, plm.getPosition().y)); + // plm.setPosition(plm.getPosition() + CVector::K * getHeight(plm.getPosition().x, plm.getPosition().y)); } } @@ -1848,13 +1847,13 @@ void CExport::transformCMB (NLPACS::CCollisionMeshBuild &cmb,sint32 nPosX,sint32 } // --------------------------------------------------------------------------- -void CExport::cutZone (NL3D::CZone &bigZone, NL3D::CZone &bigZoneNoHeightmap, NL3D::CZone &unitZone, NL3D::CZone &unitZoneNoHeightmap, - sint32 nPosX, sint32 nPosY, vector &PatchTransfered, const vector &bb, vector &SrcPI, - vector &SrcPINoHeightmap, SPiece &sMask, vector &BorderVertices, +void CExport::cutZone (NL3D::CZone &bigZone, NL3D::CZone &bigZoneNoHeightmap, NL3D::CZone &unitZone, NL3D::CZone &unitZoneNoHeightmap, + sint32 nPosX, sint32 nPosY, vector &PatchTransfered, const vector &bb, vector &SrcPI, + vector &SrcPINoHeightmap, SPiece &sMask, vector &BorderVertices, vector &BorderVerticesNoHeightmap, sint32 baseX, sint32 baseY) { string DstZoneFileName = getZoneNameFromXY (nPosX, nPosY); - + uint32 i, j, k, l, m; vector DstPI; vector DstPINoHeightmap; @@ -1955,7 +1954,7 @@ void CExport::cutZone (NL3D::CZone &bigZone, NL3D::CZone &bigZoneNoHeightmap, NL } while (foundOne); - // Add all patch that are binded to one of those of the DstPI list + // Add all patch that are binded to one of those of the DstPI list uint32 nPreviousDstPISize = (uint32)DstPI.size(); for (;;) { @@ -1989,8 +1988,8 @@ void CExport::cutZone (NL3D::CZone &bigZone, NL3D::CZone &bigZoneNoHeightmap, NL uint next = DstPI[i].BindEdges[j].Next[k]; if (!PatchTransfered[next]) { - CPatchInfo &rPITmp = SrcPI[next]; - CPatchInfo &rPITmpNoHeightmap = SrcPINoHeightmap[next]; + CPatchInfo &rPITmp = SrcPI[next]; + CPatchInfo &rPITmpNoHeightmap = SrcPINoHeightmap[next]; for (m = 0; m < 4; ++m) { rPITmp.BindEdges[m].ZoneId = nZoneId; @@ -2069,7 +2068,7 @@ void CExport::cutZone (NL3D::CZone &bigZone, NL3D::CZone &bigZoneNoHeightmap, NL gLand.init(); gLandInited = true; } - + gLand.addZone(unitZone); gLand.checkBinds(); }*/ @@ -2126,14 +2125,14 @@ void CExport::cutIG(CInstanceGroup &bigIG, CInstanceGroup &unitIG, sint32 nPosX, // lights // //////////// - const std::vector &lights = bigIG.getPointLightList(); + const std::vector &lights = bigIG.getPointLightList(); for (k = 0; k < lights.size(); ++k) { const CVector &pos = lights[k].getPosition(); if (pos.x >= rMinX && pos.x < rMaxX && pos.y >= rMinY && pos.y < rMaxY) { pointLightList.push_back(lights[k]); - } + } // First zone ? if (first) @@ -2165,13 +2164,13 @@ float CExport::getHeight (float x, float y) CRGBAF color; sint32 SizeX = _ZoneMaxX - _ZoneMinX + 1; sint32 SizeY = _ZoneMaxY - _ZoneMinY + 1; - + clamp (x, _Options->CellSize*_ZoneMinX, _Options->CellSize*(_ZoneMaxX+1)); clamp (y, _Options->CellSize*_ZoneMinY, _Options->CellSize*(_ZoneMaxY+1)); if (_HeightMap != NULL) { - color = _HeightMap->getColor ( (x-_Options->CellSize*_ZoneMinX)/(_Options->CellSize*SizeX), + color = _HeightMap->getColor ( (x-_Options->CellSize*_ZoneMinX)/(_Options->CellSize*SizeX), 1.0f - ((y-_Options->CellSize*_ZoneMinY)/(_Options->CellSize*SizeY))); color *= 255; deltaZ = color.A; @@ -2181,7 +2180,7 @@ float CExport::getHeight (float x, float y) if (_HeightMap2 != NULL) { - color = _HeightMap2->getColor ( (x-_Options->CellSize*_ZoneMinX)/(_Options->CellSize*SizeX), + color = _HeightMap2->getColor ( (x-_Options->CellSize*_ZoneMinX)/(_Options->CellSize*SizeX), 1.0f - ((y-_Options->CellSize*_ZoneMinY)/(_Options->CellSize*SizeY))); color *= 255; deltaZ2 = color.A; @@ -2198,13 +2197,13 @@ CRGBAF CExport::getColor (float x, float y) CRGBAF color = CRGBA::Black; sint32 SizeX = _ZoneMaxX - _ZoneMinX + 1; sint32 SizeY = _ZoneMaxY - _ZoneMinY + 1; - + clamp (x, _Options->CellSize*_ZoneMinX, _Options->CellSize*(_ZoneMaxX+1)); clamp (y, _Options->CellSize*_ZoneMinY, _Options->CellSize*(_ZoneMaxY+1)); if (_ColorMap != NULL) { - color = _ColorMap->getColor ( (x-_Options->CellSize*_ZoneMinX)/(_Options->CellSize*SizeX), + color = _ColorMap->getColor ( (x-_Options->CellSize*_ZoneMinX)/(_Options->CellSize*SizeX), 1.0f - ((y-_Options->CellSize*_ZoneMinY)/(_Options->CellSize*SizeY))); color *= 255; } @@ -2257,7 +2256,7 @@ void CExport::light (NL3D::CZone &zoneOut, NL3D::CZone &zoneIn) land.TileBank = *_ZeTileBank; land.initTileBanks(); land.addZone (zoneIn); - + vector vPI; vector vBV; @@ -2383,7 +2382,7 @@ sint32 CExport::getYFromZoneName (const string &ZoneName) } return -atoi(yStr.c_str()); } - + // --------------------------------------------------------------------------- void CExport::transformCMB (const std::string &name, const NLMISC::CMatrix &transfo, bool verbose) const { @@ -2405,9 +2404,9 @@ void CExport::transformCMB (const std::string &name, const NLMISC::CMatrix &tran if (inStream.open(cmbName)) { try - { + { CCollisionMeshBuild cmb; - cmb.serial(inStream); + cmb.serial(inStream); // translate and save cmb.transform (transfo); COFile outStream; @@ -2418,7 +2417,7 @@ void CExport::transformCMB (const std::string &name, const NLMISC::CMatrix &tran _ExportCB->dispWarning("Couldn't open " + outFileName + "for writing, not exporting"); } else - { + { try { cmb.serial(outStream); @@ -2428,23 +2427,23 @@ void CExport::transformCMB (const std::string &name, const NLMISC::CMatrix &tran { outStream.close(); if (_ExportCB != NULL) - { + { _ExportCB->dispWarning("Error while writing " + outFileName); _ExportCB->dispWarning(e.what()); } } - } + } inStream.close(); } catch (EStream &e) { inStream.close(); if (_ExportCB != NULL) - { + { _ExportCB->dispWarning("Error while reading " + cmbName); _ExportCB->dispWarning(e.what()); } - } + } } else { @@ -2474,7 +2473,7 @@ void CExport::transformAdditionnalIG (const std::string &name, const NLMISC::CMa if (inStream.open(igName)) { try - { + { CInstanceGroup ig, igOut; ig.serial(inStream); @@ -2483,22 +2482,22 @@ void CExport::transformAdditionnalIG (const std::string &name, const NLMISC::CMa std::vector Clusters; std::vector Portals; std::vector PLN; - + ig.retrieve(globalPos, IA, Clusters, Portals, PLN); bool realTimeSuncontribution = ig.getRealTimeSunContribution(); - + uint k; // elevate instance for(k = 0; k < IA.size(); ++k) - { + { IA[k].Pos = transfo * IA[k].Pos; IA[k].Rot = rotTransfo * IA[k].Rot; } // lights for(k = 0; k < PLN.size(); ++k) - { + { PLN[k].setPosition(transfo * PLN[k].getPosition()); - } + } // portals std::vector portal; for(k = 0; k < Portals.size(); ++k) @@ -2507,13 +2506,13 @@ void CExport::transformAdditionnalIG (const std::string &name, const NLMISC::CMa for(uint l = 0; l < portal.size(); ++l) { portal[l] = transfo * portal[l]; - } + } Portals[k].setPoly(portal); } - // clusters + // clusters for(k = 0; k < Clusters.size(); ++k) - { + { Clusters[k].applyMatrix (transfo); } @@ -2530,7 +2529,7 @@ void CExport::transformAdditionnalIG (const std::string &name, const NLMISC::CMa _ExportCB->dispWarning("Couldn't open " + outFileName + "for writing, not exporting"); } else - { + { try { igOut.serial(outStream); @@ -2540,23 +2539,23 @@ void CExport::transformAdditionnalIG (const std::string &name, const NLMISC::CMa { outStream.close(); if (_ExportCB != NULL) - { + { _ExportCB->dispWarning("Error while writing " + outFileName); _ExportCB->dispWarning(e.what()); } } - } + } inStream.close(); } catch (EStream &e) { inStream.close(); if (_ExportCB != NULL) - { + { _ExportCB->dispWarning("Error while reading " + igName); _ExportCB->dispWarning(e.what()); } - } + } } else { @@ -2567,7 +2566,7 @@ void CExport::transformAdditionnalIG (const std::string &name, const NLMISC::CMa // --------------------------------------------------------------------------- void CExport::exportCMBAndAdditionnalIGs() -{ +{ if (!_Options->ExportCollisions && !_Options->ExportCollisions) return; CSmartPtr continent = loadContinent(_Options->ContinentFile); if (!continent) return; @@ -2575,7 +2574,7 @@ void CExport::exportCMBAndAdditionnalIGs() NLGEORGES::UFormElm *villages; if (!continent->getRootNode ().getNodeByName (&villages, "Villages") || !villages) { - if (_ExportCB != NULL) + if (_ExportCB != NULL) _ExportCB->dispWarning("Cant find villages in a continent form"); return; } @@ -2588,7 +2587,7 @@ void CExport::exportCMBAndAdditionnalIGs() NLGEORGES::UFormElm *village; if (!villages->getArrayNode (&village, k) || !village) { - if (_ExportCB != NULL) + if (_ExportCB != NULL) _ExportCB->dispWarning("Cant get a village "); continue; } @@ -2597,7 +2596,7 @@ void CExport::exportCMBAndAdditionnalIGs() float altitude; if (!village->getValueByName (altitude, "Altitude")) { - if (_ExportCB != NULL) + if (_ExportCB != NULL) _ExportCB->dispWarning("Cant get a village position"); continue; } @@ -2606,7 +2605,7 @@ void CExport::exportCMBAndAdditionnalIGs() sint32 rotation; if (!village->getValueByName (rotation, "Rotation")) { - if (_ExportCB != NULL) + if (_ExportCB != NULL) _ExportCB->dispWarning("Cant get a village rotation"); continue; } @@ -2615,7 +2614,7 @@ void CExport::exportCMBAndAdditionnalIGs() uint32 width; if (!village->getValueByName (width, "Width")) { - if (_ExportCB != NULL) + if (_ExportCB != NULL) _ExportCB->dispWarning("Cant get a village width"); continue; } @@ -2624,7 +2623,7 @@ void CExport::exportCMBAndAdditionnalIGs() uint32 height; if (!village->getValueByName (height, "Height")) { - if (_ExportCB != NULL) + if (_ExportCB != NULL) _ExportCB->dispWarning("Cant get a village height"); continue; } @@ -2633,7 +2632,7 @@ void CExport::exportCMBAndAdditionnalIGs() std::string zoneName; if (!village->getValueByName (zoneName, "Zone")) { - if (_ExportCB != NULL) + if (_ExportCB != NULL) _ExportCB->dispWarning("Cant get a village name"); continue; } @@ -2675,7 +2674,7 @@ void CExport::exportCMBAndAdditionnalIGs() NLGEORGES::UFormElm *igNamesItem; if (!village->getNodeByName (&igNamesItem, "IgList") || !igNamesItem) { - if (_ExportCB != NULL) + if (_ExportCB != NULL) _ExportCB->dispWarning("Cant get village ig list"); continue; } @@ -2693,14 +2692,14 @@ void CExport::exportCMBAndAdditionnalIGs() if (igNamesItem->getArrayNode (&currIg, k) && currIg) { const NLGEORGES::UFormElm *igNameItem; - if (!currIg->getNodeByName (&igNameItem, "IgName") || !igNameItem) + if (!currIg->getNodeByName (&igNameItem, "IgName") || !igNameItem) { nlwarning("Unable to get village name from a form"); continue; - } - + } + if (igNameItem->getValue (igName)) - { + { if (_Options->ExportCollisions) { transformCMB (igName, transfo, true); @@ -2719,7 +2718,7 @@ void CExport::exportCMBAndAdditionnalIGs() } } } - + } return; } @@ -2730,7 +2729,7 @@ NLGEORGES::UForm* CExport::loadContinent(const std::string &name) const { if (!NLMISC::CFile::fileExists(name)) { - if (_ExportCB != NULL) + if (_ExportCB != NULL) _ExportCB->dispWarning("Can't find " + name); return NULL; } @@ -2739,13 +2738,13 @@ NLGEORGES::UForm* CExport::loadContinent(const std::string &name) const if (!(form = _FormLoader->loadForm (name.c_str ()))) { if (_ExportCB != NULL) - { + { _ExportCB->dispWarning("Unable to load continent form : " + name); } return NULL; } - return form; + return form; } @@ -2817,8 +2816,8 @@ void CExport::computeSubdividedTangents(uint numBinds, const NL3D::CBezierPatch // *************************************************************************** -bool CExport::applyVertexBind(NL3D::CPatchInfo &pa, NL3D::CPatchInfo &oldPa, uint edgeToModify, bool startEdge, - const NLMISC::CMatrix &oldTgSpace, const NLMISC::CMatrix &newTgSpace, +bool CExport::applyVertexBind(NL3D::CPatchInfo &pa, NL3D::CPatchInfo &oldPa, uint edgeToModify, bool startEdge, + const NLMISC::CMatrix &oldTgSpace, const NLMISC::CMatrix &newTgSpace, const NLMISC::CVector &bindedPos, const NLMISC::CVector &bindedTangent ) { // Get the vertex to modify according to edge/startEdge @@ -2836,7 +2835,7 @@ bool CExport::applyVertexBind(NL3D::CPatchInfo &pa, NL3D::CPatchInfo &oldPa, uin // change the tangent, according to startEdge pa.Patch.Tangents[edgeToModify*2 + (startEdge?0:1) ]= bindedTangent; - // Must change the tangent which is on the other side of the vertex: + // Must change the tangent which is on the other side of the vertex: uint tgToModify= 8 + edgeToModify*2 + (startEdge?-1:+2); tgToModify&=7; /* To keep the same continuity aspect around the vertex, we compute the original tangent in a @@ -2862,7 +2861,7 @@ NLMISC::CVector CExport::getHeightNormal (float x, float y) sint32 SizeX = _ZoneMaxX - _ZoneMinX + 1; sint32 SizeY = _ZoneMaxY - _ZoneMinY + 1; sint32 bmpW, bmpH; - + // get width/height of the bitmap if (_HeightMap != NULL) From 6ec0afb12abdab935a69505035c2d3607390831f Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 19:05:06 +0200 Subject: [PATCH 03/60] Changed: Replaced DeleteFile (Win32) by NLMISC::CFile::deleteFile --- .../ryzom/tools/leveldesign/export/export.cpp | 11 +++++---- .../world_editor/land_export_lib/export.cpp | 24 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/code/ryzom/tools/leveldesign/export/export.cpp b/code/ryzom/tools/leveldesign/export/export.cpp index bb3e384f1..48fb175aa 100644 --- a/code/ryzom/tools/leveldesign/export/export.cpp +++ b/code/ryzom/tools/leveldesign/export/export.cpp @@ -39,9 +39,10 @@ #include "nel/misc/i_xml.h" #include "nel/misc/path.h" #include "nel/misc/file.h" +#include "nel/misc/path.h" #include "tools.h" -#include "../master/continentcfg.h" +#include "../master/ContinentCfg.h" using namespace std; using namespace NLMISC; @@ -50,7 +51,7 @@ using namespace NLLIGO; using namespace NLGEORGES; #define MAX_SYS_DIR 6 -char *gExportSysDir[MAX_SYS_DIR] = +const char *gExportSysDir[MAX_SYS_DIR] = { ".", "..", @@ -85,7 +86,7 @@ void CExport::delIGZone (sint32 x, sint32 y) { string sZoneName = CExport::getZoneNameFromXY (x, y); sZoneName += ".ig"; - if (DeleteFile(sZoneName.c_str())) + if (CFile::deleteFile(deleteFile(sZoneName)) { CTools::chdir (_ExeDir); string sTmp = string(" zone ") + sZoneName + " deleted"; @@ -1208,7 +1209,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) if (!CTools::fileExist(sNewName)) { // Delete the oldest file - DeleteFile(vFiles[i].c_str()); + CFile::deleteFile(vFiles[i]); } } @@ -1226,7 +1227,7 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) if (!CTools::fileExist(sNewName)) { // Delete the oldest file - DeleteFile(vFiles[i].c_str()); + CFile::deleteFile(vFiles[i]); } } } diff --git a/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp b/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp index 43f2c058c..0f02075c2 100644 --- a/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp @@ -41,7 +41,9 @@ #include -#include +#ifdef NL_OS_WINDOWS +# include +#endif // NL_OS_WINDOWS using namespace NL3D; using namespace NLMISC; @@ -360,8 +362,8 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB) if (bMustDelete) { - if (!DeleteFile (allFiles[nFile].c_str())) - { + if (!CFile::deleteFile (allFiles[nFile])) + { if (_ExportCB != NULL) _ExportCB->dispWarning (string("Can't delete ") + fileName); } @@ -844,15 +846,15 @@ void CExport::treatPattern (sint32 x, sint32 y, { // Delete the .zone and .zonel file DstZoneFileName = getZoneNameFromXY(x+deltaX+i, y+deltaY+j); - DstZoneFileName = _Options->OutZoneDir + string("\\") + DstZoneFileName; + DstZoneFileName = _Options->OutZoneDir + string("/") + DstZoneFileName; string sTmp = DstZoneFileName + string(".zone"); - DeleteFile (sTmp.c_str()); + CFile::deleteFile (sTmp); DstZoneFileName = DstZoneFileName + string(".zonel"); - DeleteFile (DstZoneFileName.c_str()); + CFile::deleteFile (DstZoneFileName); // Delete the .zonenh file - string DstZoneNoHeightmapFileName = _Options->OutZoneDir + string("\\") + getZoneNameFromXY(x+deltaX+i, y+deltaY+j) + string(".zonenh"); - DeleteFile (DstZoneNoHeightmapFileName.c_str()); + string DstZoneNoHeightmapFileName = _Options->OutZoneDir + string("/") + getZoneNameFromXY(x+deltaX+i, y+deltaY+j) + string(".zonenh"); + CFile::deleteFile (DstZoneNoHeightmapFileName); COFile outFile (DstZoneFileName); UnitZoneLighted.serial (outFile); @@ -876,9 +878,9 @@ void CExport::treatPattern (sint32 x, sint32 y, try { dstIGFileName = getZoneNameFromXY(x+deltaX+i, y+deltaY+j); - dstIGFileName = _Options->OutIGDir + string("\\") + dstIGFileName + string(".ig"); - DeleteFile (dstIGFileName.c_str()); - COFile outFile (dstIGFileName); + dstIGFileName = _Options->OutIGDir + string("/") + dstIGFileName + string(".ig"); + CFile::deleteFile (dstIGFileName); + COFile outFile (dstIGFileName); unitIG.serial(outFile); if (_ExportCB != NULL) _ExportCB->dispInfo (string("Writing ") + getZoneNameFromXY(x+deltaX+i, y+deltaY+j) + ".ig"); From 83622c6cbb8c8a80986a977dc158545c26f0dffc Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 19:58:05 +0200 Subject: [PATCH 04/60] Changed: #142 Replace atoi and sscanf by fromString when it's possible --- code/nel/samples/misc/command/main.cpp | 3 ++- code/nel/samples/net/udp/client.cpp | 5 +++-- code/nel/src/logic/logic_variable.cpp | 2 +- code/nel/src/misc/config_file/config_file.cpp | 6 +++++- code/nel/tools/3d/build_shadow_skin/main.cpp | 4 ++-- code/nel/tools/3d/object_viewer/edit_ex.cpp | 8 ++++++-- code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp | 3 ++- code/nel/tools/3d/zone_lib/zone_utility.cpp | 3 ++- code/nel/tools/3d/zviewer/zviewer.cpp | 2 +- code/nel/tools/misc/log_analyser/log_analyserDlg.cpp | 6 ++++-- code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp | 2 +- code/nel/tools/pacs/build_ig_boxes/main.cpp | 2 +- code/nel/tools/pacs/build_indoor_rbank/main.cpp | 2 +- 13 files changed, 31 insertions(+), 17 deletions(-) diff --git a/code/nel/samples/misc/command/main.cpp b/code/nel/samples/misc/command/main.cpp index bd101c6b5..ba0bd3e96 100644 --- a/code/nel/samples/misc/command/main.cpp +++ b/code/nel/samples/misc/command/main.cpp @@ -56,7 +56,8 @@ NLMISC_COMMAND(square,"display the square of the parameter","") // check args, if there is not the right number of parameters, return bad status. if (args.size() != 1) return false; - uint32 val = atoi(args[0].c_str()); + uint32 val; + NLMISC::fromString(args[0], val); // display the result. log.displayNL("The square of %d is %d", val, val*val); diff --git a/code/nel/samples/net/udp/client.cpp b/code/nel/samples/net/udp/client.cpp index 06f494138..749797368 100644 --- a/code/nel/samples/net/udp/client.cpp +++ b/code/nel/samples/net/udp/client.cpp @@ -215,8 +215,9 @@ void cbInfo (CMessage &msgin, TSockId from, CCallbackNetBase &netbase) string token = "MeanPongTime "; string::size_type pos=line.find (token); string::size_type pos2=line.find (" ", pos+token.size()); - uint32 val = atoi(line.substr (pos+token.size(), pos2-pos-token.size()).c_str()); - LagGraph.addOneValue ((float)val); + float val; + NLMISC::fromString(line.substr (pos+token.size(), pos2-pos-token.size()), val); + LagGraph.addOneValue (val); #endif } diff --git a/code/nel/src/logic/logic_variable.cpp b/code/nel/src/logic/logic_variable.cpp index bca00fc91..63f5f66fc 100644 --- a/code/nel/src/logic/logic_variable.cpp +++ b/code/nel/src/logic/logic_variable.cpp @@ -381,7 +381,7 @@ void CLogicCounter::read (xmlNodePtr node) _Name = getXMLProp (node, "Name"); _Value = atoiInt64 (getXMLProp (node, "Value").c_str()); - _Verbose = atoi(getXMLProp (node, "Verbose").c_str()) == 1; + NLMISC::fromString(getXMLProp (node, "Verbose"), _Verbose); Period.setValue(atoiInt64(getXMLProp (node, "Period").c_str())); Phase.setValue(atoiInt64(getXMLProp (node, "Phase").c_str())); Step.setValue(atoiInt64(getXMLProp (node, "Step").c_str())); diff --git a/code/nel/src/misc/config_file/config_file.cpp b/code/nel/src/misc/config_file/config_file.cpp index 2351a58f7..f85469003 100644 --- a/code/nel/src/misc/config_file/config_file.cpp +++ b/code/nel/src/misc/config_file/config_file.cpp @@ -56,8 +56,12 @@ int CConfigFile::CVar::asInt (int index) const switch (Type) { case T_STRING: + { if (index >= (int)StrValues.size () || index < 0) throw EBadSize (Name, (int)StrValues.size (), index); - return atoi(StrValues[index].c_str()); + int ret = 0; + NLMISC::fromString(StrValues[index], ret); + return ret; + } case T_REAL: if (index >= (int)RealValues.size () || index < 0) throw EBadSize (Name, (int)RealValues.size (), index); return (int)RealValues[index]; diff --git a/code/nel/tools/3d/build_shadow_skin/main.cpp b/code/nel/tools/3d/build_shadow_skin/main.cpp index 38562e5d1..1c180d1e2 100644 --- a/code/nel/tools/3d/build_shadow_skin/main.cpp +++ b/code/nel/tools/3d/build_shadow_skin/main.cpp @@ -314,9 +314,9 @@ int main(int argc, char *argv[]) sint percentageFace= 100; sint maxFace= INT_MAX; if(argc>=4) - percentageFace= atoi(argv[3]); + NLMISC::fromString(argv[3], percentageFace); if(argc>=5) - maxFace= atoi(argv[4]); + NLMISC::fromString(argv[4], maxFace); // **** Load the Mesh In. IShape *pResult = NULL; diff --git a/code/nel/tools/3d/object_viewer/edit_ex.cpp b/code/nel/tools/3d/object_viewer/edit_ex.cpp index 5659145f1..754635b6d 100644 --- a/code/nel/tools/3d/object_viewer/edit_ex.cpp +++ b/code/nel/tools/3d/object_viewer/edit_ex.cpp @@ -52,13 +52,17 @@ void CEditEx::OnSetFocus(CWnd* pOldWnd) sint CEditEx::getSInt() const { nlassert(_Type == SIntType); - return (sint) ::atoi(getString().c_str()); + sint ret = 0; + NLMISC::fromString(getString(), ret); + return ret; } uint CEditEx::getUInt() const { nlassert(_Type == UIntType); - return (uint) ::atoi(getString().c_str()); + uint ret = 0; + NLMISC::fromString(getString(), ret); + return ret; } float CEditEx::getFloat() const { diff --git a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp index 2585e762b..6abfe682b 100644 --- a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp +++ b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp @@ -880,7 +880,8 @@ bool ShapesExporter::createThumbnail(const string &filename, const string &path) if (!fgets(str, 100, fp)) strcpy(str, "0"); fclose(fp); - selectedFrame = atoi(str)/2; + NLMISC::fromString(std::string(str), selectedFrame); + selectedFrame /= 2; } } diff --git a/code/nel/tools/3d/zone_lib/zone_utility.cpp b/code/nel/tools/3d/zone_lib/zone_utility.cpp index 63570aa39..3c73e3739 100644 --- a/code/nel/tools/3d/zone_lib/zone_utility.cpp +++ b/code/nel/tools/3d/zone_lib/zone_utility.cpp @@ -116,7 +116,8 @@ bool getZoneCoordByName(const char * name, uint16& x, uint16& y) return false; } } - y = atoi(ystr.c_str()); + + NLMISC::fromString(ystr, y); // x x = 0; diff --git a/code/nel/tools/3d/zviewer/zviewer.cpp b/code/nel/tools/3d/zviewer/zviewer.cpp index 420551a3e..6cd17e7df 100644 --- a/code/nel/tools/3d/zviewer/zviewer.cpp +++ b/code/nel/tools/3d/zviewer/zviewer.cpp @@ -962,7 +962,7 @@ int main(int /* argc */, char ** /* argv */) NLMISC::CApplicationContext myApplicationContext; #ifdef NL_OS_UNIX - NLMISC::CPath::addSearchPath(NLMISC::CFile::getApplicationDirectory("NeL")); + NLMISC::CPath::addSearchPath(NLMISC::CPath::getApplicationDirectory("NeL")); #endif // NL_OS_UNIX NLMISC::CPath::addSearchPath(NL_ZVIEWER_CFG); diff --git a/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp b/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp index 8103090c8..1f09bd91e 100644 --- a/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp +++ b/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp @@ -59,7 +59,8 @@ afx_msg void CLAEdit::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) int start, end; GetSel( start, end ); str = str.Mid( start, end-start ); - int lineNum = atoi( str ); + sint lineNum; + NLMISC::fromString(str, lineNum); if ( ! ((lineNum != 0) || (str == "0")) ) break; @@ -713,7 +714,8 @@ void CLog_analyserDlg::insertTraceLine( int index, char *traceLine ) char *line = strchr( traceLine, ':' ); char scycle [10]; strncpy( scycle, traceLine, line-traceLine ); - int cycle = atoi(scycle); + sint cycle; + NLMISC::fromString(scycle, cycle); TStampedLine stampedLine; stampedLine.Index = index; stampedLine.Line = CString(traceLine); diff --git a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp index c84b328ef..215dafa9e 100644 --- a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp +++ b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp @@ -424,7 +424,7 @@ int main( int argc, char ** argv ) NLMISC::CApplicationContext appContext; #ifdef NL_OS_UNIX - NLMISC::CPath::addSearchPath(NLMISC::CFile::getApplicationDirectory("NeL")); + NLMISC::CPath::addSearchPath(NLMISC::CPath::getApplicationDirectory("NeL")); #endif // NL_OS_UNIX NLMISC::CPath::addSearchPath(NL_MK_SH_ID_CFG); diff --git a/code/nel/tools/pacs/build_ig_boxes/main.cpp b/code/nel/tools/pacs/build_ig_boxes/main.cpp index 9d420745d..046e5ee74 100644 --- a/code/nel/tools/pacs/build_ig_boxes/main.cpp +++ b/code/nel/tools/pacs/build_ig_boxes/main.cpp @@ -86,7 +86,7 @@ void init() try { #ifdef NL_OS_UNIX - NLMISC::CPath::addSearchPath(NLMISC::CFile::getApplicationDirectory("NeL")); + NLMISC::CPath::addSearchPath(NLMISC::CPath::getApplicationDirectory("NeL")); #endif // NL_OS_UNIX NLMISC::CPath::addSearchPath(NL_BIB_CFG); diff --git a/code/nel/tools/pacs/build_indoor_rbank/main.cpp b/code/nel/tools/pacs/build_indoor_rbank/main.cpp index 9fbd77d1e..1d459e2ee 100644 --- a/code/nel/tools/pacs/build_indoor_rbank/main.cpp +++ b/code/nel/tools/pacs/build_indoor_rbank/main.cpp @@ -122,7 +122,7 @@ void initConfig() try { #ifdef NL_OS_UNIX - NLMISC::CPath::addSearchPath(NLMISC::CFile::getApplicationDirectory("NeL")); + NLMISC::CPath::addSearchPath(NLMISC::CPath::getApplicationDirectory("NeL")); #endif // NL_OS_UNIX NLMISC::CPath::addSearchPath(NL_BIRB_CFG); From cd78367f5075e616cf001c4107fb043f1675fc44 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 19:59:53 +0200 Subject: [PATCH 05/60] Changed: Replaced DeleteFile (Win32) by NLMISC::CFile::deleteFile --- code/ryzom/tools/leveldesign/export/export.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/ryzom/tools/leveldesign/export/export.cpp b/code/ryzom/tools/leveldesign/export/export.cpp index 48fb175aa..2b763efee 100644 --- a/code/ryzom/tools/leveldesign/export/export.cpp +++ b/code/ryzom/tools/leveldesign/export/export.cpp @@ -39,7 +39,6 @@ #include "nel/misc/i_xml.h" #include "nel/misc/path.h" #include "nel/misc/file.h" -#include "nel/misc/path.h" #include "tools.h" #include "../master/ContinentCfg.h" @@ -86,7 +85,7 @@ void CExport::delIGZone (sint32 x, sint32 y) { string sZoneName = CExport::getZoneNameFromXY (x, y); sZoneName += ".ig"; - if (CFile::deleteFile(deleteFile(sZoneName)) + if (CFile::deleteFile(sZoneName)) { CTools::chdir (_ExeDir); string sTmp = string(" zone ") + sZoneName + " deleted"; From 15cb5a955b29140c5057ebdd1067378fb8aa2947 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 20:07:20 +0200 Subject: [PATCH 06/60] Changed: #1023 Use a standard application path for writing files --- code/nel/include/nel/misc/path.h | 25 ++++-- code/nel/src/misc/path.cpp | 86 +++++++++++++------ code/ryzom/client/src/client.cpp | 2 +- .../tools/client/client_patcher/main.cpp | 8 +- 4 files changed, 85 insertions(+), 36 deletions(-) diff --git a/code/nel/include/nel/misc/path.h b/code/nel/include/nel/misc/path.h index 98896a216..f19050c90 100644 --- a/code/nel/include/nel/misc/path.h +++ b/code/nel/include/nel/misc/path.h @@ -224,6 +224,16 @@ public: */ std::string getWindowsDirectory(); + /** Get application directory. + * \return directory where applications should write files. + */ + std::string getApplicationDirectory(const std::string &appName = ""); + + /** Get a temporary directory. + * \return temporary directory where applications should write files. + */ + std::string getTemporaryDirectory(); + private: // All path in this vector must have a terminated '/' @@ -506,6 +516,16 @@ public: */ static std::string getWindowsDirectory(); + /** Get application directory. + * \return directory where applications should write files. + */ + static std::string getApplicationDirectory(const std::string &appName = ""); + + /** Get a temporary directory. + * \return temporary directory where applications should write files. + */ + static std::string getTemporaryDirectory(); + // release singleton static void releaseInstance(); @@ -700,11 +720,6 @@ struct CFile * Call this method to get a temporary output filename. If you have successfully saved your data, delete the old filename and move the new one. */ static void getTemporaryOutputFilename (const std::string &originalFilename, std::string &tempFilename); - - /** Get application directory. - * \return directory where applications should write files. - */ - static std::string getApplicationDirectory(const std::string &appName = ""); }; } // NLMISC diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 308b78af4..80911027b 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1686,6 +1686,66 @@ std::string CFileContainer::getWindowsDirectory() #endif } +std::string CPath::getApplicationDirectory(const std::string &appName) +{ + return getInstance()->_FileContainer.getApplicationDirectory(appName); +} + +std::string CFileContainer::getApplicationDirectory(const std::string &appName) +{ + static std::string appPath; + if (appPath.empty()) + { +#ifdef NL_OS_WINDOWS + wchar_t buffer[MAX_PATH]; + SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); + appPath = CPath::standardizePath(ucstring((ucchar*)buffer).toUtf8()); +#else + appPath = CPath::standardizePath(getenv("HOME")); +#endif + } + + std::string path = appPath; +#ifdef NL_OS_WINDOWS + if (!appName.empty()) + path = CPath::standardizePath(path + appName); +#else + if (!appName.empty()) + path = CPath::standardizePath(path + "." + toLower(appName)); +#endif + + return path; +} + +std::string CPath::getTemporaryDirectory() +{ + return getInstance()->_FileContainer.getTemporaryDirectory(); +} + +std::string CFileContainer::getTemporaryDirectory() +{ + static std::string path; + if (path.empty()) + { + char *tempDir = getenv("TEMP"); + + if (tempDir == NULL) + tempDir = getenv("TMP"); + +#ifdef NL_OS_UNIX + if (tempDir == NULL) + tempDir = "/tmp"; +#else + if (tempDir == NULL) + tempDir = "."; +#endif + + path = CPath::standardizePath(tempDir); + } + + return path; +} + ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2470,30 +2530,4 @@ void CFile::getTemporaryOutputFilename (const std::string &originalFilename, std while (CFile::isExists(tempFilename)); } -std::string CFile::getApplicationDirectory(const std::string &appName) -{ - static std::string appPath; - if (appPath.empty()) - { -#ifdef NL_OS_WINDOWS - wchar_t buffer[MAX_PATH]; - SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); - appPath = CPath::standardizePath(ucstring((ucchar*)buffer).toUtf8()); -#else - appPath = CPath::standardizePath(getenv("HOME")); -#endif - } - - std::string path = appPath; -#ifdef NL_OS_WINDOWS - if (!appName.empty()) - path = CPath::standardizePath(path + appName); -#else - if (!appName.empty()) - path = CPath::standardizePath(path + "." + toLower(appName)); -#endif - - return path; -} - } // NLMISC diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index 1c31a2e7b..7d5ddeb34 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -361,7 +361,7 @@ int main(int argc, char **argv) // if client_default.cfg is not in current directory, use application default directory if (!CFile::isExists("client_default.cfg")) { - std::string currentPath = CFile::getApplicationDirectory("Ryzom"); + std::string currentPath = CPath::getApplicationDirectory("Ryzom"); if (!CFile::isExists(currentPath)) CFile::createDirectory(currentPath); diff --git a/code/ryzom/tools/client/client_patcher/main.cpp b/code/ryzom/tools/client/client_patcher/main.cpp index 1c0affb9c..824ce093b 100644 --- a/code/ryzom/tools/client/client_patcher/main.cpp +++ b/code/ryzom/tools/client/client_patcher/main.cpp @@ -121,7 +121,7 @@ void printDownload(const std::string &str) // add padding with spaces memset(spaces, ' ', maxLength); spaces[maxLength - length] = '\0'; - + // display download in purple if (useEsc) { @@ -150,8 +150,8 @@ int main(int argc, char *argv[]) // init the Nel context CApplicationContext appContext; - // create logs in TEMP directory - createDebug(getenv("TEMP"), true, true); + // create logs in temporary directory + createDebug(CPath::getTemporaryDirectory(), true, true); // disable log display on stdout INelContext::getInstance().getDebugLog()->removeDisplayer("DEFAULT_SD"); @@ -198,7 +198,7 @@ int main(int argc, char *argv[]) } #endif - // create or load client.cfg + // load client.cfg or client_default.cfg ClientCfg.init(config); // check if PatchServer is defined From e8563f415699a94413a028f1474ed5a9c2e911f0 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 22:16:09 +0200 Subject: [PATCH 07/60] Changed: #1038 Implement copy/paste for Linux (patch provided by Naush) --- code/nel/include/nel/3d/driver_user.h | 5 + code/nel/include/nel/3d/u_driver.h | 9 + .../include/nel/misc/event_emitter_multi.h | 4 + .../3d/driver/direct3d/driver_direct3d.cpp | 8 + .../src/3d/driver/direct3d/driver_direct3d.h | 4 + code/nel/src/3d/driver/opengl/driver_opengl.h | 3 + .../3d/driver/opengl/driver_opengl_window.cpp | 10 + .../driver/opengl/mac/cocoa_event_emitter.cpp | 10 + .../driver/opengl/mac/cocoa_event_emitter.h | 5 +- .../3d/driver/opengl/unix_event_emitter.cpp | 254 +++++++++++++++++- .../src/3d/driver/opengl/unix_event_emitter.h | 14 + code/nel/src/3d/driver_user.cpp | 9 + code/nel/src/misc/event_emitter_multi.cpp | 12 +- 13 files changed, 342 insertions(+), 5 deletions(-) diff --git a/code/nel/include/nel/3d/driver_user.h b/code/nel/include/nel/3d/driver_user.h index 699691d89..1d079a2b7 100644 --- a/code/nel/include/nel/3d/driver_user.h +++ b/code/nel/include/nel/3d/driver_user.h @@ -535,6 +535,11 @@ public: virtual void deleteWaterEnvMap(UWaterEnvMap *map); // @} + // Copy a string to system clipboard. + virtual bool copyTextToClipboard(const ucstring &text); + + // Paste a string from system clipboard. + virtual bool pasteTextFromClipboard(ucstring &text); virtual uint64 getSwapBufferCounter(); diff --git a/code/nel/include/nel/3d/u_driver.h b/code/nel/include/nel/3d/u_driver.h index ce421b46d..9fe5c86d0 100644 --- a/code/nel/include/nel/3d/u_driver.h +++ b/code/nel/include/nel/3d/u_driver.h @@ -816,6 +816,15 @@ public: virtual uint64 getSwapBufferCounter() = 0; + /// \name Clipboard management + // @{ + // Copy a string to system clipboard. + virtual bool copyTextToClipboard(const ucstring &text) =0; + + // Paste a string from system clipboard. + virtual bool pasteTextFromClipboard(ucstring &text) =0; + // @} + public: /** diff --git a/code/nel/include/nel/misc/event_emitter_multi.h b/code/nel/include/nel/misc/event_emitter_multi.h index 6abdf08d8..73e28c16e 100644 --- a/code/nel/include/nel/misc/event_emitter_multi.h +++ b/code/nel/include/nel/misc/event_emitter_multi.h @@ -48,6 +48,10 @@ public: /// From IEventEmitter. This call submitEvents on all the emitters virtual void submitEvents(CEventServer &server, bool allWindows); virtual void emulateMouseRawMode(bool enable); + + virtual bool copyTextToClipboard(const ucstring &text); + virtual bool pasteTextFromClipboard(ucstring &text); + private: typedef std::vector > TEmitterCont; TEmitterCont _Emitters; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index d6af8cabc..0890a9084 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -3831,5 +3831,13 @@ void CDriverD3D::findNearestFullscreenVideoMode() } } } +bool CDriverD3D::copyTextToClipboard(const ucstring &text) +{ + return _EventEmitter.copyTextToClipboard(text); +} +bool CDriverD3D::pasteTextFromClipboard(ucstring &text) +{ + return _EventEmitter.pasteTextFromClipboard(text); +} } // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index ccd414782..82f73befc 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -2392,6 +2392,10 @@ public: void deleteIndexBuffer(CIBDrvInfosD3D *ib); // Build 16 bit index buffer for quad bool buildQuadIndexBuffer(); + + virtual bool copyTextToClipboard(const ucstring &text); + virtual bool pasteTextFromClipboard(ucstring &text); + public: #ifdef NL_DEBUG std::set _LockedBuffers; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index cf4f93a22..8e6b3a9b1 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -329,6 +329,9 @@ public: return _win; } + virtual bool copyTextToClipboard(const ucstring &text); + virtual bool pasteTextFromClipboard(ucstring &text); + virtual uint32 getAvailableVertexAGPMemory (); virtual uint32 getAvailableVertexVRAMMemory (); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index f82fbe746..7656e4242 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -2932,4 +2932,14 @@ void CDriverGL::setupApplicationMenu() } #endif +bool CDriverGL::copyTextToClipboard(const ucstring &text) +{ + return _EventEmitter.copyTextToClipboard(text); +} + +bool CDriverGL::pasteTextFromClipboard(ucstring &text) +{ + return _EventEmitter.pasteTextFromClipboard(text); +} + } // NL3D diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp index 86014e6cb..e1ce85dea 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp @@ -154,6 +154,16 @@ static NLMISC::TKey virtualKeycodeToNelKey(unsigned short keycode) return NLMISC::KeyNOKEY; } +bool CCocoaEventEmitter::pasteTextFromClipboard(ucstring &text) +{ + return false; +} + +bool CCocoaEventEmitter::copyTextToClipboard(const ucstring &text) +{ + return false; +} + /// convert modifier key state to nel internal modifier key state static NLMISC::TKeyButton modifierFlagsToNelKeyButton(unsigned int modifierFlags) { diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h index 72bfbb718..6680552b7 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h @@ -31,8 +31,9 @@ public: virtual void submitEvents(CEventServer & server, bool allWindows); virtual void emulateMouseRawMode(bool enable); -}; - + + virtual bool copyTextToClipboard(const ucstring &text); + virtual bool pasteTextFromClipboard(ucstring &text);}; } #endif diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp index f5de38371..6ae4c91c3 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp @@ -19,6 +19,8 @@ #if defined(NL_OS_UNIX) && !defined(NL_OS_MAC) +#include +#include #include #include #include @@ -33,6 +35,7 @@ CUnixEventEmitter::CUnixEventEmitter ():_dpy(NULL), _win(0), _emulateRawMode(fal { _im = 0; _ic = 0; + _SelectionOwned=false; } CUnixEventEmitter::~CUnixEventEmitter() @@ -47,12 +50,24 @@ void CUnixEventEmitter::init(Display *dpy, Window win, NL3D::IDriver *driver) _win = win; _driver = driver; - XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask); + XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask|ExposureMask); + _PrecomputedAtom[0] = XInternAtom(dpy, "CLIPBOARD", False); + #define XA_CLIPBOARD _PrecomputedAtom[0] + _PrecomputedAtom[1] = XInternAtom(dpy, "UTF8_STRING", False); + #define XA_UTF8_STRING _PrecomputedAtom[1] + _PrecomputedAtom[2] = XInternAtom(dpy, "TARGETS", False); + #define XA_TARGETS _PrecomputedAtom[2] + _PrecomputedAtom[3] = XInternAtom(dpy, "ATOM", False); + //#define XA_ATOM _PrecomputedAtom[3] + _PrecomputedAtom[4] = XInternAtom(dpy, "NeL_SEL", False); + #define XA_NEL_SEL _PrecomputedAtom[4] + _PrecomputedAtom[5] = XInternAtom(dpy, "TEXT", False); + #define XA_TEXT _PrecomputedAtom[5] /* TODO: implements all useful events processing EnterWindowMask|LeaveWindowMask|ButtonMotionMask|Button1MotionMask|Button2MotionMask| - Button3MotionMask|Button4MotionMask|Button5MotionMask|KeymapStateMask|ExposureMask| + Button3MotionMask|Button4MotionMask|Button5MotionMask|KeymapStateMask| SubstructureNotifyMask|VisibilityChangeMask|FocusChangeMask|PropertyChangeMask| ColormapChangeMask|OwnerGrabButtonMask */ @@ -578,6 +593,67 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) } break; } + case SelectionRequest: + { + XEvent respond; + XSelectionRequestEvent req = event.xselectionrequest; + + respond.xselection.type= SelectionNotify; + respond.xselection.display= req.display; + respond.xselection.requestor= req.requestor; + respond.xselection.selection=req.selection; + respond.xselection.target= req.target; + respond.xselection.time = req.time; + respond.xselection.property = req.property; + + if (req.property == None) + { + respond.xselection.property = req.target; + } + if (req.target == XA_TARGETS) + { + nlwarning("Client is asking for TARGETS"); + + Atom targets[] = + { + XA_TARGETS, + XA_TEXT, + XA_UTF8_STRING + }; + + respond.xselection.property = req.property; + + XChangeProperty(req.display, req.requestor, req.property, XA_ATOM, 32, PropModeReplace, (unsigned char *)targets, 3 /* number of element */); + } + else if (req.target == XA_TEXT || req.target == XA_STRING ) + { + nlwarning("client want TEXT"); + respond.xselection.property = req.property; + std::string str = _CopiedString.toString(); + XChangeProperty(req.display, req.requestor, req.property, XA_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), str.length()); + } + else if (req.target == XA_UTF8_STRING) + { + nlwarning("Client want UTF8 STRING"); + respond.xselection.property=req.property; + std::string str = _CopiedString.toUtf8(); + XChangeProperty(req.display, req.requestor, respond.xselection.property, XInternAtom(_dpy, "UTF8_STRING", False), 8, PropModeReplace, (const unsigned char*)str.c_str(), strlen((char*)str.c_str())); + } + else + { + nlwarning("Target doesn't want a string %u", (uint)req.target); // Note: Calling XGetAtomName with arbitrary value crash the client, maybe req.target have been sanitized by X11 server + respond.xselection.property = None; + } + + XSendEvent (_dpy, req.requestor, 0, 0, &respond); + + break; + } + case SelectionClear: + nlwarning("SelectionClear:"); + _SelectionOwned = false; + _CopiedString = ""; + break; case FocusIn: // keyboard focus if (_ic) XSetICFocus(_ic); @@ -605,6 +681,180 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) return true; } +/** + * This function copy a selection into propertyName. + * It is subject to timeout. + * + * @param selection: A Selection Atom + * @param requestedFormat: Target format Atom + * @param propertyName: Target property Atom + * @return true if successfull, false if timeout occured or X11 call failed + */ +bool CUnixEventEmitter::prepareSelectionContent (Atom selection, Atom requestedFormat, Atom propertyName) +{ + XConvertSelection(_dpy, selection, requestedFormat, propertyName, _win, CurrentTime); + + XSync(_dpy, False); + + int i = 0; + + bool gotReply = false; + + do + { + XEvent event; + usleep(500); + gotReply = XCheckTypedWindowEvent(_dpy, _win, SelectionNotify, &event); + if (gotReply) + { + return true; + } + i++; + } + while (i<20); + + return false; +} + +bool CUnixEventEmitter::copyTextToClipboard(const ucstring &text) +{ + _CopiedString = text; + + XSetSelectionOwner (_dpy, XA_CLIPBOARD, _win, CurrentTime); + { + Window selectionOwner = XGetSelectionOwner (_dpy, XA_CLIPBOARD); + + if ( selectionOwner != _win ) + { + nlwarning("Can't aquire selection"); + return false; + } + + _SelectionOwned = true; + + nlwarning("Owning selection"); + + return true; + } + + nlwarning("Paste: Can't acquire selection."); + + return false; +} + +bool CUnixEventEmitter::pasteTextFromClipboard(ucstring &text) +{ + // check if we own the selection + if (_SelectionOwned) + { + text = _CopiedString; + return true; + } + + Window selectionOwner = XGetSelectionOwner (_dpy, XA_CLIPBOARD); + + if (selectionOwner != None) + { + Atom *supportedTargets; + uint8 *data; + sint result; + unsigned long nitems, bytesLeft; + Atom actualType; + sint actualFormat; + sint bestTargetElect=0, bestTarget=0; + + nlwarning("Selection owner is %u", (uint)selectionOwner); + + // Find supported methods + bool bres = prepareSelectionContent(XA_CLIPBOARD, XA_TARGETS, XA_NEL_SEL); + + if (!bres) + { + nlwarning("Paste: Cannot ennumerate TARGETS"); + return false; + } + + result = XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft,(unsigned char**) &supportedTargets); + + if (result != Success) + { + return false; + } + + if ( bytesLeft>0 ) + { + nlwarning("Paste: Supported TARGETS list too long."); // We hope we find what we need in the first packet. + } + + // Elect best type + for (uint i=0; i < nitems; i++) + { + nldebug(" - Type=%s", XGetAtomName(_dpy, supportedTargets[i])); + + if (supportedTargets[i] == XA_STRING ) + { + if (bestTargetElect < 1) + { + bestTarget = XA_STRING; + bestTargetElect = 1; + } + } + + if (supportedTargets[i] == XA_UTF8_STRING ) + { + if (bestTargetElect < 2) + { + bestTarget = XA_UTF8_STRING; + bestTargetElect = 2; + } + } + } + + XFree(supportedTargets); + + if (!bestTargetElect) + { + nlwarning("Paste buffer is not a text buffer."); + return false; + } + + // Ask for selection lenght && copy to buffer + bres = prepareSelectionContent(XA_CLIPBOARD, bestTarget, XA_NEL_SEL); + + if (!bres) + { + nlwarning ("Paste: cannot obtain data. Aborting."); + return false; + } + + XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft,(unsigned char**) &data); + + std::string tmpData = (const char*)data; + XFree(data); + + switch (bestTargetElect) + { + case 1: // XA_STRING + text = tmpData; + return true; + + case 2: // XA_UTF8_STRING + text = ucstring::makeFromUtf8(tmpData); + return true; + + default: + break; + } + + nlwarning("Paste: buffer is not a text buffer."); + } + + nlwarning("Paste: error !"); + + return false; +} + + } // NLMISC #endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC) diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.h b/code/nel/src/3d/driver/opengl/unix_event_emitter.h index c6232330a..48d1f7803 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.h +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.h @@ -65,6 +65,16 @@ public: */ bool processMessage(XEvent &event, CEventServer *server = NULL); + /** + * Copy a string to system clipboard. + */ + virtual bool copyTextToClipboard(const ucstring &text); + + /* + * Paste a string from system clipboard. + */ + virtual bool pasteTextFromClipboard(ucstring &text); + private: // Private internal server message @@ -88,6 +98,7 @@ private: }; void createIM(); + bool prepareSelectionContent (Atom selection, Atom requestedFormat, Atom propertyName); Display* _dpy; Window _win; @@ -97,6 +108,9 @@ private: bool _emulateRawMode; NL3D::IDriver* _driver; CUnixEventServer _InternalServer; + ucstring _CopiedString; + Atom _PrecomputedAtom[6]; + bool _SelectionOwned; }; diff --git a/code/nel/src/3d/driver_user.cpp b/code/nel/src/3d/driver_user.cpp index 523aaf4ba..d6fccb362 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -1938,5 +1938,14 @@ bool CDriverUser::setRenderTarget(class UTexture & uTex, uint32 x, uint32 y, uin return result; } +bool CDriverUser::copyTextToClipboard(const ucstring &text) +{ + return _Driver->copyTextToClipboard(text); +} + +bool CDriverUser::pasteTextFromClipboard(ucstring &text) +{ + return _Driver->pasteTextFromClipboard(text); +} } // NL3D diff --git a/code/nel/src/misc/event_emitter_multi.cpp b/code/nel/src/misc/event_emitter_multi.cpp index 1c0e19084..815abd675 100644 --- a/code/nel/src/misc/event_emitter_multi.cpp +++ b/code/nel/src/misc/event_emitter_multi.cpp @@ -16,7 +16,7 @@ #include "stdmisc.h" #include "nel/misc/event_emitter_multi.h" - +#include "nel/misc/system_utils.h" namespace NLMISC { @@ -99,7 +99,17 @@ const IEventEmitter *CEventEmitterMulti::getEmitter(uint index) const return _Emitters[index].first; } +bool CEventEmitterMulti::copyTextToClipboard(const ucstring &text) +{ + // Naush: wrapped to old API to avoid duplicate code + return CSystemUtils::copyTextToClipboard(text); +} +bool CEventEmitterMulti::pasteTextFromClipboard(ucstring &text) +{ + // Naush: wrapped to old API to avoid duplicate code + return CSystemUtils::pasteTextFromClipboard(text); +} } // NLMISC From 106ef09c23141aea142c28e279ca6ae1ffd2f576 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 22:19:49 +0200 Subject: [PATCH 08/60] Changed: #1038 Implement copy/paste for Linux (patch provided by Naush) --- code/ryzom/client/src/interface_v3/group_editbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index afbf8e61a..a1c43d7a3 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -332,7 +332,7 @@ void CGroupEditBox::copy() stopParentBlink(); // get the selection and copy it - if (CSystemUtils::copyTextToClipboard(getSelection())) + if (Driver->copyTextToClipboard(getSelection())) nlinfo ("Chat input was copied in the clipboard"); } @@ -352,7 +352,7 @@ void CGroupEditBox::paste() ucstring sString; - if (CSystemUtils::pasteTextFromClipboard(sString)) + if (Driver->pasteTextFromClipboard(sString)) { sint length = (sint)sString.length(); From d3aec1d246c5ad472e932aa064468ad340209742 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 16 Oct 2010 22:32:19 +0200 Subject: [PATCH 09/60] Changed: #1038 Implement copy/paste for Linux (patch provided by Naush) --- code/nel/include/nel/3d/driver.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 914a1ea57..329dd19d2 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -558,6 +558,12 @@ public: /// Swap the back and front buffers. virtual bool swapBuffers(void)=0; + /// Copy a string to system clipboard. + virtual bool copyTextToClipboard(const ucstring &text) =0; + + /// Paste a string from system clipboard. + virtual bool pasteTextFromClipboard(ucstring &text) =0; + /** set the number of VBL wait when a swapBuffers() is issued. 0 means no synchronisation to the VBL * Default is 1. Values >1 may be clamped to 1 by the driver. */ From beaeccf2ce9473c610071fd75024bc2779a98239 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 17 Oct 2010 15:26:57 +0200 Subject: [PATCH 10/60] Changed: #825 Remove all warning when compiling Ryzom --- code/nel/src/3d/driver/opengl/driver_opengl.cpp | 7 +++---- code/nel/src/3d/driver/opengl/driver_opengl_window.cpp | 2 +- code/nel/src/misc/i_xml.cpp | 2 +- code/nel/src/misc/win_event_emitter.cpp | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 5ab7c7475..44eea09bd 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -341,7 +341,7 @@ CDriverGL::~CDriverGL() { H_AUTO_OGL(CDriverGL_CDriverGLDtor) release(); - + #if defined(NL_OS_MAC) [_autoreleasePool release]; #endif @@ -362,8 +362,8 @@ bool CDriverGL::setupDisplay() nlinfo("3D: %s", lines[i].c_str()); #ifdef NL_OS_WINDOWS - NL3D::registerWGlExtensions (_Extensions, _hDC); -#endif // ifdef NL_OS_WINDOWS + NL3D::registerWGlExtensions(_Extensions, _hDC); +#endif // NL_OS_WINDOWS // Check required extensions!! // ARBMultiTexture is a OpenGL 1.2 required extension. @@ -851,7 +851,6 @@ bool CDriverGL::swapBuffers() } } - #ifdef NL_OS_WINDOWS if (_EventEmitter.getNumEmitters() > 1) // is direct input running ? { diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 7656e4242..13b48c662 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -135,7 +135,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l case SC_MONITORPOWER: // Prevent From Happening - return 0; + return 0; default: break; diff --git a/code/nel/src/misc/i_xml.cpp b/code/nel/src/misc/i_xml.cpp index 91a32a225..3b198a53c 100644 --- a/code/nel/src/misc/i_xml.cpp +++ b/code/nel/src/misc/i_xml.cpp @@ -1083,7 +1083,7 @@ int CIXml::getIntProperty(xmlNodePtr node, const char *property, int defaultValu return defaultValue; s=s.strip(); - int val=s.atoi(); + sint val=s.atoi(); if (val==0 && s!="0") { nlwarning("bad integer value: %s",s.c_str()); diff --git a/code/nel/src/misc/win_event_emitter.cpp b/code/nel/src/misc/win_event_emitter.cpp index fc01a8b62..2c46a7530 100644 --- a/code/nel/src/misc/win_event_emitter.cpp +++ b/code/nel/src/misc/win_event_emitter.cpp @@ -128,11 +128,11 @@ bool CWinEventEmitter::processMessage (HWND hWnd, uint32 msg, WPARAM wParam, LPA if (_KeyboardEventsEnabled) { // Ctrl, shit or alt ? - if ((int)wParam==VK_MENU) + if ((sint)wParam==VK_MENU) _AltButton=true; - if ((int)wParam==VK_CONTROL) + if ((sint)wParam==VK_CONTROL) _CtrlButton=true; - if ((int)wParam==VK_SHIFT) + if ((sint)wParam==VK_SHIFT) _ShiftButton=true; // Post the message From 5a526b01e70eb12beaf30ff2d8d3bac644a51085 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 17 Oct 2010 16:29:18 +0200 Subject: [PATCH 11/60] Changed: #1038 Implement copy/paste for Linux --- code/nel/include/nel/misc/events.h | 16 + .../3d/driver/opengl/unix_event_emitter.cpp | 322 ++++++++---------- .../src/3d/driver/opengl/unix_event_emitter.h | 2 - 3 files changed, 164 insertions(+), 176 deletions(-) diff --git a/code/nel/include/nel/misc/events.h b/code/nel/include/nel/misc/events.h index 23dd83d5f..53418c8be 100644 --- a/code/nel/include/nel/misc/events.h +++ b/code/nel/include/nel/misc/events.h @@ -19,6 +19,7 @@ #include "types_nl.h" #include "class_id.h" +#include "ucstring.h" #include #include @@ -58,6 +59,7 @@ protected: const CClassId EventKeyDownId (0x3c2643da, 0x43f802a1); const CClassId EventKeyUpId (0x1e62e85, 0x68a35d46); const CClassId EventCharId (0x552255fe, 0x75a2373f); +const CClassId EventStringId (0x49b5af8f, 0x7f52cd26); // Window events const CClassId EventActivateId (0x7da66b0a, 0x1ef74519); @@ -327,6 +329,20 @@ private: }; +/** + * CEventString + */ +class CEventString : public CEventKey +{ +public: + CEventString (const ucstring &str, IEventEmitter* emitter) : CEventKey (noKeyButton, emitter, EventStringId) + { + String = str; + } + ucstring String; + + virtual CEvent *clone() const {return new CEventString(*this);} +}; /** * CEventMouse. diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp index 6ae4c91c3..9f86c8c89 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp @@ -29,6 +29,11 @@ typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e); +static Atom XA_CLIPBOARD = 0; +static Atom XA_UTF8_STRING = 0; +static Atom XA_TARGETS = 0; +static Atom XA_NEL_SEL = 0; + namespace NLMISC { CUnixEventEmitter::CUnixEventEmitter ():_dpy(NULL), _win(0), _emulateRawMode(false), _driver(NULL) @@ -51,18 +56,12 @@ void CUnixEventEmitter::init(Display *dpy, Window win, NL3D::IDriver *driver) _driver = driver; XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask|ExposureMask); - _PrecomputedAtom[0] = XInternAtom(dpy, "CLIPBOARD", False); - #define XA_CLIPBOARD _PrecomputedAtom[0] - _PrecomputedAtom[1] = XInternAtom(dpy, "UTF8_STRING", False); - #define XA_UTF8_STRING _PrecomputedAtom[1] - _PrecomputedAtom[2] = XInternAtom(dpy, "TARGETS", False); - #define XA_TARGETS _PrecomputedAtom[2] - _PrecomputedAtom[3] = XInternAtom(dpy, "ATOM", False); - //#define XA_ATOM _PrecomputedAtom[3] - _PrecomputedAtom[4] = XInternAtom(dpy, "NeL_SEL", False); - #define XA_NEL_SEL _PrecomputedAtom[4] - _PrecomputedAtom[5] = XInternAtom(dpy, "TEXT", False); - #define XA_TEXT _PrecomputedAtom[5] + + // define Atoms used by clipboard + XA_CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); + XA_UTF8_STRING = XInternAtom(dpy, "UTF8_STRING", False); + XA_TARGETS = XInternAtom(dpy, "TARGETS", False); + XA_NEL_SEL = XInternAtom(dpy, "NeL_SEL", False); /* TODO: implements all useful events processing @@ -568,10 +567,23 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) #ifdef X_HAVE_UTF8_STRING ucstring ucstr; ucstr.fromUtf8(Text); - server->postEvent (new CEventChar (ucstr[0], noKeyButton, this)); + + CEventChar *charEvent = new CEventChar (ucstr[0], noKeyButton, this); + + // raw if not processed by IME + charEvent->setRaw(keyCode != 0); + + server->postEvent (charEvent); #else for (int i = 0; i < c; i++) - server->postEvent (new CEventChar ((ucchar)(unsigned char)Text[i], noKeyButton, this)); + { + CEventChar *charEvent = new CEventChar ((ucchar)(unsigned char)Text[i], noKeyButton, this); + + // raw if not processed by IME + charEvent->setRaw(keyCode != 0); + + server->postEvent (charEvent); + } #endif } break; @@ -612,12 +624,10 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) } if (req.target == XA_TARGETS) { - nlwarning("Client is asking for TARGETS"); - Atom targets[] = { XA_TARGETS, - XA_TEXT, + XA_STRING, XA_UTF8_STRING }; @@ -625,23 +635,21 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) XChangeProperty(req.display, req.requestor, req.property, XA_ATOM, 32, PropModeReplace, (unsigned char *)targets, 3 /* number of element */); } - else if (req.target == XA_TEXT || req.target == XA_STRING ) + else if (req.target == XA_STRING) { - nlwarning("client want TEXT"); respond.xselection.property = req.property; std::string str = _CopiedString.toString(); XChangeProperty(req.display, req.requestor, req.property, XA_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), str.length()); } else if (req.target == XA_UTF8_STRING) { - nlwarning("Client want UTF8 STRING"); - respond.xselection.property=req.property; + respond.xselection.property = req.property; std::string str = _CopiedString.toUtf8(); - XChangeProperty(req.display, req.requestor, respond.xselection.property, XInternAtom(_dpy, "UTF8_STRING", False), 8, PropModeReplace, (const unsigned char*)str.c_str(), strlen((char*)str.c_str())); + XChangeProperty(req.display, req.requestor, respond.xselection.property, XA_UTF8_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), str.length()); } else { - nlwarning("Target doesn't want a string %u", (uint)req.target); // Note: Calling XGetAtomName with arbitrary value crash the client, maybe req.target have been sanitized by X11 server + // Note: Calling XGetAtomName with arbitrary value crash the client, maybe req.target have been sanitized by X11 server respond.xselection.property = None; } @@ -650,16 +658,111 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) break; } case SelectionClear: - nlwarning("SelectionClear:"); _SelectionOwned = false; _CopiedString = ""; break; + case SelectionNotify: + { + Atom target = event.xselection.target; + + Atom actualType = 0; + int actualFormat = 0; + unsigned long nitems = 0, bytesLeft = 0; + + // some applications are sending ATOM and other TARGETS + if (target == XA_TARGETS || target == XA_ATOM) + { + Atom *supportedTargets = NULL; + + // list NeL selection properties + if (XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft, (unsigned char**)&supportedTargets) != Success) + return false; + + if (bytesLeft > 0) + { + nlwarning("Paste: Supported TARGETS list too long."); + } + + Atom bestTarget = 0; + sint bestTargetElect = 0; + + // Elect best type + for (uint i=0; i < nitems; i++) + { + // nlwarning(" - Type=%s (%u)", XGetAtomName(_dpy, supportedTargets[i]), (uint)supportedTargets[i]); + if (supportedTargets[i] == XA_UTF8_STRING ) + { + if (bestTargetElect < 2) + { + bestTarget = XA_UTF8_STRING; + bestTargetElect = 2; + } + } + else if (supportedTargets[i] == XA_STRING ) + { + if (bestTargetElect < 1) + { + bestTarget = XA_STRING; + bestTargetElect = 1; + } + } + } + + XFree(supportedTargets); + + if (!bestTargetElect) + { + nlwarning("Paste buffer is not a text buffer."); + return false; + } + + // request string conversion + XConvertSelection(_dpy, XA_CLIPBOARD, bestTarget, XA_NEL_SEL, _win, CurrentTime); + } + else if (target == XA_UTF8_STRING || target == XA_STRING) + { + uint8 *data = NULL; + + // get selection + if (XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft, (unsigned char**)&data) != Success) + return false; + + ucstring text; + std::string tmpData = (const char*)data; + XFree(data); + + // convert buffer to ucstring + if (target == XA_UTF8_STRING) + { + text = ucstring::makeFromUtf8(tmpData); + } + else if (target == XA_STRING) + { + text = tmpData; + } + else + { + nlwarning("Unknow format %u", (uint)target); + } + + // sent string event to event server + server->postEvent (new CEventString (text, this)); + } + else + { + nlwarning("Unknow target %u", (uint)target); + } + + break; + } case FocusIn: // keyboard focus + server->postEvent (new CEventSetFocus (true, this)); if (_ic) XSetICFocus(_ic); break; case FocusOut: // keyboard focus + server->postEvent (new CEventSetFocus (false, this)); if (_ic) XUnsetICFocus(_ic); break; case KeymapNotify: @@ -672,6 +775,12 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) // XIM server has crashed createIM(); break; + case ClientMessage: + if ((xevent.xclient.format == 32) && (xevent.xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) + { + server->postEvent (new CEventDestroyWindow (this)); + } + break; default: // nlinfo("UnknownEvent"); // XtDispatchEvent(&event); @@ -681,65 +790,23 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) return true; } -/** - * This function copy a selection into propertyName. - * It is subject to timeout. - * - * @param selection: A Selection Atom - * @param requestedFormat: Target format Atom - * @param propertyName: Target property Atom - * @return true if successfull, false if timeout occured or X11 call failed - */ -bool CUnixEventEmitter::prepareSelectionContent (Atom selection, Atom requestedFormat, Atom propertyName) -{ - XConvertSelection(_dpy, selection, requestedFormat, propertyName, _win, CurrentTime); - - XSync(_dpy, False); - - int i = 0; - - bool gotReply = false; - - do - { - XEvent event; - usleep(500); - gotReply = XCheckTypedWindowEvent(_dpy, _win, SelectionNotify, &event); - if (gotReply) - { - return true; - } - i++; - } - while (i<20); - - return false; -} - bool CUnixEventEmitter::copyTextToClipboard(const ucstring &text) { _CopiedString = text; - XSetSelectionOwner (_dpy, XA_CLIPBOARD, _win, CurrentTime); + // NeL window is the owner of clipboard + XSetSelectionOwner(_dpy, XA_CLIPBOARD, _win, CurrentTime); + + // check we are owning the clipboard + if (XGetSelectionOwner(_dpy, XA_CLIPBOARD) != _win) { - Window selectionOwner = XGetSelectionOwner (_dpy, XA_CLIPBOARD); - - if ( selectionOwner != _win ) - { - nlwarning("Can't aquire selection"); - return false; - } - - _SelectionOwned = true; - - nlwarning("Owning selection"); - - return true; + nlwarning("Can't aquire selection"); + return false; } - nlwarning("Paste: Can't acquire selection."); + _SelectionOwned = true; - return false; + return true; } bool CUnixEventEmitter::pasteTextFromClipboard(ucstring &text) @@ -751,110 +818,17 @@ bool CUnixEventEmitter::pasteTextFromClipboard(ucstring &text) return true; } - Window selectionOwner = XGetSelectionOwner (_dpy, XA_CLIPBOARD); + // check if there is a data in clipboard + if (XGetSelectionOwner(_dpy, XA_CLIPBOARD) == None) + return false; - if (selectionOwner != None) - { - Atom *supportedTargets; - uint8 *data; - sint result; - unsigned long nitems, bytesLeft; - Atom actualType; - sint actualFormat; - sint bestTargetElect=0, bestTarget=0; - - nlwarning("Selection owner is %u", (uint)selectionOwner); - - // Find supported methods - bool bres = prepareSelectionContent(XA_CLIPBOARD, XA_TARGETS, XA_NEL_SEL); - - if (!bres) - { - nlwarning("Paste: Cannot ennumerate TARGETS"); - return false; - } - - result = XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft,(unsigned char**) &supportedTargets); - - if (result != Success) - { - return false; - } - - if ( bytesLeft>0 ) - { - nlwarning("Paste: Supported TARGETS list too long."); // We hope we find what we need in the first packet. - } - - // Elect best type - for (uint i=0; i < nitems; i++) - { - nldebug(" - Type=%s", XGetAtomName(_dpy, supportedTargets[i])); - - if (supportedTargets[i] == XA_STRING ) - { - if (bestTargetElect < 1) - { - bestTarget = XA_STRING; - bestTargetElect = 1; - } - } - - if (supportedTargets[i] == XA_UTF8_STRING ) - { - if (bestTargetElect < 2) - { - bestTarget = XA_UTF8_STRING; - bestTargetElect = 2; - } - } - } - - XFree(supportedTargets); - - if (!bestTargetElect) - { - nlwarning("Paste buffer is not a text buffer."); - return false; - } - - // Ask for selection lenght && copy to buffer - bres = prepareSelectionContent(XA_CLIPBOARD, bestTarget, XA_NEL_SEL); - - if (!bres) - { - nlwarning ("Paste: cannot obtain data. Aborting."); - return false; - } - - XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft,(unsigned char**) &data); - - std::string tmpData = (const char*)data; - XFree(data); - - switch (bestTargetElect) - { - case 1: // XA_STRING - text = tmpData; - return true; - - case 2: // XA_UTF8_STRING - text = ucstring::makeFromUtf8(tmpData); - return true; - - default: - break; - } - - nlwarning("Paste: buffer is not a text buffer."); - } - - nlwarning("Paste: error !"); + // request supported methods + XConvertSelection(_dpy, XA_CLIPBOARD, XA_TARGETS, XA_NEL_SEL, _win, CurrentTime); + // don't return result now return false; } - } // NLMISC #endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC) diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.h b/code/nel/src/3d/driver/opengl/unix_event_emitter.h index 48d1f7803..1a17ecd1f 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.h +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.h @@ -98,7 +98,6 @@ private: }; void createIM(); - bool prepareSelectionContent (Atom selection, Atom requestedFormat, Atom propertyName); Display* _dpy; Window _win; @@ -109,7 +108,6 @@ private: NL3D::IDriver* _driver; CUnixEventServer _InternalServer; ucstring _CopiedString; - Atom _PrecomputedAtom[6]; bool _SelectionOwned; }; From c1fd96584954431795a11fb848f345ba2948992b Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 17 Oct 2010 16:38:43 +0200 Subject: [PATCH 12/60] Changed: #1038 Implement copy/paste for Linux --- .../src/interface_v3/event_descriptor.cpp | 5 + .../src/interface_v3/event_descriptor.h | 12 +- .../client/src/interface_v3/group_editbox.cpp | 317 +++++++++--------- .../client/src/interface_v3/group_editbox.h | 2 + .../interface_v3/input_handler_manager.cpp | 5 +- 5 files changed, 188 insertions(+), 153 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/event_descriptor.cpp b/code/ryzom/client/src/interface_v3/event_descriptor.cpp index e2178540a..2e72c69c2 100644 --- a/code/ryzom/client/src/interface_v3/event_descriptor.cpp +++ b/code/ryzom/client/src/interface_v3/event_descriptor.cpp @@ -40,6 +40,11 @@ void CEventDescriptorKey::init(const NLMISC::CEventKey &ev) _KeyEvent = keydown; _Key = ((const NLMISC::CEventKeyDown &) ev).Key; } + else if (ev == NLMISC::EventStringId) + { + _KeyEvent = keystring; + _String = ((const NLMISC::CEventString &) ev).String; + } else { _KeyEvent = unknown; diff --git a/code/ryzom/client/src/interface_v3/event_descriptor.h b/code/ryzom/client/src/interface_v3/event_descriptor.h index 5034b940c..fc601806f 100644 --- a/code/ryzom/client/src/interface_v3/event_descriptor.h +++ b/code/ryzom/client/src/interface_v3/event_descriptor.h @@ -54,6 +54,7 @@ public: keydown = 0, // a key has been press down. The key value is stored as a TKey keyup, // a key has been released. The key value is stored as a TKey keychar, // a key has been stroke. The key is a ucchar + keystring, // a string has been sent. The string is a ucstring unknown, // uninitialized event }; CEventDescriptorKey() : _KeyEvent(unknown) @@ -80,6 +81,12 @@ public: nlassert(_KeyEvent == keychar); return _Char; } + // return the string that has been sent. The key event type MUST be 'keystring', else => assert + ucstring getString() const + { + nlassert(_KeyEvent == keystring); + return _String; + } bool getKeyCtrl() const // is CTRL pressed ? { return _CtrlState; @@ -102,9 +109,10 @@ private: bool _AltState; union { - NLMISC::TKey _Key; - ucchar _Char; + NLMISC::TKey _Key; + ucchar _Char; }; + ucstring _String; }; // ---------------------------------------------------------------------------- diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index a1c43d7a3..e690dfbe1 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -347,155 +347,163 @@ void CGroupEditBox::paste() } cutSelection(); } - stopParentBlink(); - makeTopWindow(); ucstring sString; if (Driver->pasteTextFromClipboard(sString)) { - sint length = (sint)sString.length(); - - ucstring toAppend; - // filter character depending on the netry type - switch (_EntryType) - { - case Text: - case Password: - { - if (_NegativeFilter.empty()) - { - toAppend = sString; - } - else - { - for (sint k = 0; k < length; ++k) - { - if (!isFiltered(sString[k])) - { - toAppend += sString[k]; - } - } - } - // remove '\r' characters - toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (ucchar) '\r'), toAppend.end()); - - } - break; - case PositiveInteger: - case PositiveFloat: - { - for (sint k = 0; k < length; ++k) - { - if (isdigit(sString[k]) || sString[k]== ' ' || - (_EntryType==PositiveFloat && sString[k]=='.') ) - { - if (!isFiltered(sString[k])) - { - toAppend += sString[k]; - } - } - } - } - break; - case Integer: - case Float: - { - for (sint k = 0; k < length; ++k) - { - if (isdigit(sString[k]) || sString[k]== ' ' || sString[k]== '-' || - (_EntryType==Float && sString[k]=='.') ) - { - if (!isFiltered(sString[k])) - { - toAppend += sString[k]; - } - } - } - } - break; - case AlphaNumSpace: - { - for (sint k = 0; k < length; ++k) - { - if (isValidAlphaNumSpace(sString[k])) - { - if (!isFiltered(sString[k])) - { - toAppend += sString[k]; - } - } - } - } - break; - case AlphaNum: - { - for (sint k = 0; k < length; ++k) - { - if (isValidAlphaNum(sString[k])) - { - if (!isFiltered(sString[k])) - { - toAppend += sString[k]; - } - } - } - } - break; - case Alpha: - { - for (sint k = 0; k < length; ++k) - { - if (isValidAlpha(sString[k])) - { - if (!isFiltered(sString[k])) - { - toAppend += sString[k]; - } - } - } - } - break; - case Filename: - { - for (sint k = 0; k < length; ++k) - { - if (isValidFilenameChar(sString[k])) - { - if (!isFiltered(sString[k])) - { - toAppend += sString[k]; - } - } - } - } - break; - case PlayerName: - { - for (sint k = 0; k < length; ++k) - { - if (isValidPlayerNameChar(sString[k])) - { - if (!isFiltered(sString[k])) - { - toAppend += sString[k]; - } - } - } - } - } - length = (sint)toAppend.size(); - if ((uint) (_InputString.length() + length) > _MaxNumChar) - { - length = _MaxNumChar - (sint)_InputString.length(); - } - ucstring toAdd = toAppend.substr(0, length); - _InputString = _InputString.substr(0, _CursorPos) + toAdd + _InputString.substr(_CursorPos); - _CursorPos += (sint32)toAdd.length(); - nlinfo ("Chat input was pasted from the clipboard"); - - triggerOnChangeAH(); + // append string now + appendString(sString); } +} + +// ---------------------------------------------------------------------------- +void CGroupEditBox::appendString(const ucstring &str) +{ + stopParentBlink(); + makeTopWindow(); + + sint length = (sint)str.length(); + + ucstring toAppend; + // filter character depending on the entry type + switch (_EntryType) + { + case Text: + case Password: + { + if (_NegativeFilter.empty()) + { + toAppend = str; + } + else + { + for (sint k = 0; k < length; ++k) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + // remove '\r' characters + toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (ucchar) '\r'), toAppend.end()); + + } + break; + case PositiveInteger: + case PositiveFloat: + { + for (sint k = 0; k < length; ++k) + { + if (isdigit(str[k]) || str[k]== ' ' || + (_EntryType==PositiveFloat && str[k]=='.') ) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case Integer: + case Float: + { + for (sint k = 0; k < length; ++k) + { + if (isdigit(str[k]) || str[k]== ' ' || str[k]== '-' || + (_EntryType==Float && str[k]=='.') ) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case AlphaNumSpace: + { + for (sint k = 0; k < length; ++k) + { + if (isValidAlphaNumSpace(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case AlphaNum: + { + for (sint k = 0; k < length; ++k) + { + if (isValidAlphaNum(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case Alpha: + { + for (sint k = 0; k < length; ++k) + { + if (isValidAlpha(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case Filename: + { + for (sint k = 0; k < length; ++k) + { + if (isValidFilenameChar(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case PlayerName: + { + for (sint k = 0; k < length; ++k) + { + if (isValidPlayerNameChar(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + } + length = (sint)toAppend.size(); + if ((uint) (_InputString.length() + length) > _MaxNumChar) + { + length = _MaxNumChar - (sint)_InputString.length(); + } + ucstring toAdd = toAppend.substr(0, length); + _InputString = _InputString.substr(0, _CursorPos) + toAdd + _InputString.substr(_CursorPos); + _CursorPos += (sint32)toAdd.length(); + nlinfo ("Chat input was pasted from the clipboard"); + + triggerOnChangeAH(); _CursorAtPreviousLineEnd = false; } @@ -610,6 +618,8 @@ void CGroupEditBox::handleEventChar(const CEventDescriptorKey &rEDK) if (!isValidPlayerNameChar(c)) return; break; + default: + break; } // verify integer bounds if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX)) @@ -658,6 +668,11 @@ void CGroupEditBox::handleEventChar(const CEventDescriptorKey &rEDK) } } +// ---------------------------------------------------------------------------- +void CGroupEditBox::handleEventString(const CEventDescriptorKey &rEDK) +{ + appendString(rEDK.getString()); +} // ---------------------------------------------------------------------------- bool CGroupEditBox::undo() @@ -720,7 +735,7 @@ bool CGroupEditBox::expand() if (_InputString[0] == '/') { makeTopWindow(); - // for french or deutch, be aware of unicode + // for french, deutsch and russian, be aware of unicode std::string command = ucstring(_InputString.substr(1)).toUtf8(); ICommand::expand(command); // then back to ucstring @@ -788,12 +803,14 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event) switch(rEDK.getKeyEventType()) { case CEventDescriptorKey::keychar: handleEventChar(rEDK); break; + case CEventDescriptorKey::keystring: handleEventString(rEDK); break; + default: break; } // update the text setInputString(_InputString); - // if event of type char, consider handle all of them - if( rEDK.getKeyEventType()==CEventDescriptorKey::keychar ) + // if event of type char or string, consider handle all of them + if( rEDK.getKeyEventType()==CEventDescriptorKey::keychar || rEDK.getKeyEventType()==CEventDescriptorKey::keystring ) return true; // Else filter the EventKeyDown AND EventKeyUp. else @@ -1089,16 +1106,16 @@ void CGroupEditBox::setInputStringAsInt(sint32 val) // *************************************************************************** sint64 CGroupEditBox::getInputStringAsInt64() const -{ - sint32 value; +{ + sint64 value; fromString(_InputString.toString(), value); return value; } // *************************************************************************** void CGroupEditBox::setInputStringAsInt64(sint64 val) -{ - setInputString(NLMISC::toString(val)); +{ + setInputString(NLMISC::toString(val)); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_editbox.h b/code/ryzom/client/src/interface_v3/group_editbox.h index 3b2bc7fc9..c8f8bf457 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.h +++ b/code/ryzom/client/src/interface_v3/group_editbox.h @@ -288,8 +288,10 @@ private: void setupDisplayText(); void makeTopWindow(); void handleEventChar(const CEventDescriptorKey &event); + void handleEventString(const CEventDescriptorKey &event); void setup(); void triggerOnChangeAH(); + void appendString(const ucstring &str); ucstring getSelection(); diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index 6fae67260..3fa53ef42 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -104,6 +104,7 @@ void CInputHandlerManager::addToServer(NLMISC::CEventServer * server) server->addListener(EventMouseDblClkId, this); // Keyboard + server->addListener(EventStringId, this); server->addListener(EventCharId, this); server->addListener(EventKeyDownId, this); server->addListener(EventKeyUpId, this); @@ -127,6 +128,7 @@ void CInputHandlerManager::release() _EventServer->removeListener(EventMouseDblClkId, this); // Keyboard + _EventServer->removeListener(EventStringId, this); _EventServer->removeListener(EventCharId, this); _EventServer->removeListener(EventKeyDownId, this); _EventServer->removeListener(EventKeyUpId, this); @@ -230,7 +232,8 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) // **** Event Keyboard if( event == EventKeyDownId || event == EventKeyUpId || - event == EventCharId) + event == EventCharId || + event == EventStringId) { // if not handled, post to Action Manager if( !pIM->handleEvent( CEventDescriptorKey((const CEventKey &) event) ) ) From 1e3e7e384907782cbb0fb09bf842a72d61cc343a Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 17 Oct 2010 17:21:33 +0200 Subject: [PATCH 13/60] Changed: #825 Remove all warning when compiling Ryzom --- code/nel/tools/misc/log_analyser/log_analyserDlg.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp b/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp index 1f09bd91e..f90881f99 100644 --- a/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp +++ b/code/nel/tools/misc/log_analyser/log_analyserDlg.cpp @@ -59,8 +59,7 @@ afx_msg void CLAEdit::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) int start, end; GetSel( start, end ); str = str.Mid( start, end-start ); - sint lineNum; - NLMISC::fromString(str, lineNum); + int lineNum = atoi(str); if ( ! ((lineNum != 0) || (str == "0")) ) break; @@ -714,8 +713,7 @@ void CLog_analyserDlg::insertTraceLine( int index, char *traceLine ) char *line = strchr( traceLine, ':' ); char scycle [10]; strncpy( scycle, traceLine, line-traceLine ); - sint cycle; - NLMISC::fromString(scycle, cycle); + int cycle = atoi(scycle); TStampedLine stampedLine; stampedLine.Index = index; stampedLine.Line = CString(traceLine); From 45a9a519db927e7b442e9afe2c1ca99238e4181e Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 17 Oct 2010 17:22:19 +0200 Subject: [PATCH 14/60] Changed: #1038 Implement copy/paste for Linux --- code/nel/src/3d/driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/3d/driver.cpp b/code/nel/src/3d/driver.cpp index 43a1778ee..0caf4a508 100644 --- a/code/nel/src/3d/driver.cpp +++ b/code/nel/src/3d/driver.cpp @@ -33,7 +33,7 @@ namespace NL3D { // *************************************************************************** -const uint32 IDriver::InterfaceVersion = 0x68; // added setWindowIcon +const uint32 IDriver::InterfaceVersion = 0x69; // added clipboard methods // *************************************************************************** IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" ) From 5a5ea67ca735ae9cf952e04f914697d98990fb8d Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 17 Oct 2010 23:25:09 +0200 Subject: [PATCH 15/60] Changed: #1038 Implement copy/paste for Linux --- .../3d/driver/opengl/unix_event_emitter.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp index 9f86c8c89..19b76923e 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp @@ -664,7 +664,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) case SelectionNotify: { Atom target = event.xselection.target; - + Atom actualType = 0; int actualFormat = 0; unsigned long nitems = 0, bytesLeft = 0; @@ -673,19 +673,19 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) if (target == XA_TARGETS || target == XA_ATOM) { Atom *supportedTargets = NULL; - + // list NeL selection properties if (XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft, (unsigned char**)&supportedTargets) != Success) return false; - + if (bytesLeft > 0) { nlwarning("Paste: Supported TARGETS list too long."); } - + Atom bestTarget = 0; sint bestTargetElect = 0; - + // Elect best type for (uint i=0; i < nitems; i++) { @@ -715,22 +715,22 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) nlwarning("Paste buffer is not a text buffer."); return false; } - + // request string conversion XConvertSelection(_dpy, XA_CLIPBOARD, bestTarget, XA_NEL_SEL, _win, CurrentTime); } else if (target == XA_UTF8_STRING || target == XA_STRING) { uint8 *data = NULL; - + // get selection if (XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft, (unsigned char**)&data) != Success) return false; - + ucstring text; std::string tmpData = (const char*)data; XFree(data); - + // convert buffer to ucstring if (target == XA_UTF8_STRING) { @@ -752,17 +752,17 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) { nlwarning("Unknow target %u", (uint)target); } - + break; } case FocusIn: // keyboard focus - server->postEvent (new CEventSetFocus (true, this)); +// server->postEvent (new CEventSetFocus (true, this)); if (_ic) XSetICFocus(_ic); break; case FocusOut: // keyboard focus - server->postEvent (new CEventSetFocus (false, this)); +// server->postEvent (new CEventSetFocus (false, this)); if (_ic) XUnsetICFocus(_ic); break; case KeymapNotify: @@ -776,10 +776,10 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) createIM(); break; case ClientMessage: - if ((xevent.xclient.format == 32) && (xevent.xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) - { - server->postEvent (new CEventDestroyWindow (this)); - } +// if ((xevent.xclient.format == 32) && (xevent.xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) +// { +// server->postEvent (new CEventDestroyWindow (this)); +// } break; default: // nlinfo("UnknownEvent"); From b7e53676da030b3cfc76cd6d92774cfec8b167a4 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:03:17 +0200 Subject: [PATCH 16/60] Fixed: client_patcher compilation --- code/ryzom/tools/client/client_patcher/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/client_patcher/main.cpp b/code/ryzom/tools/client/client_patcher/main.cpp index 824ce093b..c05c2097b 100644 --- a/code/ryzom/tools/client/client_patcher/main.cpp +++ b/code/ryzom/tools/client/client_patcher/main.cpp @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) CApplicationContext appContext; // create logs in temporary directory - createDebug(CPath::getTemporaryDirectory(), true, true); + createDebug(CPath::getTemporaryDirectory().c_str(), true, true); // disable log display on stdout INelContext::getInstance().getDebugLog()->removeDisplayer("DEFAULT_SD"); From 00c431845affeab28c82d8bb5c00cdbfba2d41cf Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:05:11 +0200 Subject: [PATCH 17/60] Changed: #825 Remove all warning when compiling Ryzom --- code/ryzom/tools/leveldesign/export/export.cpp | 4 ++-- .../ryzom/tools/leveldesign/world_editor/land_export/main.cpp | 2 +- code/ryzom/tools/skill_extractor/skill_extractor.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/ryzom/tools/leveldesign/export/export.cpp b/code/ryzom/tools/leveldesign/export/export.cpp index 2b763efee..49b79193e 100644 --- a/code/ryzom/tools/leveldesign/export/export.cpp +++ b/code/ryzom/tools/leveldesign/export/export.cpp @@ -1762,7 +1762,7 @@ bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vector::iterator it = Plants.find (rPlant.Name); @@ -1846,7 +1846,7 @@ bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vectorVPoints.size()-1)) { - l = pPath->VPoints.size()-2; + l = (uint32)pPath->VPoints.size()-2; curvAbs = (pPath->VPoints[l]-pPath->VPoints[l+1]).norm(); } // Calculate the coord diff --git a/code/ryzom/tools/leveldesign/world_editor/land_export/main.cpp b/code/ryzom/tools/leveldesign/world_editor/land_export/main.cpp index 362a67f24..d3e107d17 100644 --- a/code/ryzom/tools/leveldesign/world_editor/land_export/main.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/land_export/main.cpp @@ -22,7 +22,7 @@ #include "nel/misc/i_xml.h" #include "../land_export_lib/export.h" -#include "nel/../../src/ligo/zone_region.h" +#include "nel/ligo/zone_region.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/tools/skill_extractor/skill_extractor.cpp b/code/ryzom/tools/skill_extractor/skill_extractor.cpp index fa03d37c7..37b3f1020 100644 --- a/code/ryzom/tools/skill_extractor/skill_extractor.cpp +++ b/code/ryzom/tools/skill_extractor/skill_extractor.cpp @@ -311,10 +311,10 @@ sint main( sint argc, char ** argv ) } break; case 1: // code - skill.Code = strupr(string( ptr )); + skill.Code = toUpper(string( ptr )); break; case 2: // parent skill - skill.ParentSkill = strupr(string( ptr )); + skill.ParentSkill = toUpper(string( ptr )); break; case 3: // max skill value skill.MaxValue = (uint16)atoi(ptr); From 89c384efcc35a88a85dbe6e374d5985d63aedd59 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:08:45 +0200 Subject: [PATCH 18/60] Fixed: Moved zone_bank.h from src to include --- code/nel/{src => include/nel}/ligo/zone_bank.h | 0 code/nel/tools/3d/ig_elevation/main.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename code/nel/{src => include/nel}/ligo/zone_bank.h (100%) diff --git a/code/nel/src/ligo/zone_bank.h b/code/nel/include/nel/ligo/zone_bank.h similarity index 100% rename from code/nel/src/ligo/zone_bank.h rename to code/nel/include/nel/ligo/zone_bank.h diff --git a/code/nel/tools/3d/ig_elevation/main.cpp b/code/nel/tools/3d/ig_elevation/main.cpp index 55f696fd0..f0044b651 100644 --- a/code/nel/tools/3d/ig_elevation/main.cpp +++ b/code/nel/tools/3d/ig_elevation/main.cpp @@ -31,7 +31,7 @@ #include "nel/misc/i_xml.h" #include "nel/misc/app_context.h" -#include "nel/../../src/ligo/zone_region.h" +#include "nel/ligo/zone_region.h" #include "nel/3d/scene_group.h" From 85f757d902ed26edb6a7d9184acb7a28c4def634 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:12:49 +0200 Subject: [PATCH 19/60] Changed: Added getBigFileName method to CBigFile --- code/nel/include/nel/misc/big_file.h | 5 ++++- code/nel/src/misc/big_file.cpp | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/code/nel/include/nel/misc/big_file.h b/code/nel/include/nel/misc/big_file.h index 582b44e46..c7c96912a 100644 --- a/code/nel/include/nel/misc/big_file.h +++ b/code/nel/include/nel/misc/big_file.h @@ -58,7 +58,10 @@ public: void remove (const std::string &sBigFileName); // true if a bigFile is added - bool isBigFileAdded(const std::string &sBigFileName); + bool isBigFileAdded(const std::string &sBigFileName) const; + + // return name of Big File + std::string getBigFileName(const std::string &sBigFileName) const; // List all files in a bigfile void list (const std::string &sBigFileName, std::vector &vAllFiles); diff --git a/code/nel/src/misc/big_file.cpp b/code/nel/src/misc/big_file.cpp index 1521efb5f..e60f8d8a2 100644 --- a/code/nel/src/misc/big_file.cpp +++ b/code/nel/src/misc/big_file.cpp @@ -295,13 +295,25 @@ void CBigFile::remove (const std::string &sBigFileName) } // *************************************************************************** -bool CBigFile::isBigFileAdded(const std::string &sBigFileName) +bool CBigFile::isBigFileAdded(const std::string &sBigFileName) const { // Is already the same bigfile name ? string bigfilenamealone = CFile::getFilename (sBigFileName); return _BNPs.find(bigfilenamealone) != _BNPs.end(); } +// *************************************************************************** +std::string CBigFile::getBigFileName(const std::string &sBigFileName) const +{ + string bigfilenamealone = CFile::getFilename (sBigFileName); + map::const_iterator it = _BNPs.find(bigfilenamealone); + if (it != _BNPs.end()) + return it->second.BigFileName; + else + return ""; +} + + // *************************************************************************** void CBigFile::list (const std::string &sBigFileName, std::vector &vAllFiles) { @@ -403,9 +415,10 @@ FILE* CBigFile::getFile (const std::string &sFileName, uint32 &rFileSize, { handle.File = fopen (bnp->BigFileName.c_str(), "rb"); if (handle.File == NULL) - nlwarning ("bnp: can't fopen big file '%s' error %d '%s'", bnp->BigFileName.c_str(), errno, strerror(errno)); - if (handle.File == NULL) + { + nlwarning ("bnp: can't fopen big file '%s' error %d '%s'", bnp->BigFileName.c_str(), errno, strerror(errno)); return NULL; + } } rCacheFileOnOpen = bnp->CacheFileOnOpen; From 3ae23b3b364cb6cef9bb09e466e45ad79240da2f Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:13:29 +0200 Subject: [PATCH 20/60] Changed: Added include guard to stdmisc.h --- code/nel/src/misc/stdmisc.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/nel/src/misc/stdmisc.h b/code/nel/src/misc/stdmisc.h index 27c495672..572a90f1a 100644 --- a/code/nel/src/misc/stdmisc.h +++ b/code/nel/src/misc/stdmisc.h @@ -14,6 +14,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#ifndef NL_STDMISC_H +#define NL_STDMISC_H + #include "nel/misc/types_nl.h" #include @@ -54,3 +57,5 @@ #define NOMINMAX #include #endif + +#endif // NL_STDMISC_H From 99c0124f2ca3c798e8c24373dfa511ae7221ce11 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:15:14 +0200 Subject: [PATCH 21/60] Changed: Reactivate runtime checks and optimizations --- code/nel/src/misc/sha1.cpp | 15 --------------- code/nel/src/pacs/local_retriever.cpp | 4 ++-- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/code/nel/src/misc/sha1.cpp b/code/nel/src/misc/sha1.cpp index eb25b3a84..bb375a928 100644 --- a/code/nel/src/misc/sha1.cpp +++ b/code/nel/src/misc/sha1.cpp @@ -85,13 +85,6 @@ typedef struct SHA1Context int Corrupted; /* Is the message digest corrupted? */ } SHA1Context; - -// Because the code does some tricky stuff, VC>6 would cry at runtime -#ifdef _MFC_VER - #pragma runtime_checks( "", off ) -#endif - - // // Function Prototypes // @@ -194,10 +187,6 @@ CHashKey getSHA1(const string &filename, bool forcePath) return hk; } -#ifdef _MFC_VER - #pragma runtime_checks( "", off ) -#endif - /* * Define the SHA1 circular left shift macro */ @@ -554,7 +543,3 @@ void SHA1PadMessage(SHA1Context *context) SHA1ProcessMessageBlock(context); } - -#ifdef _MFC_VER - #pragma runtime_checks( "", restore ) -#endif diff --git a/code/nel/src/pacs/local_retriever.cpp b/code/nel/src/pacs/local_retriever.cpp index 0aabd5532..4f4c85907 100644 --- a/code/nel/src/pacs/local_retriever.cpp +++ b/code/nel/src/pacs/local_retriever.cpp @@ -1638,7 +1638,7 @@ float NLPACS::CLocalRetriever::getInteriorHeightAround(const ULocalPosition &pos // *************************************************************************** #ifdef NL_OS_WINDOWS -#pragma optimize( "", off ) +//#pragma optimize( "", off ) #endif // NL_OS_WINDOWS void NLPACS::CLocalRetriever::findPath(const NLPACS::CLocalRetriever::CLocalPosition &A, @@ -1853,7 +1853,7 @@ void NLPACS::CLocalRetriever::findPath(const NLPACS::CLocalRetriever::CLocalPosi path.push_back(CVector2s(B.Estimation)); } #ifdef NL_OS_WINDOWS -#pragma optimize( "", on ) +//#pragma optimize( "", on ) #endif // NL_OS_WINDOWS // *************************************************************************** From 77b5f84ba98dcdbd76b0d7e27a52dc8dfb2e55cf Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:17:18 +0200 Subject: [PATCH 22/60] Changed: Added substr to ucstring --- code/nel/include/nel/misc/ucstring.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/nel/include/nel/misc/ucstring.h b/code/nel/include/nel/misc/ucstring.h index a33c19fda..0c336d598 100644 --- a/code/nel/include/nel/misc/ucstring.h +++ b/code/nel/include/nel/misc/ucstring.h @@ -184,6 +184,11 @@ public: return res; } + ucstring substr(size_type pos = 0, size_type n = npos) const + { + return ucstringbase::substr(pos, n); + } + // for luabind (can't bind to 'substr' else ...) ucstring luabind_substr(size_type pos = 0, size_type n = npos) const { From 4a281f0d1b14ea745e120a72c047631c6af1c226 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:19:03 +0200 Subject: [PATCH 23/60] Changed: #825 Remove all warning when compiling Ryzom --- code/nel/include/nel/sound/sound_animation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/include/nel/sound/sound_animation.h b/code/nel/include/nel/sound/sound_animation.h index 162f87c5d..748ede1f7 100644 --- a/code/nel/include/nel/sound/sound_animation.h +++ b/code/nel/include/nel/sound/sound_animation.h @@ -54,7 +54,7 @@ public: /** Return the number of markers in this track */ - virtual uint32 countMarkers() { return (uint32)_Markers.size(); } + virtual uint32 countMarkers() const { return (uint32)_Markers.size(); } /** Return a marker of this track given its index */ virtual CSoundAnimMarker* getMarker(uint32 i) { return _Markers[i]; } From 933395109b91eb410cb0115c17ba1ab61af6a794 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:44:19 +0200 Subject: [PATCH 24/60] Changed: #825 Remove all warning when compiling Ryzom --- code/ryzom/client/src/attack_list.cpp | 20 ------------------- .../ryzom/client/src/bg_downloader_access.cpp | 2 +- code/ryzom/client/src/cdb.h | 5 +++++ code/ryzom/client/src/client_cfg.h | 4 ++-- code/ryzom/client/src/color_slot_manager.cpp | 5 ++--- code/ryzom/client/src/debug_client.cpp | 11 ---------- code/ryzom/client/src/far_tp.cpp | 7 ++++--- code/ryzom/client/src/fx_manager.cpp | 4 ++-- code/ryzom/client/src/game_context_menu.cpp | 2 +- .../client/src/interface_v3/view_renderer.cpp | 2 +- code/ryzom/client/src/libwww.cpp | 3 --- code/ryzom/client/src/network_connection.cpp | 8 ++++---- code/ryzom/client/src/progress.cpp | 2 +- .../client/src/string_manager_client.cpp | 12 +++++------ .../ryzom/common/src/game_share/bnp_patch.cpp | 2 +- code/ryzom/common/src/game_share/scores.h | 2 +- 16 files changed, 31 insertions(+), 60 deletions(-) diff --git a/code/ryzom/client/src/attack_list.cpp b/code/ryzom/client/src/attack_list.cpp index 08c2f3581..6c974adf4 100644 --- a/code/ryzom/client/src/attack_list.cpp +++ b/code/ryzom/client/src/attack_list.cpp @@ -223,23 +223,3 @@ void CAttackListManager::buildLinkFXs() { _Links.init("links.id_to_string_array", _AnimationSet, false /* must not delete animset, owned by this object */); } - - - - - - - - - - - - - - - - - - - - diff --git a/code/ryzom/client/src/bg_downloader_access.cpp b/code/ryzom/client/src/bg_downloader_access.cpp index e321eb28e..15d98569b 100644 --- a/code/ryzom/client/src/bg_downloader_access.cpp +++ b/code/ryzom/client/src/bg_downloader_access.cpp @@ -486,7 +486,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader() uint tryCounter = 1; for (;;) { - nlwarning("Launching downloader: try number %d", (int) tryCounter++); + nlwarning("Launching downloader: try number %u", tryCounter++); // now we can create the message queue because we are sure that it will reach the good app Parent->_DownloaderMsgQueue.init(HInstance, BGDownloader::ClientWndID, BGDownloader::DownloaderWndID); sleep(200); diff --git a/code/ryzom/client/src/cdb.h b/code/ryzom/client/src/cdb.h index 97edfa2a5..24c2dd5eb 100644 --- a/code/ryzom/client/src/cdb.h +++ b/code/ryzom/client/src/cdb.h @@ -19,6 +19,11 @@ #ifndef CDB_H #define CDB_H +// misc +#include "nel/misc/types_nl.h" +#include "nel/misc/smart_ptr.h" +#include "nel/misc/string_mapper.h" + #include namespace NLMISC diff --git a/code/ryzom/client/src/client_cfg.h b/code/ryzom/client/src/client_cfg.h index dad8e8077..4289a1b0b 100644 --- a/code/ryzom/client/src/client_cfg.h +++ b/code/ryzom/client/src/client_cfg.h @@ -66,8 +66,8 @@ struct CClientConfig bool SaveConfig; /// Window position in windowed mode - sint32 PositionX; - sint32 PositionY; + sint32 PositionX; + sint32 PositionY; /// Window frequency uint Frequency; diff --git a/code/ryzom/client/src/color_slot_manager.cpp b/code/ryzom/client/src/color_slot_manager.cpp index 905eecef5..996d256a5 100644 --- a/code/ryzom/client/src/color_slot_manager.cpp +++ b/code/ryzom/client/src/color_slot_manager.cpp @@ -134,7 +134,7 @@ uint CColorSlotManager::addSlot(const TStringVect &slotDescs) _Slots.push_back(slotDescs); for(uint k = 0; k < slotDescs.size(); ++k) { - NLMISC::strupr(_Slots.back()[k]); + _Slots.back()[k] = NLMISC::toUpper(_Slots.back()[k]); } return (uint)_Slots.size() - 1; } @@ -327,10 +327,9 @@ bool CColorSlotManager::addSlotsFromConfigFile(NLMISC::CConfigFile &cf, uint &st { return false; } + uint startSlot = (uint)_Slots.size(); - - _Slots.resize(_Slots.size() + mask_extensions->size()); /// For each kind of mask, build a slot for (uint k = 0; k < (uint) mask_extensions->size(); ++k) diff --git a/code/ryzom/client/src/debug_client.cpp b/code/ryzom/client/src/debug_client.cpp index bfed1c53a..9e42dffc8 100644 --- a/code/ryzom/client/src/debug_client.cpp +++ b/code/ryzom/client/src/debug_client.cpp @@ -22,14 +22,6 @@ ///////////// #include "stdpch.h" // First include for pre-compiled headers. -#include - -// OS. -#ifdef NL_OS_WINDOWS -# define NOMINMAX -# include -#endif - // Misc #include "nel/misc/file.h" #include "nel/misc/async_file_manager.h" @@ -689,6 +681,3 @@ bool verboseVPAdvanceTest(CEntityCL *en, uint32 form) return false; } } - - - diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index fd629a43c..16946a705 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -965,7 +965,7 @@ void CFarTP::requestReturnToPreviousSession(TSessionId rejectedSessionId) void CFarTP::requestReconnection() { _ReselectingChar = true; - requestFarTPToSession(TSessionId(~0u), ~0, CFarTP::JoinMainland, false); + requestFarTPToSession(TSessionId(std::numeric_limits::max()), std::numeric_limits::max(), CFarTP::JoinMainland, false); } @@ -1060,9 +1060,10 @@ void CFarTP::disconnectFromPreviousShard() // Play music and fade out the Game Sound if (SoundMngr) { - SoundMngr->playEventMusic(ClientCfg.SoundOutGameMusic, CSoundManager::LoadingMusicXFade, true); // Loading Music Loop.ogg - SoundMngr->fadeOutGameSound(ClientCfg.SoundTPFade); + // Loading Music Loop.ogg LoadingMusic = ClientCfg.SoundOutGameMusic; + SoundMngr->playEventMusic(LoadingMusic, CSoundManager::LoadingMusicXFade, true); + SoundMngr->fadeOutGameSound(ClientCfg.SoundTPFade); } // Change the tips diff --git a/code/ryzom/client/src/fx_manager.cpp b/code/ryzom/client/src/fx_manager.cpp index cc785197d..f1a4e6106 100644 --- a/code/ryzom/client/src/fx_manager.cpp +++ b/code/ryzom/client/src/fx_manager.cpp @@ -142,7 +142,7 @@ void CFXManager::update() while (!_DeferredFXByDate.empty()) { - if (T1 < (sint64)_DeferredFXByDate.begin()->first) break; + if (T1 < (uint)_DeferredFXByDate.begin()->first) break; const CDeferredFX &fx = _DeferredFXByDate.begin()->second; NL3D::UParticleSystemInstance fxInstance = instantFX(fx.FXName, fx.TimeOut); if (!fxInstance.empty()) @@ -231,7 +231,7 @@ void CFXManager::deferFX(const std::string &fxName, const NLMISC::CMatrix &matri fx.FXName = fxName; fx.Matrix = matrix; fx.TimeOut = timeOut; - _DeferredFXByDate.insert(std::make_pair(T1 + sint64(1000.f * delayInSeconds), fx)); + _DeferredFXByDate.insert(std::make_pair(T1 + uint64(1000.f * delayInSeconds), fx)); } diff --git a/code/ryzom/client/src/game_context_menu.cpp b/code/ryzom/client/src/game_context_menu.cpp index 84b31db53..b6e77dc20 100644 --- a/code/ryzom/client/src/game_context_menu.cpp +++ b/code/ryzom/client/src/game_context_menu.cpp @@ -847,7 +847,7 @@ void CGameContextMenu::updateContextMenuTalkEntries(uint options) { if (ClientCfg.Local) { - options = ~0; // in local mode, force all options to be shown (for debug) + options = std::numeric_limits::max(); // in local mode, force all options to be shown (for debug) } // news _OkTextNews= ((options & (1 << BOTCHATTYPE::NewsFlag))); diff --git a/code/ryzom/client/src/interface_v3/view_renderer.cpp b/code/ryzom/client/src/interface_v3/view_renderer.cpp index 17bfa99a3..ffe61b1cb 100644 --- a/code/ryzom/client/src/interface_v3/view_renderer.cpp +++ b/code/ryzom/client/src/interface_v3/view_renderer.cpp @@ -743,7 +743,7 @@ void CViewRenderer::loadTextures (const std::string &textureFileName, const std: image.UVMax.U = uvMaxU; image.UVMax.V = uvMaxV; sTGAname = tgaName; - sTGAname = strlwr(sTGAname); + sTGAname = toLower(sTGAname); string::size_type stripPng = sTGAname.find(".png"); if (stripPng != string::npos) { diff --git a/code/ryzom/client/src/libwww.cpp b/code/ryzom/client/src/libwww.cpp index c66079cdb..dc5c151bd 100644 --- a/code/ryzom/client/src/libwww.cpp +++ b/code/ryzom/client/src/libwww.cpp @@ -531,9 +531,6 @@ void initLibWWW() static bool initialized = false; if (!initialized) { - // log all libwww - //WWW_TraceFlag = SHOW_ALL_TRACE; - //HTProfile_newNoCacheClient("Ryzom", "1.1"); /* Need our own trace and print functions */ diff --git a/code/ryzom/client/src/network_connection.cpp b/code/ryzom/client/src/network_connection.cpp index d37e05eae..fe1216b64 100644 --- a/code/ryzom/client/src/network_connection.cpp +++ b/code/ryzom/client/src/network_connection.cpp @@ -714,7 +714,7 @@ void CNetworkConnection::setMsPerTick(sint32 msPerTick) bool CNetworkConnection::update() { #ifdef ENABLE_INCOMING_MSG_RECORDER - if ( _NextClientTickToReplay == ~0 ) + if ( _NextClientTickToReplay == std::numeric_limits::max() ) { setReplayingMode( false ); return false; @@ -881,7 +881,7 @@ bool CNetworkConnection::buildStream( CBitMemStream &msgin ) if ( _RecordedMessagesIn.eof() ) { // Nothing more to load - _NextClientTickToReplay = ~0; + _NextClientTickToReplay = std::numeric_limits::max(); nlinfo( "Nothing more to replay, end of replaying" ); } else @@ -1147,10 +1147,10 @@ void CNetworkConnection::receiveSystemSync(CBitMemStream &msgin) //_MsPerTick = 100; // initial values #ifdef HALF_FREQUENCY_SENDING_TO_CLIENT -#pragma message ("HALF_FREQUENCY_SENDING_TO_CLIENT") +//#pragma message ("HALF_FREQUENCY_SENDING_TO_CLIENT") _CurrentServerTick = _Synchronize+_CurrentReceivedNumber*2; #else -#pragma message ("FULL_FREQUENCY_SENDING_TO_CLIENT") +//#pragma message ("FULL_FREQUENCY_SENDING_TO_CLIENT") _CurrentServerTick = _Synchronize+_CurrentReceivedNumber; #endif _CurrentClientTick = uint32(_CurrentServerTick - (_LCT+_MsPerTick)/_MsPerTick); diff --git a/code/ryzom/client/src/progress.cpp b/code/ryzom/client/src/progress.cpp index 0f487b747..dc164ef8e 100644 --- a/code/ryzom/client/src/progress.cpp +++ b/code/ryzom/client/src/progress.cpp @@ -121,7 +121,6 @@ void drawLoadingBitmap (float progress) CQuadUV quad; uint wh = Driver->getWindowHeight(); uint ww = Driver->getWindowWidth(); - //nlinfo("%d x %d", ww, wh); float x1 = 0; float y1 = 0; float x2 = 1; @@ -441,3 +440,4 @@ void CProgress::finish() // stop system dependent progress bar CSystemUtils::updateProgressBar(1, 0); } + diff --git a/code/ryzom/client/src/string_manager_client.cpp b/code/ryzom/client/src/string_manager_client.cpp index 72604df73..3e93c7957 100644 --- a/code/ryzom/client/src/string_manager_client.cpp +++ b/code/ryzom/client/src/string_manager_client.cpp @@ -1208,15 +1208,15 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) // Get the women name index if possible. uint womenNameColIndex; if( !ws.findCol(womenNameColIdent, womenNameColIndex) ) - womenNameColIndex= ~0; + womenNameColIndex= std::numeric_limits::max(); // Get the description index if possible. uint descColIndex; if( !ws.findCol(descColIdent, descColIndex) ) - descColIndex= ~0; + descColIndex= std::numeric_limits::max(); uint descColIndex2; if( !ws.findCol(descColIdent2, descColIndex2) ) - descColIndex2= ~0; + descColIndex2= std::numeric_limits::max(); // For all rows minus the first header one. for(uint j=1;j::max()) { const ucstring &womenName= ws.getData(j, womenNameColIndex); _SpecItem_TempMap[keyStr].WomenName= womenName; @@ -1255,7 +1255,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) } // insert in map of Description if OK. - if(descColIndex!=((uint)~0)) + if(descColIndex!=std::numeric_limits::max()) { const ucstring &desc= ws.getData(j, descColIndex); _SpecItem_TempMap[keyStr].Desc= desc; @@ -1264,7 +1264,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) } // insert in map of Description2 if OK. - if(descColIndex2!=((uint)~0)) + if(descColIndex2!=std::numeric_limits::max()) { const ucstring &desc= ws.getData(j, descColIndex2); _SpecItem_TempMap[keyStr].Desc2= desc; diff --git a/code/ryzom/common/src/game_share/bnp_patch.cpp b/code/ryzom/common/src/game_share/bnp_patch.cpp index 071b03675..413e24a0b 100644 --- a/code/ryzom/common/src/game_share/bnp_patch.cpp +++ b/code/ryzom/common/src/game_share/bnp_patch.cpp @@ -63,7 +63,7 @@ CBNPFileVersion::CBNPFileVersion() _FileSize= 0; _7ZFileSize=0; _PatchSize= 0; - _VersionNumber= ~0u; + _VersionNumber= std::numeric_limits::max(); } // setup record contents from a file name and version number diff --git a/code/ryzom/common/src/game_share/scores.h b/code/ryzom/common/src/game_share/scores.h index a718e426d..33b69c275 100644 --- a/code/ryzom/common/src/game_share/scores.h +++ b/code/ryzom/common/src/game_share/scores.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" -#include +#include namespace SCORES { From 258e16099c36efe598f647002e4a6abceda6d715 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:51:06 +0200 Subject: [PATCH 25/60] Fixed: Added /Zm1000 to be able to create PCH with a lot of headers --- code/CMakeModules/nel.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 94fdf346d..870b0a0ac 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -288,7 +288,7 @@ MACRO(NL_SETUP_BUILD) # without inlining it's unusable, use custom optimizations again SET(MIN_OPTIMIZATIONS "/Ob1") - SET(PLATFORM_CFLAGS "/D_CRT_SECURE_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zi") + SET(PLATFORM_CFLAGS "/D_CRT_SECURE_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zi /Zm1000") IF(WITH_STLPORT) # deactivate all global include paths From ed9abbb2d52e3b428f46499097425728fdd1d253 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:52:01 +0200 Subject: [PATCH 26/60] Fixed: name_dir property for NeL and Ryzom libs under Mac OS X --- code/CMakeModules/nel.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 870b0a0ac..d96937cc2 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -42,6 +42,7 @@ MACRO(NL_DEFAULT_PROPS name label) # Set versions only if target is a shared library SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR} + INSTALL_NAME_DIR ${NL_LIB_PREFIX} PROJECT_LABEL ${label}) ELSE(${type} STREQUAL SHARED_LIBRARY) SET_TARGET_PROPERTIES(${name} PROPERTIES From 27cdfd91206b11a2df08bcd244c236f42e570eb9 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:57:15 +0200 Subject: [PATCH 27/60] Changed: #841 Change the wrong header in the source code --- .../game_share/backup_service_interface.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/code/ryzom/common/src/game_share/backup_service_interface.cpp b/code/ryzom/common/src/game_share/backup_service_interface.cpp index b7d60b54f..a31656670 100644 --- a/code/ryzom/common/src/game_share/backup_service_interface.cpp +++ b/code/ryzom/common/src/game_share/backup_service_interface.cpp @@ -1,6 +1,18 @@ -/** file backup_service_interface.cpp - * $Id: backup_service_interface.cpp,v 1.23 2007/02/01 16:25:12 boucher Exp $ - */ +// Ryzom - 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 . //------------------------------------------------------------------------------------------------- // includes From 7cd750c726e8a80d0240e9df86422deef2096c8f Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:58:10 +0200 Subject: [PATCH 28/60] Changed: Added titles associated to title enum --- .../common/src/game_share/character_title.h | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/code/ryzom/common/src/game_share/character_title.h b/code/ryzom/common/src/game_share/character_title.h index 2f9046b94..08a57fa8c 100644 --- a/code/ryzom/common/src/game_share/character_title.h +++ b/code/ryzom/common/src/game_share/character_title.h @@ -214,10 +214,10 @@ enum ECharacterTitle Title00028, // Tryker Taliar Title00029, // Zorai Awakened Title00030, // Marauder - Title00031, - Title00032, - Title00033, - Title00034, + Title00031, // Fyros Ambassador + Title00032, // Matis Ambassador + Title00033, // Tryker Ambassador + Title00034, // Zorai Ambassador Title00035, Title00036, Title00037, @@ -233,22 +233,22 @@ enum ECharacterTitle Title00047, // Machinegunner Title00048, // Assault Machinegunner Title00049, - Title00050, - Title00051, - Title00052, - Title00053, - Title00054, - Title00055, - Title00056, - Title00057, - Title00058, - Title00059, - Title00060, - Title00061, - Title00062, - Title00063, - Title00064, - Title00065, + Title00050, // Apprentice Butcher + Title00051, // Butcher + Title00052, // Apprentice Florist + Title00053, // Florist + Title00054, // Apprentice Water-Carrier + Title00055, // Water-Carrier + Title00056, // Apprentice Magnetic + Title00057, // Magnetic Cartographe + Title00058, // Apprentice Toolmaker + Title00059, // Toolmaker + Title00060, // Apprentice Rescuer + Title00061, // Rescuer + Title00062, // Apprentice Larvester + Title00063, // Larvester + Title00064, // Apprentice Scrollmaker + Title00065, // Scrollmaker Title00066, Title00067, Title00068, @@ -300,6 +300,15 @@ inline ECharacterTitle getGMTitleFromPriv (const std::string& priv) } +//---------------------------------------------------------------------- +inline bool isCsrTitle(const ucstring& title) +{ + ECharacterTitle titleEnum = toCharacterTitle( title.toUtf8() ); + bool bIsCsrTitle = (titleEnum >= SGM && titleEnum <= CM); + + return bIsCsrTitle; +} + } // CHARACTER_TITLE #endif From 54961449c3f4c504b76234aee5d66024ca946f31 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 09:59:59 +0200 Subject: [PATCH 29/60] Changed: #825 Remove all warning when compiling Ryzom --- .../game_share/_backup_service_interface_non_module.cpp | 2 +- .../common/src/game_share/backup_service_interface.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/ryzom/common/src/game_share/_backup_service_interface_non_module.cpp b/code/ryzom/common/src/game_share/_backup_service_interface_non_module.cpp index 0fc3df40f..8176793bd 100644 --- a/code/ryzom/common/src/game_share/_backup_service_interface_non_module.cpp +++ b/code/ryzom/common/src/game_share/_backup_service_interface_non_module.cpp @@ -85,7 +85,7 @@ private: void CGenericRequestIdRegister::pushRequestId(uint32 requestId,const std::string& fileName) { // check for out of order entries in the request list - BOMB_IF(!_RequestIds.empty() && ((sint32)requestId-(sint32)_RequestIds.back().RequestId)<0,"Ignoring out of order request id in generic callback registration for file "+CSString(fileName).quote(),return); + BOMB_IF(!_RequestIds.empty() && (requestId<_RequestIds.back().RequestId),"Ignoring out of order request id in generic callback registration for file "+CSString(fileName).quote(),return); // setup a new record for this request id / file name pair SRequestId theNewRequestId; diff --git a/code/ryzom/common/src/game_share/backup_service_interface.cpp b/code/ryzom/common/src/game_share/backup_service_interface.cpp index a31656670..112737b6a 100644 --- a/code/ryzom/common/src/game_share/backup_service_interface.cpp +++ b/code/ryzom/common/src/game_share/backup_service_interface.cpp @@ -47,10 +47,10 @@ public: for (uint32 i='A'; i<='Z';++i) _Data[i]= true; for (uint32 i='a'; i<='z';++i) _Data[i]= true; for (uint32 i='0'; i<='9';++i) _Data[i]= true; - _Data['/']= true; - _Data['.']= true; - _Data['_']= true; - _Data[' ']= true; + _Data[(uint32)'/']= true; + _Data[(uint32)'.']= true; + _Data[(uint32)'_']= true; + _Data[(uint32)' ']= true; } // lookup a character to determine whether it's valid or not From 5574174db4ad2ee1d7fe1f290754335cad981c08 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 10:10:16 +0200 Subject: [PATCH 30/60] Changed: #825 Remove all warning when compiling Ryzom --- code/ryzom/client/src/cursor_functions.cpp | 3 +- code/ryzom/client/src/entities.h | 3 ++ code/ryzom/client/src/entity_cl.h | 1 + code/ryzom/client/src/input.cpp | 3 -- .../src/interface_v3/bot_chat_page_trade.cpp | 24 +++++------ .../client/src/interface_v3/group_editbox.h | 1 + .../client/src/interface_v3/guild_manager.cpp | 2 + .../src/interface_v3/interface_manager.cpp | 42 +++++++++---------- code/ryzom/client/src/login_patch.cpp | 16 +++---- code/ryzom/client/src/user_entity.cpp | 8 ++-- 10 files changed, 52 insertions(+), 51 deletions(-) diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index 9ba384ce3..79998b7c7 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -510,7 +510,6 @@ void checkUnderCursor() } } } - else SlotUnderCursor = CLFECOMMON::INVALID_SLOT; } @@ -839,5 +838,5 @@ void contextBuildTotem(bool rightClick, bool dblClick) return; if( ClientCfg.DblClickMode && !dblClick) return; - UserEntity->moveToTotemBuildingPhrase(SlotUnderCursor,MaxExtractionDistance, ~0, ~0, true ); + UserEntity->moveToTotemBuildingPhrase(SlotUnderCursor,MaxExtractionDistance, std::numeric_limits::max(), std::numeric_limits::max(), true ); }// contextBuildTotem // diff --git a/code/ryzom/client/src/entities.h b/code/ryzom/client/src/entities.h index c9416a5d5..502065926 100644 --- a/code/ryzom/client/src/entities.h +++ b/code/ryzom/client/src/entities.h @@ -35,6 +35,9 @@ #include "nel/misc/time_nl.h" #include "nel/misc/vector.h" #include "nel/misc/file.h" +#include "nel/misc/aabbox.h" +// 3D +#include "nel/3d/u_instance.h" // Std. #include diff --git a/code/ryzom/client/src/entity_cl.h b/code/ryzom/client/src/entity_cl.h index 7f97eeec8..725f6b883 100644 --- a/code/ryzom/client/src/entity_cl.h +++ b/code/ryzom/client/src/entity_cl.h @@ -910,6 +910,7 @@ protected: std::string _PermanentStatutIcon; // Has reserved title? bool _HasReservedTitle; + // Extended Name ucstring _NameEx; // String ID diff --git a/code/ryzom/client/src/input.cpp b/code/ryzom/client/src/input.cpp index d0732bd86..668b1f15b 100644 --- a/code/ryzom/client/src/input.cpp +++ b/code/ryzom/client/src/input.cpp @@ -445,7 +445,6 @@ void HandleSystemCursorCapture(const CEvent &event) } } - // ********************************************************************************* bool IsSystemCursorInClientArea() { @@ -506,8 +505,6 @@ bool IsSystemCursorInClientArea() return true; } - - sint CNiceInputAuto::_Count = 0; diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index 02a929772..ae608fa79 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -327,10 +327,10 @@ uint32 CBotChatPageTrade::getCurrItemQuantity() const // TODO: edit box in faction points? CGroupEditBox *ed = dynamic_cast(ig->getGroup("header_opened:standard_price:quantity:edit:eb")); if (!ed) return ~0; - int intQuantity; + uint32 intQuantity; if (fromString(ed->getInputString().toString(), intQuantity)) { - return (uint32) intQuantity; + return intQuantity; } else { @@ -375,7 +375,7 @@ uint32 CBotChatPageTrade::getCurrItemPriceResale() const // *************************************************************************************** uint64 CBotChatPageTrade::getCurrItemPrice(bool mulByFame) const { - if (!_CurrItemSheet) return ~0; + if (!_CurrItemSheet) return std::numeric_limits::max(); if (_BuyDlgOn && (_BuyMean == MoneyGuildXP || _BuyMean == GuildMoneyGuildXP || _BuyMean == GuildMoney) ) { if (_BuyMean == MoneyGuildXP) @@ -419,7 +419,7 @@ uint64 CBotChatPageTrade::getCurrItemPrice(bool mulByFame) const } } } - return ~0; + return std::numeric_limits::max(); } // *************************************************************************************** @@ -440,7 +440,7 @@ uint64 CBotChatPageTrade::getCurrItemXP() const return 0; // By now no need for XP even if xp guild required } - return ~0; + return std::numeric_limits::max(); } @@ -809,11 +809,11 @@ void CBotChatPageTrade::updateTradeModal() if (cantTradeButton) cantTradeButton->setText(CI18N::get("uiWontBuyThis")); if (cantTradeButton) cantTradeButton->setDefaultContextHelp(CI18N::get("uittWontBuyThis")); } - else if (_SellDlgOn && priceWithoutFame == ~0) + else if (_SellDlgOn && priceWithoutFame == std::numeric_limits::max()) { if (cantTradeButton) cantTradeButton->setText(CI18N::get("uiPriceNotReceived")); } - else if (quantity == 0 || quantity == ~0) + else if (quantity == 0 || quantity == std::numeric_limits::max()) { if (cantTradeButton) cantTradeButton->setText(CI18N::get("uiBadQuantity")); if (cantTradeButton) cantTradeButton->setDefaultContextHelp(CI18N::get("uittBadQuantity")); @@ -1100,7 +1100,7 @@ bool CBotChatPageTrade::isTradeValid( bool enableResale ) const getCurrItemFactionTypePoints(fpType, fpCost); // if price/quantity is valid - bool validSetup= priceWithoutFame != ~0 && quantity != ~0 && quantity != 0; + bool validSetup= priceWithoutFame != std::numeric_limits::max() && quantity != std::numeric_limits::max() && quantity != 0; if(validSetup && _BuyMean==MoneyFactionPoints) { // valid if at least one price type is not 0 @@ -1179,7 +1179,7 @@ void CBotChatPageTrade::confirmTrade( bool enableResale ) { uint32 quantity = getCurrItemQuantity(); sint32 resalePrice = resaleEnabled ? getCurrItemPriceResale() : 0; // getCurrItemPriceResale() returns 0 is !_ResaleEdit - if (quantity != ~0) + if (quantity != std::numeric_limits::max()) { uint16 u16Quantity = (uint16) quantity; // The Item bought is a SPhrase ? @@ -2120,7 +2120,7 @@ void CBotChatPageTrade::startDestroyItemDialog() // setup the quantity to destroy (if edited correctly) uint32 quantity= getCurrItemQuantity(); - if(quantity==0 || quantity==~0) + if(quantity==0 || quantity==std::numeric_limits::max()) return; // if quantity check, maximize with it (if user entered to big value...) if(_QuantityCheck) @@ -2144,7 +2144,7 @@ void CBotChatPageTrade::confirmDestroyItemDialog() // get the quantity destroyed uint32 quantity= getCurrItemQuantity(); // if correct quantity - if(quantity!=0 && quantity!=~0) + if(quantity!=0 && quantity!=std::numeric_limits::max()) { // if quantity check, maximize with it (if user entered too big value...) if(_QuantityCheck) @@ -2190,7 +2190,7 @@ void CBotChatPageTrade::confirmDestroyItemDialog() pIM->disableModalWindow(); // if the quantity entered was correct - if(quantity!=0 && quantity!=~0) + if(quantity!=0 && quantity!=std::numeric_limits::max()) { // close also the container modal endTradeModal(); diff --git a/code/ryzom/client/src/interface_v3/group_editbox.h b/code/ryzom/client/src/interface_v3/group_editbox.h index c8f8bf457..7046130f6 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.h +++ b/code/ryzom/client/src/interface_v3/group_editbox.h @@ -20,6 +20,7 @@ #define RZ_CTRL_EDITBOX_H #include "interface_group.h" +#include "nel/3d/u_texture.h" class CEventDescriptor; diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index a8bb9cc2f..2be4808f0 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -41,6 +41,8 @@ #include "game_share/lift_icons.h" #include "../r2/editor.h" +#include "chat_window.h" +#include "people_interraction.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 4247fd46a..66610dbf2 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -459,7 +459,7 @@ void CInterfaceManager::initLogin() } nldebug("Textures Login Interface"); - + for (vector::iterator it = ClientCfg.TexturesLoginInterface.begin(), end = ClientCfg.TexturesLoginInterface.end(); it != end; ++it) { nldebug("Textures Login Interface: %s", (*it).c_str()); @@ -549,13 +549,13 @@ void CInterfaceManager::initOutGame() } nldebug("Textures OutGame Interface"); - + for (vector::iterator it = ClientCfg.TexturesOutGameInterface.begin(), end = ClientCfg.TexturesOutGameInterface.end(); it != end; ++it) { nldebug("Textures OutGame Interface: %s", (*it).c_str()); loadTextures(*it + ".tga", *it + ".txt", false); } - + for (vector::iterator it = ClientCfg.TexturesOutGameInterfaceDXTC.begin(), end = ClientCfg.TexturesOutGameInterfaceDXTC.end(); it != end; ++it) { nldebug("Textures OutGame Interface DXTC: %s", (*it).c_str()); @@ -1667,7 +1667,7 @@ bool CInterfaceManager::loadConfig (const string &filename) // *** Apply the NPC icon display mode CNPCIconCache::getInstance().init(!ClientCfg.R2EDEnabled && getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool()); - + return true; } @@ -2189,7 +2189,7 @@ CInterfaceGroup *CInterfaceManager::getWindowForActiveMasterGroup(const std::str // ---------------------------------------------------------------------------- void CInterfaceManager::updateTooltipCoords() { - updateTooltipCoords(_CurCtrlContextHelp); + updateTooltipCoords(_CurCtrlContextHelp); } // ---------------------------------------------------------------------------- @@ -2239,7 +2239,7 @@ void CInterfaceManager::updateTooltipCoords(CCtrlBase *newCtrl) yParent = newCtrl->getYReal(); wParent = newCtrl->getWReal(); hParent = newCtrl->getHReal(); - // Additionaly, must clip this ctrl with its parent + // Additionaly, must clip this ctrl with its parent // (else animals are buggy for instance) CInterfaceGroup *parent= newCtrl->getParent(); if(parent) @@ -2258,7 +2258,7 @@ void CInterfaceManager::updateTooltipCoords(CCtrlBase *newCtrl) } - // **** resolve auto posref + // **** resolve auto posref uint clampCount = adjustTooltipPosition(newCtrl, win, newCtrl->getToolTipParentPosRef(), newCtrl->getToolTipPosRef(), xParent, yParent, wParent, hParent); if (clampCount != 0) { @@ -2270,7 +2270,7 @@ void CInterfaceManager::updateTooltipCoords(CCtrlBase *newCtrl) adjustTooltipPosition(newCtrl, win, newCtrl->getToolTipParentPosRef(), newCtrl->getToolTipPosRef(), xParent, yParent, wParent, hParent); } } - } + } } } @@ -2364,7 +2364,7 @@ void CInterfaceManager::drawContextHelp () { // enable _CurCtrlContextHelp = newCtrl->getId(); - newCtrl->invalidateCoords(); + newCtrl->invalidateCoords(); } } } @@ -2376,7 +2376,7 @@ void CInterfaceManager::drawContextHelp () // **** display // *************** if(_CurCtrlContextHelp) - { + { CInterfaceGroup *groupContextHelp = getWindowForActiveMasterGroup(_CurCtrlContextHelp->getContextHelpWindowName()); if(groupContextHelp) { @@ -2384,12 +2384,12 @@ void CInterfaceManager::drawContextHelp () * If this is the case, we just disable it, unless the tooltip was generated by the current modal window */ if (!_ModalStack.empty()) - { + { CInterfaceGroup *mw = _ModalStack.back().ModalWindow; if (mw && mw->isIn(*groupContextHelp)) - { + { if (_CurCtrlContextHelp->isSonOf(mw)) - { + { groupContextHelp->executeLuaScriptOnDraw(); groupContextHelp->draw (); // flush layers @@ -2397,7 +2397,7 @@ void CInterfaceManager::drawContextHelp () } } else - { + { groupContextHelp->executeLuaScriptOnDraw(); groupContextHelp->draw (); // flush layers @@ -2405,7 +2405,7 @@ void CInterfaceManager::drawContextHelp () } } else - { + { groupContextHelp->executeLuaScriptOnDraw(); groupContextHelp->draw (); // flush layers @@ -2420,11 +2420,11 @@ void CInterfaceManager::drawContextHelp () } void CInterfaceManager::setContextHelpActive(bool active) -{ +{ if (!active) { - disableContextHelp(); - } + disableContextHelp(); + } _ContextHelpActive = active; } @@ -2675,7 +2675,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) CInterfaceGroup *tw= getTopWindow(); if(tw && !tw->getAHOnEnter().empty()) { - // if the captured keypborad is in this Modal window, then must handle him in priority + // if the captured keyboard is in this Modal window, then must handle him in priority if(_CaptureKeyboard && _CaptureKeyboard->getRootWindow()==tw) { bool result = _CaptureKeyboard->handleEvent(event); @@ -5494,8 +5494,6 @@ class CHandlerEmote : public IActionHandler public: void execute (CCtrlBase * /* pCaller */, const std::string &sParams) { - - // An emote is 2 things : a phrase and an animation // Phrase is the phrase that server returns in chat system // Behav is the animation played @@ -5524,7 +5522,7 @@ public: behavToSend = MBEHAV::IDLE; } - /* Emotes forbidden when dead, emotes with behav forbidden when + /* Emotes forbidden when dead, emotes with behav forbidden when * stunned or swimming */ if ( ( behavToSend != MBEHAV::IDLE && (isSwimming() || isStunned() || isDead() ) ) ) { diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index e886e29b0..655f0221b 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -2872,7 +2872,6 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP) } } - // following lines added by Sadge to ensure that the correct file gets patched // string SourceNameXDFull; // if (NLMISC::CFile::fileExists(pPM->ClientDataPath + SourceNameXD)) SourceNameXDFull = pPM->ClientDataPath + SourceNameXD; @@ -2898,9 +2897,6 @@ void CPatchThread::processFile (CPatchManager::SFileToPatch &rFTP) pPM->deleteFile(SourceName); pPM->deleteFile(PatchName); - - - if (j > 0) { pPM->deleteFile(SourceNameXD, false, false); // File can exists if bad BNP loading @@ -3210,9 +3206,11 @@ bool CPatchManager::download(const std::string& patchFullname, const std::string NLMISC::CFile::createDirectoryTree( NLMISC::CFile::getPath(sourceFullname) ); // try to download - try { + try + { pPM->getServerFile(patchFullname, false, patchName); - } catch ( const std::exception& e) + } + catch ( const std::exception& e) { nlwarning("%s", e.what()); pPM->setState(true, ucstring(e.what()) ); @@ -3468,12 +3466,14 @@ void CDownloadThread::run() // create directory tree NLMISC::CFile::createDirectoryTree(path); // Try to download, rename, applyDate and send error msg to gui in case of error - try { + try + { pPM->getServerFile(patchName, false, tmpFile); NLMISC::CFile::moveFile(finalFile.c_str(), tmpFile.c_str()); pPM->applyDate(finalFile, _Entries[first].Timestamp); - } catch ( const std::exception& e) + } + catch ( const std::exception& e) { nlwarning("%s", e.what()); pPM->setState(true, ucstring(e.what()) ); diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index cfc661620..cd9925e05 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -1329,7 +1329,7 @@ void CUserEntity::resetAnyMoveTo() if(_MoveToAction==CUserEntity::CombatPhrase || _MoveToAction==CUserEntity::ExtractRM) { // the clientExecute has not been called in case of "ExtractRM autoFind" - bool autoFindExtractRM= _MoveToAction==CUserEntity::ExtractRM && _MoveToPhraseMemoryLine == (uint)~0; + bool autoFindExtractRM= _MoveToAction==CUserEntity::ExtractRM && _MoveToPhraseMemoryLine == std::numeric_limits::max(); if(!autoFindExtractRM) { CSPhraseManager *pPM= CSPhraseManager::getInstance(); @@ -3758,7 +3758,7 @@ void CUserEntity::extractRM() CSPhraseManager *pm = CSPhraseManager::getInstance(); uint index; uint memoryLine; - bool autoFindPhrase = (_MoveToPhraseMemoryLine == (uint)~0); + bool autoFindPhrase = (_MoveToPhraseMemoryLine == std::numeric_limits::max()); if ( ! autoFindPhrase ) { // Use clicked phrase @@ -3773,7 +3773,7 @@ void CUserEntity::extractRM() if ( ! findExtractionActionInMemory( pm, bm, memoryLine, index ) ) { // Search in other memory bar lines (because the auto-equip does not set the current line at once) - memoryLine = ~0; + memoryLine = std::numeric_limits::max(); uint nbLines = pm->getNbMemoryLines(); for ( uint j=0; j!=nbLines; ++j ) { @@ -3788,7 +3788,7 @@ void CUserEntity::extractRM() } } - if ( memoryLine != (uint)~0 ) + if ( memoryLine != std::numeric_limits::max() ) { // Open the forage (but not for care actions). Necessary for the case of redoing an extraction after a Drop All on the same source. uint32 phraseId = pm->getMemorizedPhrase( memoryLine, index ); From 7db03223fc1c8a2e144f3055dc39c3ffba709b35 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 13:00:39 +0200 Subject: [PATCH 31/60] Changed: #142 Replace atoi and sscanf by fromString when it's possible --- code/ryzom/tools/leveldesign/prim_export/main.cpp | 10 ++++++++-- code/ryzom/tools/pd_parser/parser_rules.h | 2 +- code/ryzom/tools/pd_parser/templatizer.h | 4 +++- .../server/build_world_packed_col/zone_util.cpp | 3 ++- code/ryzom/tools/skill_extractor/skill_extractor.cpp | 4 ++-- code/ryzom/tools/stats_scan/char_commands.cpp | 12 +++++++++--- .../tools/translation_tools/extract_bot_names.cpp | 6 ++++-- code/ryzom/tools/translation_tools/main.cpp | 10 +++++++--- 8 files changed, 36 insertions(+), 15 deletions(-) diff --git a/code/ryzom/tools/leveldesign/prim_export/main.cpp b/code/ryzom/tools/leveldesign/prim_export/main.cpp index 44f377575..b993caea1 100644 --- a/code/ryzom/tools/leveldesign/prim_export/main.cpp +++ b/code/ryzom/tools/leveldesign/prim_export/main.cpp @@ -179,7 +179,9 @@ bool getZoneCoordByName(const char * name, uint16& x, uint16& y) return false; } } - y = -atoi(ystr.c_str()); + + NLMISC::fromString(ystr, y); + y = -y; // x x = 0; @@ -223,7 +225,11 @@ sint getYFromZoneName (const string &ZoneName) { xStr += ZoneName[i]; ++i; } - return -atoi(yStr.c_str()); + + sint y = 0; + NLMISC::fromString(yStr, y); + + return -y; } // *************************************************************************** diff --git a/code/ryzom/tools/pd_parser/parser_rules.h b/code/ryzom/tools/pd_parser/parser_rules.h index ed3f0fec0..a5840504e 100644 --- a/code/ryzom/tools/pd_parser/parser_rules.h +++ b/code/ryzom/tools/pd_parser/parser_rules.h @@ -203,7 +203,7 @@ CParseNode *parse##nodename(CTokenizer &tokenizer) \ { \ if (tokenizer.end() || tokenizer.current() != TokenNumber) \ PARSE_FAIL \ - main->savein = atoi(tokenizer.get(tokenizer.currentToken()).c_str()); \ + NLMISC::fromString(tokenizer.get(tokenizer.currentToken()), main->savein); \ tokenizer.next(); \ } diff --git a/code/ryzom/tools/pd_parser/templatizer.h b/code/ryzom/tools/pd_parser/templatizer.h index 70a98b5a4..2f661c059 100644 --- a/code/ryzom/tools/pd_parser/templatizer.h +++ b/code/ryzom/tools/pd_parser/templatizer.h @@ -865,7 +865,9 @@ public: if (env->envExists(subname)) { - CTemplatizerEnv* subenv = (atoi(evalinsub.c_str()) ? env->getEnv(subname) : env); + sint eval; + NLMISC::fromString(evalinsub, eval); + CTemplatizerEnv* subenv = (eval ? env->getEnv(subname) : env); return ITemplatizerBloc::eval(subenv); } diff --git a/code/ryzom/tools/server/build_world_packed_col/zone_util.cpp b/code/ryzom/tools/server/build_world_packed_col/zone_util.cpp index 64bcf268a..d63e3caf5 100644 --- a/code/ryzom/tools/server/build_world_packed_col/zone_util.cpp +++ b/code/ryzom/tools/server/build_world_packed_col/zone_util.cpp @@ -51,7 +51,8 @@ bool getZonePos(const std::string &name, sint &destX, sint &destY) if (xStr.size() != 2) return false; // compute min corner destX = ((xStr[0] - 'A') * 26 + (xStr[1] - 'A')); - destY = -atoi(yStr.c_str()); + NLMISC::fromString(yStr, destY); + destY = -destY; return true; } diff --git a/code/ryzom/tools/skill_extractor/skill_extractor.cpp b/code/ryzom/tools/skill_extractor/skill_extractor.cpp index 37b3f1020..24500f45d 100644 --- a/code/ryzom/tools/skill_extractor/skill_extractor.cpp +++ b/code/ryzom/tools/skill_extractor/skill_extractor.cpp @@ -317,10 +317,10 @@ sint main( sint argc, char ** argv ) skill.ParentSkill = toUpper(string( ptr )); break; case 3: // max skill value - skill.MaxValue = (uint16)atoi(ptr); + NLMISC::fromString(std::string(ptr), skill.MaxValue); break; case 4: // stage type - skill.StageType = (uint8)atoi(ptr); + NLMISC::fromString(std::string(ptr), skill.StageType); break; case 5: // main category skill.MainCategory = string( ptr ); diff --git a/code/ryzom/tools/stats_scan/char_commands.cpp b/code/ryzom/tools/stats_scan/char_commands.cpp index 4506536af..261e1f2e3 100644 --- a/code/ryzom/tools/stats_scan/char_commands.cpp +++ b/code/ryzom/tools/stats_scan/char_commands.cpp @@ -196,7 +196,9 @@ NLMISC_COMMAND(jobsPromote,"pause execution of jobs","") if (args.size()!=1) return false; - uint32 idx= atoi(args[0].c_str()); + uint32 idx; + NLMISC::fromString(args[0], idx); + if ( (idx==0 && args[0]!="0") ) { nlwarning("Argument is not a valid job id - should be a number"); @@ -216,7 +218,9 @@ NLMISC_COMMAND(JobUpdatesPerUpdate,"set or display the number of job updates per if (args.size()==1) { - uint32 count= atoi(args[0].c_str()); + uint32 count; + NLMISC::fromString(args[0], count); + if ( (count==0 && args[0]!="0") ) { nlwarning("Argument is not a valid number"); @@ -270,7 +274,9 @@ NLMISC_COMMAND(jobsDisplayDetails,"display detailed info for the current job (or case 1: { - uint32 idx= atoi(args[0].c_str()); + uint32 idx; + NLMISC::fromString(args[0], idx); + if ( (idx==0 && args[0]!="0") ) { nlwarning("Argument is not a valid job id - should be a number"); diff --git a/code/ryzom/tools/translation_tools/extract_bot_names.cpp b/code/ryzom/tools/translation_tools/extract_bot_names.cpp index 0bfc6f6dc..5660b1a41 100644 --- a/code/ryzom/tools/translation_tools/extract_bot_names.cpp +++ b/code/ryzom/tools/translation_tools/extract_bot_names.cpp @@ -339,7 +339,8 @@ int extractBotNames(int argc, char *argv[]) result[i]->getPropertyByName("count", countStr); result[i]->getPropertyByName("bot_sheet_look", sheetStr); - uint32 count = atoi(countStr.c_str()); + uint32 count; + NLMISC::fromString(countStr, count); if (count != 0) { @@ -402,7 +403,8 @@ int extractBotNames(int argc, char *argv[]) result[i]->getPropertyByName("count", countStr); result[i]->getPropertyByName("bot_sheet_client", sheetStr); - uint32 count = atoi(countStr.c_str()); + uint32 count; + NLMISC::fromString(countStr, count); if (count > 0 && sheetStr.empty()) { diff --git a/code/ryzom/tools/translation_tools/main.cpp b/code/ryzom/tools/translation_tools/main.cpp index decf4af78..5655442e9 100644 --- a/code/ryzom/tools/translation_tools/main.cpp +++ b/code/ryzom/tools/translation_tools/main.cpp @@ -263,14 +263,16 @@ bool parseDiffCommandFromComment(const ucstring &comments, TDiffInfo &diffInfo) string indexStr; if (!CI18N::parseLabel(it, last, indexStr)) return false; - diffInfo.Index1 = atoi(indexStr.c_str()); + + NLMISC::fromString(indexStr, diffInfo.Index1); if (diffInfo.Command == diff_swap) { CI18N::skipWhiteSpace(it, last); if (!CI18N::parseLabel(it, last, indexStr)) return false; - diffInfo.Index2 = atoi(indexStr.c_str()); + + NLMISC::fromString(indexStr, diffInfo.Index2); } return true; } @@ -3183,7 +3185,9 @@ int main(int argc, char *argv[]) showUsage(argv[0]); return 1; } - uint nbLines = atoi(argv[3]); + + uint nbLines; + NLMISC::fromString(argv[3], nbLines); cropLines(argv[2], nbLines); From 24874b0356513fcc33f55147afeb28f844964165 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 13:11:28 +0200 Subject: [PATCH 32/60] Changed: Added isWindowMaximized and getRyzomModes functions --- code/ryzom/client/src/misc.cpp | 87 ++++++++++++++++++++++++++++++++++ code/ryzom/client/src/misc.h | 6 +++ 2 files changed, 93 insertions(+) diff --git a/code/ryzom/client/src/misc.cpp b/code/ryzom/client/src/misc.cpp index bd45482b6..0e6d42491 100644 --- a/code/ryzom/client/src/misc.cpp +++ b/code/ryzom/client/src/misc.cpp @@ -1440,13 +1440,31 @@ void setVideoMode(const UDriver::CMode &mode) UDriver::CMode oldMode; oldMode.Windowed = true; // getCurrentScreenMode may fail if first init ... Driver->getCurrentScreenMode(oldMode); + bool wasMaximized = isWindowMaximized(); Driver->setMode(mode); + bool isMaximized = isWindowMaximized(); if (oldMode.Windowed && !mode.Windowed) // going to fullscreen ? { /*CInterfaceManager *pIM = CInterfaceManager::getInstance(); pIM->movePointerAbs((sint32) mode.Width / 2, (sint32) mode.Height / 2); Driver->setMousePos(0.5f, 0.5f);*/ } + else if ((!oldMode.Windowed || wasMaximized) && (mode.Windowed && !isMaximized)) // leaving fullscreen ? + { + UDriver::CMode screenMode; + + uint32 posX = 0; + uint32 posY = 0; + + if (Driver->getCurrentScreenMode(screenMode)) + { + // position is not saved in config so center the window + posX = (screenMode.Width - Driver->getWindowWidth())/2; + posY = (screenMode.Height - Driver->getWindowHeight())/2; + } + + Driver->setWindowPos(posX, posY); + } } uint getCurrentColorDepth() @@ -1464,3 +1482,72 @@ uint getCurrentColorDepth() return CSystemUtils::getCurrentColorDepth(); } +bool isWindowMaximized() +{ + UDriver::CMode screenMode; + uint32 width, height; + + Driver->getWindowSize(width, height); + + return (Driver->getCurrentScreenMode(screenMode) && screenMode.Windowed && + screenMode.Width == width && screenMode.Height == height); +} + +sint getRyzomModes(std::vector &videoModes, std::vector &stringModeList) +{ + // **** Init Video Modes + Driver->getModes(videoModes); + // Remove modes under 800x600 and get the unique strings + sint i, j, nFoundMode = -1; + for (i=0; i < (sint)videoModes.size(); ++i) + { + if ((videoModes[i].Width < 800) || (videoModes[i].Height < 600)) + { + videoModes.erase(videoModes.begin()+i); + --i; + } + else + { + bool bFound = false; + string tmp = toString(videoModes[i].Width)+" x "+toString(videoModes[i].Height); + for (j = 0; j < (sint)stringModeList.size(); ++j) + { + if (stringModeList[j] == tmp) + { + bFound = true; + break; + } + } + if (!bFound) + { + stringModeList.push_back(tmp); + if ((videoModes[i].Width <= ClientCfg.Width) && (videoModes[i].Height <= ClientCfg.Height)) + { + if (nFoundMode == -1) + { + nFoundMode = j; + } + else + { + if ((videoModes[i].Width >= videoModes[nFoundMode].Width) && + (videoModes[i].Height >= videoModes[nFoundMode].Height)) + nFoundMode = j; + } + } + } + } + } + + // If no modes are available, display a message and exit + if (!ClientCfg.Windowed && (nFoundMode == -1 || stringModeList.empty())) + { + Driver->systemMessageBox("No Video Modes available!\n" + "Minimum Video mode to play Ryzom is 800x600.\n", + "No Video Mode!", + NL3D::UDriver::okType, + NL3D::UDriver::exclamationIcon); + exit(EXIT_SUCCESS); + } + + return nFoundMode; +} diff --git a/code/ryzom/client/src/misc.h b/code/ryzom/client/src/misc.h index 7f9bd8593..7a4dff95f 100644 --- a/code/ryzom/client/src/misc.h +++ b/code/ryzom/client/src/misc.h @@ -29,6 +29,7 @@ #include "nel/misc/quat.h" #include "nel/misc/rgba.h" #include "nel/3d/u_instance.h" +#include "nel/3d/u_driver.h" #include "game_share/slot_types.h" #include "game_share/mode_and_behaviour.h" @@ -242,6 +243,11 @@ void setVideoMode(const NL3D::UDriver::CMode &mode); // Get the current color depth (8, 16, or 32). In windowed mode, this will be the desktop color depth, in fullscreen mode, the color depth of the framebuffer. uint getCurrentColorDepth(); +// get maximized +bool isWindowMaximized(); + +sint getRyzomModes(std::vector &videoModes, std::vector &stringModeList); + #endif // CL_MISC_H /* End of misc.h */ From c1073c4dd1c2597644c3ba2578e5890a3d2cd7a4 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 13:23:07 +0200 Subject: [PATCH 33/60] Changed: #142 Replace atoi and sscanf by fromString when it's possible --- code/ryzom/client/src/interface_v3/sphrase_manager.cpp | 6 ++++-- code/ryzom/client/src/npc_icon.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp index bb215b30b..e25900f91 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -4686,12 +4686,14 @@ NLMISC_COMMAND(regenTickRange, "Emulate regen tick range locally for a memory sl { if (args.size() != 1 && args.size() != 2) return false; CSPhraseManager *pPM = CSPhraseManager::getInstance(); - const CSPhraseCom &phrase = pPM->getPhrase(atoi(args[0].c_str())); + uint32 phraseId; + NLMISC::fromString(args[0], phraseId); + const CSPhraseCom &phrase = pPM->getPhrase(phraseId); uint64 powerBitField = CSPhraseManager::getPhraseRequiredFlags(phrase); TGameCycle duration; if (args.size() >= 2) { - duration = (TGameCycle) atoi(args[1].c_str()); + NLMISC::fromString(args[1], duration); } else { diff --git a/code/ryzom/client/src/npc_icon.cpp b/code/ryzom/client/src/npc_icon.cpp index 4857a7ad0..7d03ede01 100644 --- a/code/ryzom/client/src/npc_icon.cpp +++ b/code/ryzom/client/src/npc_icon.cpp @@ -486,7 +486,8 @@ NLMISC_COMMAND(queryMissionGiverData, "Query mission giver data for the specifie { if (args.size() == 0) return false; - uint32 alias = atoi(args[0].c_str()); + uint32 alias; + NLMISC::fromString(args[0], alias); CNPCIconCache::getInstance().queryMissionGiverData(alias); //giver.setDescTransient(); From 0f9a569d2a4baf1f15f8330d8b68fd2aa282c091 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 13:48:40 +0200 Subject: [PATCH 34/60] Changed: #825 Remove all warning when compiling Ryzom --- code/ryzom/common/src/game_share/persistent_data.cpp | 2 +- .../common/src/game_share/persistent_data_tree.cpp | 10 +++++----- .../src/game_share/property_allocator_client.cpp | 2 +- .../common/src/game_share/server_animation_module.cpp | 8 ++++---- .../game_share/time_weather_season/weather_predict.cpp | 2 +- code/ryzom/common/src/game_share/utils.cpp | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/code/ryzom/common/src/game_share/persistent_data.cpp b/code/ryzom/common/src/game_share/persistent_data.cpp index 9d8f8a893..dffbfa7ed 100644 --- a/code/ryzom/common/src/game_share/persistent_data.cpp +++ b/code/ryzom/common/src/game_share/persistent_data.cpp @@ -277,7 +277,7 @@ uint16 CPersistentDataRecord::addString(const string& name) uint16 result= (uint16)_StringTable.size(); _StringTable.push_back(name); - BOMB_IF(result==(uint16)~0u,"No more room in string table!!!",_StringTable.pop_back()); + BOMB_IF(result==std::numeric_limits::max(),"No more room in string table!!!",_StringTable.pop_back()); return result; } } diff --git a/code/ryzom/common/src/game_share/persistent_data_tree.cpp b/code/ryzom/common/src/game_share/persistent_data_tree.cpp index 58b029a66..156e4177f 100644 --- a/code/ryzom/common/src/game_share/persistent_data_tree.cpp +++ b/code/ryzom/common/src/game_share/persistent_data_tree.cpp @@ -133,7 +133,7 @@ CPersistentDataTreeNode::CPersistentDataTreeNode(const NLMISC::CSString& name,CP bool CPersistentDataTreeNode::attachToParent(CPersistentDataTreeNode* parent) { - return attachToParent(parent,parent==NULL?~0u:(uint32)parent->_Children.size()); + return attachToParent(parent,parent==NULL?std::numeric_limits::max():(uint32)parent->_Children.size()); } bool CPersistentDataTreeNode::attachToParent(CPersistentDataTreeNode* parent,uint32 idx) @@ -216,8 +216,8 @@ bool CPersistentDataTreeNode::attachToParent(CPersistentDataTreeNode* parent,uin bool CPersistentDataTreeNode::readFromPdr(CPersistentDataRecord& pdr) { - static uint16 mapKeyToken= (uint16)~0u; pdr.addString("__Key__",mapKeyToken); - static uint16 mapValToken= (uint16)~0u; pdr.addString("__Val__",mapValToken); + static uint16 mapKeyToken= std::numeric_limits::max(); pdr.addString("__Key__",mapKeyToken); + static uint16 mapValToken= std::numeric_limits::max(); pdr.addString("__Val__",mapValToken); while (!pdr.isEndOfData()) { @@ -378,8 +378,8 @@ bool CPersistentDataTreeNode::writeToPdr(CPersistentDataRecord& pdr) const // if this is a map entry then split into map key and value if (isMapEntry()) { - static uint16 mapKeyToken= (uint16)~0u; pdr.addString("__Key__",mapKeyToken); - static uint16 mapValToken= (uint16)~0u; pdr.addString("__Val__",mapValToken); + static uint16 mapKeyToken= std::numeric_limits::max(); pdr.addString("__Key__",mapKeyToken); + static uint16 mapValToken= std::numeric_limits::max(); pdr.addString("__Val__",mapValToken); // write a value - try to match a reasonably compact format if one exists pdrPushCompactValue(pdr,mapKeyToken,name); diff --git a/code/ryzom/common/src/game_share/property_allocator_client.cpp b/code/ryzom/common/src/game_share/property_allocator_client.cpp index b5cd00200..f4c3c340f 100644 --- a/code/ryzom/common/src/game_share/property_allocator_client.cpp +++ b/code/ryzom/common/src/game_share/property_allocator_client.cpp @@ -44,7 +44,7 @@ void CPropertyAllocatorClient::allocProperty( if ( ! (propinfo.allocated() || propinfo.Pending) ) { // Send alloc request to the local Mirror Service - if ( _LocalMSId != TServiceId(~0) ) + if ( _LocalMSId != TServiceId(std::numeric_limits::max()) ) { // Check options if ( (options & PSOReadOnly) && (options & PSOWriteOnly) ) diff --git a/code/ryzom/common/src/game_share/server_animation_module.cpp b/code/ryzom/common/src/game_share/server_animation_module.cpp index a8744e8bf..1db870ca9 100644 --- a/code/ryzom/common/src/game_share/server_animation_module.cpp +++ b/code/ryzom/common/src/game_share/server_animation_module.cpp @@ -402,10 +402,10 @@ public: CAnimationSession() { WeatherValue = 0; // auto weather - CurrSeason = ~0; + CurrSeason = std::numeric_limits::max(); StartingAct = false; InitialAct = 1; - AiInstance = ~0;//wrong value + AiInstance = std::numeric_limits::max(); //wrong value DateOfLastNewLocation = 0; InitialX = 0; @@ -3578,7 +3578,7 @@ TSessionId CServerAnimationModule::getScenarioId(uint32 charId) { return found->second; } - return TSessionId(~0u); + return TSessionId(std::numeric_limits::max()); } void CServerAnimationModule::disconnectChar(TCharId charId) @@ -3651,7 +3651,7 @@ void CServerAnimationModule::scheduleStartSessionImpl(const CAnimationMessageAni nlinfo("R2An: Char %u is connected as animator", *first); } } - session->CurrSeason = ~0; + session->CurrSeason = std::numeric_limits::max(); } diff --git a/code/ryzom/common/src/game_share/time_weather_season/weather_predict.cpp b/code/ryzom/common/src/game_share/time_weather_season/weather_predict.cpp index 7526eb74f..30f7e6ed2 100644 --- a/code/ryzom/common/src/game_share/time_weather_season/weather_predict.cpp +++ b/code/ryzom/common/src/game_share/time_weather_season/weather_predict.cpp @@ -268,7 +268,7 @@ float CPredictWeather::predictWeather(uint64 day, float hour, const CWeatherFunc static const CFctCtrlPoint *lastFct; static uint lastNumPoints; static CWeatherFunctionParamsSheetBase lastDesc; - static uint64 lastCycle = ~0; + static uint64 lastCycle = std::numeric_limits::max(); static EWeatherCycleType weatherCycle = HighPressure; static const CWeatherFunction *lastWf = NULL; diff --git a/code/ryzom/common/src/game_share/utils.cpp b/code/ryzom/common/src/game_share/utils.cpp index b5d443559..3601acef6 100644 --- a/code/ryzom/common/src/game_share/utils.cpp +++ b/code/ryzom/common/src/game_share/utils.cpp @@ -62,7 +62,7 @@ CSString cleanPath(const CSString& path,bool addTrailingSlash) break; } // if we found an element then remove it and the '..' as well - if (j!=~0u) + if (j!=std::numeric_limits::max()) { pathComponents[j].clear(); pathComponents[i].clear(); From a1d2e9354f4ec1475c4862308c75effc9024b6d9 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 13:50:08 +0200 Subject: [PATCH 35/60] Changed: #142 Replace atoi and sscanf by fromString when it's possible --- code/ryzom/common/src/game_share/object.cpp | 12 +++++++----- .../src/game_share/server_animation_module.cpp | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/code/ryzom/common/src/game_share/object.cpp b/code/ryzom/common/src/game_share/object.cpp index f395bcf7a..d15497ce4 100644 --- a/code/ryzom/common/src/game_share/object.cpp +++ b/code/ryzom/common/src/game_share/object.cpp @@ -1897,16 +1897,18 @@ uint32 CObject::instanceIdToUint32(const std::string& instanceId) std::string clientIdStr = instanceId.substr(6, clientIdIt-6); std::string componentIdStr = instanceId.substr(clientIdIt+1, size - clientIdIt); - char* ko=NULL; - uint32 clientId = static_cast(strtol(clientIdStr.c_str(), &ko, 10)); - if (*ko != '\0') + bool ko; + uint32 clientId; + ko = NLMISC::fromString(clientIdStr, clientId); + if (!ko) { nlwarning("R2Share: Wrong InstanceId(%s)", instanceId.c_str()); return 0; } - uint32 componentId = static_cast(strtol(componentIdStr.c_str(), &ko, 10)); - if (*ko != '\0') + uint32 componentId; + ko = NLMISC::fromString(componentIdStr, componentId); + if (!ko) { nlwarning("R2Share: Wrong InstanceId(%s)", instanceId.c_str()); return 0; diff --git a/code/ryzom/common/src/game_share/server_animation_module.cpp b/code/ryzom/common/src/game_share/server_animation_module.cpp index 1db870ca9..577cd3078 100644 --- a/code/ryzom/common/src/game_share/server_animation_module.cpp +++ b/code/ryzom/common/src/game_share/server_animation_module.cpp @@ -3932,14 +3932,15 @@ void CServerAnimationModule::activateEasterEgg(class NLNET::IModuleProxy * /* ai DROP_IF( itemAndQt.size() != 2, "Syntax error in activateEasterEgg", return ); - char* ok = 0; - uint32 item = static_cast(strtol(itemAndQt[0].c_str(), &ok, 10)); + uint32 item; + bool ok = NLMISC::fromString(itemAndQt[0], item); - DROP_IF( *ok != '\0', "Error activateEasterEgg", return); + DROP_IF( !ok, "Error activateEasterEgg", return); - uint32 qt = static_cast(strtol(itemAndQt[1].c_str(), &ok, 10)); + uint32 qt; + ok = NLMISC::fromString(itemAndQt[1], qt); - DROP_IF( *ok != '\0', "Error in activateEasterEgg", return); + DROP_IF( !ok, "Error in activateEasterEgg", return); DROP_IF( qt > 255, "Error in activateEasterEgg", return); DROP_IF( item >= session->MissionItems.size(), "Error activateEasterEgg", return); From 302550eb7eea44f5671cc0050b71d7dcefd62f7a Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 13:50:31 +0200 Subject: [PATCH 36/60] Changed: #841 Change the wrong header in the source code --- code/ryzom/common/src/game_share/r2_modules_itf.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/code/ryzom/common/src/game_share/r2_modules_itf.h b/code/ryzom/common/src/game_share/r2_modules_itf.h index a3ab7a03d..e8626cafd 100644 --- a/code/ryzom/common/src/game_share/r2_modules_itf.h +++ b/code/ryzom/common/src/game_share/r2_modules_itf.h @@ -1,3 +1,18 @@ +// Ryzom - 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 . ///////////////////////////////////////////////////////////////// // WARNING : this is a generated file, don't change it ! From 5f9ae67e1b6b60e10123cc951464102eff2c2954 Mon Sep 17 00:00:00 2001 From: "Matt Raykowski\"" Date: Mon, 18 Oct 2010 10:13:01 -0500 Subject: [PATCH 37/60] Fixed: WITH_CEGUI changed to WITH_NEL_CEGUI but wasn't corrected in the build tree. It is now. --- code/CMakeLists.txt | 4 ++-- code/nel/CMakeLists.txt | 4 ++-- code/nel/include/nel/CMakeLists.txt | 4 ++-- code/nel/samples/3d/CMakeLists.txt | 4 ++-- code/nel/src/CMakeLists.txt | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 538382e5f..a504198ed 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -260,14 +260,14 @@ IF(WIN32) ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "Release") # Install CEGUI and its dependencies. - IF(WITH_CEGUI) + IF(WITH_NEL_CEGUI) INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIBase.dll" DESTINATION bin) INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIDevilImageCodec.dll" DESTINATION bin) INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIExpatParser.dll" DESTINATION bin) INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIFalagardWRBase.dll" DESTINATION bin) INSTALL(FILES "${CEGUI_LIB_DIR}/Devil.dll" DESTINATION bin) INSTALL(FILES "${CEGUI_LIB_DIR}/ILU.dll" DESTINATION bin) - ENDIF(WITH_CEGUI) + ENDIF(WITH_NEL_CEGUI) # Only the tools require MFC. IF(WITH_TOOLS) diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index bff4ab359..74c8a1902 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -32,9 +32,9 @@ IF(WITH_3D) ENDIF(NOT WIN32) ENDIF(WITH_DRIVER_OPENGL) - IF(WITH_CEGUI) + IF(WITH_NEL_CEGUI) FIND_PACKAGE(CEGUI) - ENDIF(WITH_CEGUI) + ENDIF(WITH_NEL_CEGUI) ENDIF(WITH_3D) diff --git a/code/nel/include/nel/CMakeLists.txt b/code/nel/include/nel/CMakeLists.txt index 0be2a83a0..9e2d5586c 100644 --- a/code/nel/include/nel/CMakeLists.txt +++ b/code/nel/include/nel/CMakeLists.txt @@ -28,6 +28,6 @@ IF(WITH_PACS) SUBDIRS(pacs) ENDIF(WITH_PACS) -IF(WITH_CEGUI) +IF(WITH_NEL_CEGUI) SUBDIRS(cegui) -ENDIF(WITH_CEGUI) +ENDIF(WITH_NEL_CEGUI) diff --git a/code/nel/samples/3d/CMakeLists.txt b/code/nel/samples/3d/CMakeLists.txt index 1abd079b2..ee038e23c 100644 --- a/code/nel/samples/3d/CMakeLists.txt +++ b/code/nel/samples/3d/CMakeLists.txt @@ -2,9 +2,9 @@ ADD_SUBDIRECTORY(font) ADD_SUBDIRECTORY(cluster_viewer) ADD_SUBDIRECTORY(shape_viewer) -IF(WITH_CEGUI) +IF(WITH_NEL_CEGUI) ADD_SUBDIRECTORY(cegui) -ENDIF(WITH_CEGUI) +ENDIF(WITH_NEL_CEGUI) #IF(WITH_QT) # ADD_SUBDIRECTORY(qtnel) diff --git a/code/nel/src/CMakeLists.txt b/code/nel/src/CMakeLists.txt index 690768531..4bf260c13 100644 --- a/code/nel/src/CMakeLists.txt +++ b/code/nel/src/CMakeLists.txt @@ -24,9 +24,9 @@ IF(WITH_SOUND) ADD_SUBDIRECTORY(sound) ENDIF(WITH_SOUND) -IF(WITH_CEGUI) +IF(WITH_NEL_CEGUI) ADD_SUBDIRECTORY(cegui) -ENDIF(WITH_CEGUI) +ENDIF(WITH_NEL_CEGUI) IF(WITH_PACS) ADD_SUBDIRECTORY(pacs) From 211f65156bd26cc7124dd544415017489f6345ff Mon Sep 17 00:00:00 2001 From: "Matt Raykowski\"" Date: Mon, 18 Oct 2010 10:15:23 -0500 Subject: [PATCH 38/60] Changed: Moved this header, changing it in the source file too. --- code/nel/src/ligo/zone_bank.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/ligo/zone_bank.cpp b/code/nel/src/ligo/zone_bank.cpp index 38b2ca5d6..5f03c4bb5 100644 --- a/code/nel/src/ligo/zone_bank.cpp +++ b/code/nel/src/ligo/zone_bank.cpp @@ -17,7 +17,7 @@ #include "stdligo.h" -#include "zone_bank.h" +#include "nel/ligo/zone_bank.h" #ifdef NL_OS_WINDOWS From e9ebb9ae1f7d40e7a2aa34478d5a9b90ab389918 Mon Sep 17 00:00:00 2001 From: "Matt Raykowski\"" Date: Mon, 18 Oct 2010 10:30:55 -0500 Subject: [PATCH 39/60] Fixed: Nightly Linux build failed - 'export' tool is Windows only. --- code/ryzom/tools/leveldesign/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/ryzom/tools/leveldesign/CMakeLists.txt b/code/ryzom/tools/leveldesign/CMakeLists.txt index 2b6045998..ae9f502d3 100644 --- a/code/ryzom/tools/leveldesign/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/CMakeLists.txt @@ -3,9 +3,11 @@ ADD_SUBDIRECTORY(prim_export) ADD_SUBDIRECTORY(uni_conv) ADD_SUBDIRECTORY(csv_transform) ADD_SUBDIRECTORY(icon_search) -ADD_SUBDIRECTORY(export) ADD_SUBDIRECTORY(world_editor) +IF(WIN32) + ADD_SUBDIRECTORY(export) +ENDIF(WIN32) # Legacy folders, do not build #ADD_SUBDIRECTORY(export) From fa39973ad24e2d6b9f25c634eceea15049a4e1c3 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 19:11:05 +0200 Subject: [PATCH 40/60] Changed: #841 Change the wrong header in the source code --- code/nel/include/nel/cegui/inellibrary.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/code/nel/include/nel/cegui/inellibrary.h b/code/nel/include/nel/cegui/inellibrary.h index 73ff3e2f8..4cc3c17e2 100644 --- a/code/nel/include/nel/cegui/inellibrary.h +++ b/code/nel/include/nel/cegui/inellibrary.h @@ -1,3 +1,19 @@ +// 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 . + #ifndef __INELLIBRARY_H__ #define __INELLIBRARY_H__ From de0731c04d7fa65673823af53f54093049fb3927 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 19:11:58 +0200 Subject: [PATCH 41/60] Changed: #825 Remove all warning when compiling Ryzom --- code/nel/include/nel/misc/eid_translator.h | 2 +- code/nel/src/misc/eid_translator.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/misc/eid_translator.h b/code/nel/include/nel/misc/eid_translator.h index 82d239511..26b296ea1 100644 --- a/code/nel/include/nel/misc/eid_translator.h +++ b/code/nel/include/nel/misc/eid_translator.h @@ -41,7 +41,7 @@ public: : EntityNameStringId(0), EntitySlot(-1), ShardId(0), - UId(~0), + UId(std::numeric_limits::max()), Online(false) { } diff --git a/code/nel/src/misc/eid_translator.cpp b/code/nel/src/misc/eid_translator.cpp index 3d1a81bf1..36ea84247 100644 --- a/code/nel/src/misc/eid_translator.cpp +++ b/code/nel/src/misc/eid_translator.cpp @@ -574,7 +574,7 @@ void CEntityIdTranslator::getEntityIdInfo (const CEntityId &eid, ucstring &entit nlwarning ("EIT: %s is not registered in CEntityIdTranslator", reid.toString().c_str()); entityName = ""; entitySlot = -1; - uid = ~0; + uid = std::numeric_limits::max(); userName = ""; online = false; } From 725daff253c1d8004700a6a9a05324c3a59a3425 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 19:34:20 +0200 Subject: [PATCH 42/60] Fixed: #1129 Implement missing CI18N::getLanguageCodes and CI18N::getLanguageNames methods --- code/nel/include/nel/misc/i18n.h | 3 ++ code/nel/src/misc/i18n.cpp | 48 ++++++++++++++------------------ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/code/nel/include/nel/misc/i18n.h b/code/nel/include/nel/misc/i18n.h index 6778efcc6..4a1984d65 100644 --- a/code/nel/include/nel/misc/i18n.h +++ b/code/nel/include/nel/misc/i18n.h @@ -241,6 +241,9 @@ private: private: + /// Init _LanguageCodes and _LanguageNames + static void initLanguages(); + static bool loadFileIntoMap(const std::string &filename, StrMapContainer &dest); /// The internal read function, it does the real job of readTextFile diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index 94e41a06a..e76dc73eb 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -39,40 +39,34 @@ void CI18N::setLoadProxy(ILoadProxy *loadProxy) _LoadProxy = loadProxy; } +void CI18N::initLanguages() +{ + if (!_LanguagesNamesLoaded) + { + _LanguageCodes.push_back("en"); + _LanguageCodes.push_back("fr"); + _LanguageCodes.push_back("de"); + _LanguageCodes.push_back("ru"); + + _LanguageNames.push_back("English"); + _LanguageNames.push_back("French"); + _LanguageNames.push_back("German"); + _LanguageNames.push_back("Russian"); + + _LanguagesNamesLoaded = true; + } +} + const std::vector &CI18N::getLanguageNames() { + initLanguages(); + return _LanguageNames; } const std::vector &CI18N::getLanguageCodes() { - if (!_LanguagesNamesLoaded) - { - std::vector files; - - // search all .uxt files - CPath::getFileList("uxt", files); - - // if not uxt found, use default languages - if (files.empty()) - { - _LanguageCodes.clear(); - _LanguageCodes.push_back("en"); - _LanguageCodes.push_back("fr"); - _LanguageCodes.push_back("de"); - _LanguageCodes.push_back("ru"); - } - else - { - // add all languages found - for(uint i = 0; i < files.size(); ++i) - { - _LanguageCodes.push_back(toLower(CFile::getFilenameWithoutExtension(files[i]))); - } - - _LanguagesNamesLoaded = true; - } - } + initLanguages(); return _LanguageCodes; } From e3a648f1ece9f643fe884be64dcc79721c1b527d Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 19:42:16 +0200 Subject: [PATCH 43/60] Changed: #1135 Merge changes from Ryzom patch 1.10 --- code/ryzom/common/src/game_share/action_sint64.cpp | 2 +- code/ryzom/common/src/game_share/dyn_chat.h | 1 + code/ryzom/common/src/game_share/item_family.cpp | 1 + code/ryzom/common/src/game_share/item_type.cpp | 1 + code/ryzom/common/src/game_share/item_type.h | 1 + code/ryzom/common/src/game_share/ryzom_mirror_properties.h | 2 +- 6 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/ryzom/common/src/game_share/action_sint64.cpp b/code/ryzom/common/src/game_share/action_sint64.cpp index 6cc00deda..cbdeb1e06 100644 --- a/code/ryzom/common/src/game_share/action_sint64.cpp +++ b/code/ryzom/common/src/game_share/action_sint64.cpp @@ -73,7 +73,7 @@ void CActionSint64::registerNumericPropertiesRyzom() CActionSint64::registerNumericProperty( PROPERTY_GUILD_NAME_ID, 32 ); CActionSint64::registerNumericProperty( PROPERTY_EVENT_FACTION_ID, 32 ); CActionSint64::registerNumericProperty( PROPERTY_PVP_MODE, PVP_MODE::NbBits ); - CActionSint64::registerNumericProperty( PROPERTY_PVP_CLAN, PVP_CLAN::NbBits ); + CActionSint64::registerNumericProperty( PROPERTY_PVP_CLAN, 32 ); CActionSint64::registerNumericProperty( PROPERTY_OWNER_PEOPLE, 3 ); // 4 races and unknow CActionSint64::registerNumericProperty( PROPERTY_OUTPOST_INFOS, 16 ); // 15+1 } diff --git a/code/ryzom/common/src/game_share/dyn_chat.h b/code/ryzom/common/src/game_share/dyn_chat.h index 8cc5b8bdc..37b53588c 100644 --- a/code/ryzom/common/src/game_share/dyn_chat.h +++ b/code/ryzom/common/src/game_share/dyn_chat.h @@ -33,6 +33,7 @@ typedef NLMISC::CEntityId TChanID; // tag for invalid channel const TChanID DYN_CHAT_INVALID_CHAN = NLMISC::CEntityId::Unknown; +const std::string DYN_CHAT_INVALID_NAME; /// Message payload for player input forward to channel service owner diff --git a/code/ryzom/common/src/game_share/item_family.cpp b/code/ryzom/common/src/game_share/item_family.cpp index f0cfbf9e6..47f3782b5 100644 --- a/code/ryzom/common/src/game_share/item_family.cpp +++ b/code/ryzom/common/src/game_share/item_family.cpp @@ -107,6 +107,7 @@ namespace ITEMFAMILY fam == SHIELD || fam == JEWELRY || fam == CRYSTALLIZED_SPELL || + fam == CONSUMABLE || fam == ITEM_SAP_RECHARGE; } diff --git a/code/ryzom/common/src/game_share/item_type.cpp b/code/ryzom/common/src/game_share/item_type.cpp index 028240ebc..5b8c8e3e2 100644 --- a/code/ryzom/common/src/game_share/item_type.cpp +++ b/code/ryzom/common/src/game_share/item_type.cpp @@ -97,6 +97,7 @@ namespace ITEM_TYPE { "HAIRCOLOR_FEMALE", HAIRCOLOR_FEMALE }, { "TATOO_FEMALE", TATOO_FEMALE }, { "SERVICE_STABLE", SERVICE_STABLE }, + { "JOB_ELEMENT", JOB_ELEMENT }, { "GENERIC", GENERIC }, }; diff --git a/code/ryzom/common/src/game_share/item_type.h b/code/ryzom/common/src/game_share/item_type.h index 9b6c3947d..c9a94d661 100644 --- a/code/ryzom/common/src/game_share/item_type.h +++ b/code/ryzom/common/src/game_share/item_type.h @@ -92,6 +92,7 @@ namespace ITEM_TYPE HAIRCOLOR_FEMALE, TATOO_FEMALE, SERVICE_STABLE, + JOB_ELEMENT, GENERIC, UNDEFINED, diff --git a/code/ryzom/common/src/game_share/ryzom_mirror_properties.h b/code/ryzom/common/src/game_share/ryzom_mirror_properties.h index 20c3fe238..0aab0b870 100644 --- a/code/ryzom/common/src/game_share/ryzom_mirror_properties.h +++ b/code/ryzom/common/src/game_share/ryzom_mirror_properties.h @@ -139,7 +139,7 @@ void initRyzomVisualPropertyIndices( CMirroredDataSet& dataset ); #define TYPE_EVENT_FACTION_ID uint32 #define TYPE_PVP_MODE uint8 -#define TYPE_PVP_CLAN uint8 +#define TYPE_PVP_CLAN uint32 #define TYPE_FUEL bool From 5c1aee15093199d7fd5ad9431d33e9bf4823188e Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 20:02:31 +0200 Subject: [PATCH 44/60] Changed: #1135 Merge changes from Ryzom patch 1.10 --- code/ryzom/client/src/character_cl.cpp | 19 +- code/ryzom/client/src/character_cl.h | 42 ++ code/ryzom/client/src/client_chat_manager.cpp | 69 ++- code/ryzom/client/src/commands.cpp | 467 ++++++++++++------ code/ryzom/client/src/cursor_functions.cpp | 2 +- code/ryzom/client/src/entities.cpp | 84 ++++ code/ryzom/client/src/entities.h | 32 +- code/ryzom/client/src/entity_cl.cpp | 22 +- code/ryzom/client/src/entity_cl.h | 8 +- code/ryzom/client/src/init_main_loop.cpp | 11 +- .../src/interface_v3/action_handler_game.cpp | 168 +++++++ .../src/interface_v3/action_handler_help.cpp | 160 +++++- .../client/src/interface_v3/chat_filter.cpp | 3 +- .../client/src/interface_v3/chat_window.cpp | 17 +- .../client/src/interface_v3/group_html.cpp | 271 +++++++--- .../client/src/interface_v3/group_html.h | 29 +- .../interface_v3/group_in_scene_user_info.cpp | 115 ++++- .../client/src/interface_v3/guild_manager.cpp | 179 +++++-- .../client/src/interface_v3/guild_manager.h | 11 +- .../src/interface_v3/interface_3d_scene.cpp | 20 +- .../src/interface_v3/interface_manager.cpp | 310 ++++++++++++ .../src/interface_v3/interface_manager.h | 8 + .../src/interface_v3/interface_parser.cpp | 65 ++- .../src/interface_v3/interface_parser.h | 2 +- .../ryzom/client/src/interface_v3/lua_ihm.cpp | 9 +- .../src/interface_v3/people_interraction.cpp | 155 ++++-- .../src/interface_v3/people_interraction.h | 2 + .../client/src/interface_v3/people_list.cpp | 111 ++++- .../client/src/interface_v3/people_list.h | 16 + .../client/src/interface_v3/view_bitmap.cpp | 2 +- code/ryzom/client/src/light_cycle_manager.cpp | 24 +- code/ryzom/client/src/net_manager.cpp | 77 ++- code/ryzom/client/src/player_cl.cpp | 55 ++- code/ryzom/client/src/user_entity.cpp | 26 +- code/ryzom/client/src/user_entity.h | 7 +- 35 files changed, 2190 insertions(+), 408 deletions(-) diff --git a/code/ryzom/client/src/character_cl.cpp b/code/ryzom/client/src/character_cl.cpp index 146d0dc1c..4e7a45885 100644 --- a/code/ryzom/client/src/character_cl.cpp +++ b/code/ryzom/client/src/character_cl.cpp @@ -359,6 +359,13 @@ CCharacterCL::CCharacterCL() _EventFactionId = 0; _PvpMode = PVP_MODE::None; _PvpClan = PVP_CLAN::None; + + for (uint8 i = 0; i < PVP_CLAN::NbClans; i++) + { + _PvpAllies[i] = false; + _PvpEnemies[i] = false; + } + _OutpostId = 0; _OutpostSide = OUTPOSTENUMS::UnknownPVPSide; @@ -1853,12 +1860,16 @@ void CCharacterCL::updateVisualPropertyPvpMode(const NLMISC::TGameCycle &/* game //----------------------------------------------- void CCharacterCL::updateVisualPropertyPvpClan(const NLMISC::TGameCycle &/* gameCycle */, const sint64 &prop) { - _PvpClan = PVP_CLAN::TPVPClan(prop); - if (_PvpClan >= PVP_CLAN::NbClans) + // get fames signs from prop + for (uint8 fameIdx = 0; fameIdx < 7; fameIdx++) { - //nlwarning("updateVisualPropertyPvpClan: received invalid PvP clan: %"NL_I64"u", prop); - _PvpClan = PVP_CLAN::None; + _PvpAllies[fameIdx] = prop & (1 << 2*fameIdx); + _PvpEnemies[fameIdx] = prop & (1 << ((2*fameIdx)+1)); } + + _ClanCivMaxFame = PVP_CLAN::TPVPClan((prop & (0x03 << 2*7)) >> 2*7); + _ClanCultMaxFame = PVP_CLAN::TPVPClan(4 + ((prop & (0x03 << 2*8)) >> 2*8)); + buildInSceneInterface(); } // updateVisualPropertyPvpClan // diff --git a/code/ryzom/client/src/character_cl.h b/code/ryzom/client/src/character_cl.h index 85f408fa7..1a0e864d0 100644 --- a/code/ryzom/client/src/character_cl.h +++ b/code/ryzom/client/src/character_cl.h @@ -372,6 +372,44 @@ public: void setPvpMode(uint8 mode) { _PvpMode=mode; } virtual PVP_CLAN::TPVPClan getPvpClan() const { return _PvpClan; } void setPvpClan(PVP_CLAN::TPVPClan clan) { _PvpClan=clan; } + + virtual PVP_CLAN::TPVPClan getClanCivMaxFame() const { return _ClanCivMaxFame; } + void setClanCivMaxFame(PVP_CLAN::TPVPClan clan) { _ClanCivMaxFame=clan; } + virtual PVP_CLAN::TPVPClan getClanCultMaxFame() const { return _ClanCultMaxFame; } + void setClanCultMaxFame(PVP_CLAN::TPVPClan clan) { _ClanCultMaxFame=clan; } + + virtual bool isPvpAlly(uint8 faction) const { if (faction < PVP_CLAN::NbClans) return _PvpAllies[faction]; else return false; } + virtual bool isPvpEnnemy(uint8 faction) const { if (faction < PVP_CLAN::NbClans) return _PvpEnemies[faction]; else return false; } + + virtual bool isPvpMarauder() const + { + for (uint8 i = 0; i < 4; i++) + if (!_PvpEnemies[i]) + return false; + return true; + } + + virtual bool isPvpTrytonist() const + { + if (_PvpEnemies[4] && _PvpEnemies[6]) + return true; + return false; + } + + virtual bool isPvpPrimas() const + { + if (_PvpAllies[4] && _PvpAllies[6]) + return true; + return false; + } + + virtual bool isPvpRanger() const + { + for (uint8 i = 0; i < 4; i++) + if (!_PvpAllies[i]) + return false; + return true; + } virtual uint16 getOutpostId() const { return _OutpostId; } virtual OUTPOSTENUMS::TPVPSide getOutpostSide() const { return _OutpostSide; } @@ -690,6 +728,10 @@ protected: uint32 _EventFactionId; uint8 _PvpMode; PVP_CLAN::TPVPClan _PvpClan; + PVP_CLAN::TPVPClan _ClanCivMaxFame; + PVP_CLAN::TPVPClan _ClanCultMaxFame; + bool _PvpAllies[PVP_CLAN::NbClans]; + bool _PvpEnemies[PVP_CLAN::NbClans]; uint16 _OutpostId; OUTPOSTENUMS::TPVPSide _OutpostSide; diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index aa438a989..97814abe1 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -40,6 +40,7 @@ #include "game_share/generic_xml_msg_mngr.h" #include "game_share/msg_client_server.h" #include "game_share/chat_group.h" +#include "interface_v3/skill_manager.h" using namespace std; using namespace NLMISC; @@ -948,19 +949,29 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin else { ucstring name = CEntityCL::removeTitleAndShardFromName(sender); + ucstring csr; // special case where there is only a title, very rare case for some NPC if (name.empty()) { // we need the gender to display the correct title CCharacterCL *entity = dynamic_cast(EntitiesMngr.getEntityByName(sender, true, true)); - bool bWoman = entity && entity->getGender() == GSGENDER::female; name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); + } + else + { + // Does the char have a CSR title? + csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); } - result = name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg; + ucstring cur_time; + if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + { + cur_time = CInterfaceManager::getTimestampHuman(); + } + result = cur_time + csr + name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg; } } @@ -992,27 +1003,41 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde // Format the sentence with the provided sender name ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender); + + // Add time if not a &bbl& + ucstring cur_time; + if (cat.toString() != "&bbl&") + { + if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + { + cur_time = CInterfaceManager::getTimestampHuman(); + } + } + + ucstring csr; + // Does the char have a CSR title? + csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); + if (UserEntity && senderName == UserEntity->getDisplayName()) { - // the player talks + // The player talks switch(type) { case CChatGroup::shout: - result = cat + CI18N::get("youShout") + ucstring(" : ") + finalMsg; + result = cat + cur_time + csr + CI18N::get("youShout") + ucstring(": ") + finalMsg; break; default: - result = cat + CI18N::get("youSay") + ucstring(" : ") + finalMsg; + result = cat + cur_time + csr + CI18N::get("youSay") + ucstring(": ") + finalMsg; break; } } else { - // special case where there is only a title, very rare case for some NPC + // Special case where there is only a title, very rare case for some NPC if (senderName.empty()) { - // we need the gender to display the correct title CCharacterCL *entity = dynamic_cast(EntitiesMngr.getEntityByName(sender, true, true)); - + // We need the gender to display the correct title bool bWoman = entity && entity->getGender() == GSGENDER::female; senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); @@ -1021,10 +1046,10 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde switch(type) { case CChatGroup::shout: - result = cat + senderName + ucstring(" ") + CI18N::get("heShout") + ucstring(" : ") + finalMsg; + result = cat + cur_time + csr + senderName + ucstring(" ") + CI18N::get("heShout") + ucstring(": ") + finalMsg; break; default: - result = cat + senderName + ucstring(" ") + CI18N::get("heSays") + ucstring(" : ") + finalMsg; + result = cat + cur_time + csr + senderName + ucstring(" ") + CI18N::get("heSays") + ucstring(": ") + finalMsg; break; } } @@ -1157,7 +1182,13 @@ class CHandlerTell : public IActionHandler prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); ucstring finalMsg; CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, false); - finalMsg += CI18N::get("youTell") + ": "; + ucstring cur_time; + if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + { + cur_time = CInterfaceManager::getTimestampHuman(); + } + ucstring csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + finalMsg += cur_time + csr + CI18N::get("youTell") + ": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, true); finalMsg += message; @@ -1238,6 +1269,14 @@ void CClientChatManager::updateChatModeAndButton(uint mode) case CChatGroup::universe: pUserBut->setHardText("uiFilterUniverse"); break; case CChatGroup::team: if (teamActive) pUserBut->setHardText("uiFilterTeam"); break; case CChatGroup::guild: if (guildActive) pUserBut->setHardText("uiFilterGuild"); break; + case CChatGroup::dyn_chat: + uint32 index = PeopleInterraction.TheUserChat.Filter.getTargetDynamicChannelDbIndex(); + uint32 textId = pIM->getDbProp("SERVER:DYN_CHAT:CHANNEL"+toString(index)+":NAME")->getValue32(); + ucstring title; + STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); + pUserBut->setHardText(title.toUtf8()); + break; + // NB: user chat cannot have yubo_chat target } pUserBut->setActive(true); @@ -1276,6 +1315,12 @@ class CHandlerTalk : public IActionHandler text.fromUtf8 (getParam (sParams, "text")); // text = getParam (sParams, "text"); + // Parse any tokens in the text + if ( ! CInterfaceManager::parseTokens(text)) + { + return; + } + // Find the base group if ((modedisplaySystemInfo (ucstring(cmd+" : ")+CI18N::get ("uiCommandNotExists")); + im->displaySystemInfo (ucstring(cmd+": ")+CI18N::get ("uiCommandNotExists")); } } else diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index a31619936..cb88846e1 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -125,7 +125,7 @@ extern CClientChatManager ChatMngr; extern ULandscape *Landscape; extern UScene *Scene; extern CLog g_log; - +extern CEntityManager EntitiesMngr; /////////////// // Variables // @@ -342,6 +342,317 @@ NLMISC_COMMAND(random, "Roll a dice and say the result around","[] ") return true; } +//----------------------------------------------- +// 'dumpShapePos' : Dump Last Added Shape Pos +//----------------------------------------------- +NLMISC_COMMAND(dumpShapePos, "Dump Last Added Shape Pos.", "") +{ + #if FINAL_VERSION + if (!hasPrivilegeDEV() && + !hasPrivilegeSGM() && + !hasPrivilegeGM() && + !hasPrivilegeVG() && + !hasPrivilegeSG() && + !hasPrivilegeG() && + !hasPrivilegeEM() && + !hasPrivilegeEG()) + return true; + #endif // FINAL_VERSION + + if (ShapeAddedByCommand.empty()) + { + nlwarning("No shape created yet"); + return false; + } + + CInterfaceManager *IM = CInterfaceManager::getInstance(); + CVector pos = ShapeAddedByCommand.back().getPos(); + IM->displaySystemInfo(ucstring(toString("Shape Pos = %f, %f, %f", pos.x, pos.y, pos.z))); + return true; +} +//----------------------------------------------- +// 'clearShape' : Remove all shapes added with the 'shape' command +//----------------------------------------------- +NLMISC_COMMAND(clearShape, "Remove all shapes added with the 'shape' command.", "") +{ + #if FINAL_VERSION + if (!hasPrivilegeDEV() && + !hasPrivilegeSGM() && + !hasPrivilegeGM() && + !hasPrivilegeVG() && + !hasPrivilegeSG() && + !hasPrivilegeG() && + !hasPrivilegeEM() && + !hasPrivilegeEG()) + return true; + #endif // FINAL_VERSION + + if (ShapeAddedByCommand.empty()) + { + nlwarning("No shape created yet"); + return false; + } + + if (!Scene) return false; + for(uint k = 0; k < ShapeAddedByCommand.size(); ++k) + { + Scene->deleteInstance(ShapeAddedByCommand[k]); + } + ShapeAddedByCommand.clear(); + return true; +} + +//----------------------------------------------------- +// 'setShapeX' : Set X position for last created shape +//----------------------------------------------------- +NLMISC_COMMAND(setShapeX, "Set X position for last created shape.", "") +{ + #if FINAL_VERSION + if (!hasPrivilegeDEV() && + !hasPrivilegeSGM() && + !hasPrivilegeGM() && + !hasPrivilegeVG() && + !hasPrivilegeSG() && + !hasPrivilegeG() && + !hasPrivilegeEM() && + !hasPrivilegeEG()) + return true; + #endif // FINAL_VERSION + + if (args.size() != 1) return false; + if (ShapeAddedByCommand.empty()) + { + nlwarning("No shape created yet"); + return false; + } + float coord; + bool valid_coord; + if (args[0][0] == '+') + valid_coord = fromString(args[0].substr(1), coord); + else + valid_coord = fromString(args[0], coord); + + if (!valid_coord) + { + nlwarning("Can't get position"); + return false; + } + CVector pos = ShapeAddedByCommand.back().getPos(); + if (args[0][0] == '+') + pos.x += coord; + else + pos.x = coord; + ShapeAddedByCommand.back().setPos(pos); + return true; +} + +//----------------------------------------------------- +// 'setShapeY' : Set Y position for last created shape +//----------------------------------------------------- +NLMISC_COMMAND(setShapeY, "Set Y position for last created shape.", "") +{ + #if FINAL_VERSION + if (!hasPrivilegeDEV() && + !hasPrivilegeSGM() && + !hasPrivilegeGM() && + !hasPrivilegeVG() && + !hasPrivilegeSG() && + !hasPrivilegeG() && + !hasPrivilegeEM() && + !hasPrivilegeEG()) + return true; + #endif // FINAL_VERSION + + if (args.size() != 1) return false; + if (ShapeAddedByCommand.empty()) + { + nlwarning("No shape created yet"); + return false; + } + float coord; + bool valid_coord; + if (args[0][0] == '+') + valid_coord = fromString(args[0].substr(1), coord); + else + valid_coord = fromString(args[0], coord); + + if (!valid_coord) + { + nlwarning("Can't get position"); + return false; + } + CVector pos = ShapeAddedByCommand.back().getPos(); + if (args[0][0] == '+') + pos.y += coord; + else + pos.y = coord; + ShapeAddedByCommand.back().setPos(pos); + return true; +} + +//----------------------------------------------------- +// 'setShapeZ' : Set Z position for last created shape +//----------------------------------------------------- +NLMISC_COMMAND(setShapeZ, "Set Z position for last created shape.", "") +{ + #if FINAL_VERSION + if (!hasPrivilegeDEV() && + !hasPrivilegeSGM() && + !hasPrivilegeGM() && + !hasPrivilegeVG() && + !hasPrivilegeSG() && + !hasPrivilegeG() && + !hasPrivilegeEM() && + !hasPrivilegeEG()) + return true; + #endif // FINAL_VERSION + + if (args.size() != 1) return false; + if (ShapeAddedByCommand.empty()) + { + nlwarning("No shape created yet"); + return false; + } + float coord; + bool valid_coord; + if (args[0][0] == '+') + valid_coord = fromString(args[0].substr(1), coord); + else + valid_coord = fromString(args[0], coord); + + if (!valid_coord) + { + nlwarning("Can't get position"); + return false; + } + CVector pos = ShapeAddedByCommand.back().getPos(); + if (args[0][0] == '+') + pos.z += coord; + else + pos.z = coord; + ShapeAddedByCommand.back().setPos(pos); + return true; +} + + +//----------------------------------------------------- +// 'setShapeDir' : Set direction angle for last created shape +//----------------------------------------------------- +NLMISC_COMMAND(setShapeDir, "Set direction angle for last created shape.", "") +{ + #if FINAL_VERSION + if (!hasPrivilegeDEV() && + !hasPrivilegeSGM() && + !hasPrivilegeGM() && + !hasPrivilegeVG() && + !hasPrivilegeSG() && + !hasPrivilegeG() && + !hasPrivilegeEM() && + !hasPrivilegeEG()) + return true; + #endif // FINAL_VERSION + + if (args.size() != 1) return false; + if (ShapeAddedByCommand.empty()) + { + nlwarning("No shape created yet"); + return false; + } + float angle; + if (!fromString(args[0], angle)) + { + nlwarning("Can't get angle"); + return false; + } + + CMatrix dir; + dir.identity(); + CVector vangle = CVector(sin(angle), cos(angle), 0.f); + CVector vi = vangle^CVector(0.f, 0.f, 1.f); + CVector vk = vi^vangle; + dir.setRot(vi, vangle, vk, true); + // Set Orientation : User Direction should be normalized. + ShapeAddedByCommand.back().setRotQuat(dir.getRot()); + + return true; +} + + +//----------------------------------------------- +// 'shape' : Add a shape in the scene. +//----------------------------------------------- +NLMISC_COMMAND(shape, "Add a shape in the scene.", "") +{ + #if FINAL_VERSION + if (!hasPrivilegeDEV() && + !hasPrivilegeSGM() && + !hasPrivilegeGM() && + !hasPrivilegeVG() && + !hasPrivilegeSG() && + !hasPrivilegeG() && + !hasPrivilegeEM() && + !hasPrivilegeEG()) + return true; + #endif // FINAL_VERSION + + if(args.size() < 1) + { + nlwarning("Command 'shape': need at least 1 parameter, try '/help shape' for more details."); + return false; + } + if (!Scene) + { + nlwarning("No scene available"); + return false; + } + UInstance instance = Scene->createInstance(args[0]); + if(!instance.empty()) + { + ShapeAddedByCommand.push_back(instance); + // Set the position + instance.setPos(UserEntity->pos()); + instance.setClusterSystem(UserEntity->getClusterSystem()); // for simplicity, assume it is in the same + // cluster system than the user + // Compute the direction Matrix + CMatrix dir; + dir.identity(); + CVector vi = UserEntity->dir()^CVector(0.f, 0.f, 1.f); + CVector vk = vi^UserEntity->dir(); + dir.setRot(vi, UserEntity->dir(), vk, true); + // Set Orientation : User Direction should be normalized. + instance.setRotQuat(dir.getRot()); + // if the shape is a particle system, additionnal parameters are user params + UParticleSystemInstance psi; + psi.cast (instance); + if (!psi.empty()) + { + // set each user param that is present + for(uint k = 0; k < 4; ++k) + { + if (args.size() >= (k + 2)) + { + float uparam; + if (fromString(args[k + 1], uparam)) + { + psi.setUserParam(k, uparam); + } + else + { + nlwarning("Cant read param %d", k); + } + } + } + } + } + else + { + nlwarning("Command 'shape': cannot find the shape %s.", args[0].c_str()); + } + + // Command Well Done + return true; +} + NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", "") { const char *brname[] = { "bug_report.exe", "bug_report_r.exe", "bug_report_rd.exe", "bug_report_df.exe", "bug_report_d.exe" }; @@ -908,6 +1219,10 @@ static bool talkInChan(uint32 nb,std::vectorargs) PeopleInterraction.talkInDynamicChannel(nb,ucstring(tmp)); return true; } + else + { + ChatMngr.updateChatModeAndButton(CChatGroup::dyn_chat); + } return false; } @@ -3467,156 +3782,6 @@ NLMISC_COMMAND(dist2side, "Change the distance to the side for a given sheet.", - - - -//----------------------------------------------- -// 'clearShape' : Remove all shapes added with the 'shape' command -//----------------------------------------------- -NLMISC_COMMAND(clearShape, "Remove all shapes added with the 'shape' command.", "") -{ - if (!Scene) return false; - for(uint k = 0; k < ShapeAddedByCommand.size(); ++k) - { - Scene->deleteInstance(ShapeAddedByCommand[k]); - } - ShapeAddedByCommand.clear(); - return true; -} - - -//----------------------------------------------------- -// 'setShapeX' : Set X position for last created shape -//----------------------------------------------------- -NLMISC_COMMAND(setShapeX, "Set X position for last created shape.", "") -{ - if (args.size() != 1) return false; - if (ShapeAddedByCommand.empty()) - { - nlwarning("No shape created yet"); - return false; - } - float coord; - if (!fromString(args[0], coord)) - { - nlwarning("Can't get position"); - return false; - } - CVector pos = ShapeAddedByCommand.back().getPos(); - pos.x = coord; - ShapeAddedByCommand.back().setPos(pos); - return true; -} - -//----------------------------------------------------- -// 'setShapeY' : Set Y position for last created shape -//----------------------------------------------------- -NLMISC_COMMAND(setShapeY, "Set Y position for last created shape.", "") -{ - if (args.size() != 1) return false; - if (ShapeAddedByCommand.empty()) - { - nlwarning("No shape created yet"); - return false; - } - float coord; - if (!fromString(args[0], coord)) - { - nlwarning("Can't get position"); - return false; - } - CVector pos = ShapeAddedByCommand.back().getPos(); - pos.y = coord; - ShapeAddedByCommand.back().setPos(pos); - return true; -} - -//----------------------------------------------------- -// 'setShapeZ' : Set Z position for last created shape -//----------------------------------------------------- -NLMISC_COMMAND(setShapeZ, "Set Z position for last created shape.", "") -{ - if (args.size() != 1) return false; - if (ShapeAddedByCommand.empty()) - { - nlwarning("No shape created yet"); - return false; - } - float coord; - if (!fromString(args[0], coord)) - { - nlwarning("Can't get position"); - return false; - } - CVector pos = ShapeAddedByCommand.back().getPos(); - pos.z = coord; - ShapeAddedByCommand.back().setPos(pos); - return true; -} - - -//----------------------------------------------- -// 'shape' : Add a shape in the scene. -//----------------------------------------------- -NLMISC_COMMAND(shape, "Add a shape in the scene.", "") -{ - if(args.size() < 1) - { - nlwarning("Command 'shape': need at least 1 parameter, try '/help shape' for more details."); - return false; - } - if (!Scene) - { - nlwarning("No scene available"); - return false; - } - UInstance instance = Scene->createInstance(args[0]); - if(!instance.empty()) - { - ShapeAddedByCommand.push_back(instance); - // Set the position - instance.setPos(UserEntity->pos()); - instance.setClusterSystem(UserEntity->getClusterSystem()); // for simplicity, assume it is in the same - // cluster system than the user - // Compute the direction Matrix - CMatrix dir; - dir.identity(); - CVector vi = UserEntity->dir()^CVector(0.f, 0.f, 1.f); - CVector vk = vi^UserEntity->dir(); - dir.setRot(vi, UserEntity->dir(), vk, true); - // Set Orientation : User Direction should be normalized. - instance.setRotQuat(dir.getRot()); - // if the shape is a particle system, additionnal parameters are user params - UParticleSystemInstance psi; - psi.cast (instance); - if (!psi.empty()) - { - // set each user param that is present - for(uint k = 0; k < 4; ++k) - { - if (args.size() >= (k + 2)) - { - float uparam; - if (fromString(args[k + 1], uparam)) - { - psi.setUserParam(k, uparam); - } - else - { - nlwarning("Cant read param %d", k); - } - } - } - } - } - else - nlwarning("Command 'shape': cannot find the shape %s.", args[0].c_str()); - - // Command Well Done - return true; -} - - // Change the parent of an entity. 'parent slot' not defined remove the current parent. NLMISC_COMMAND(parent, "Change the parent of an entity.", " []") { diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index 79998b7c7..f4190f69a 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -777,7 +777,7 @@ void contextExtractRM(bool rightClick, bool dblClick) return; if( ClientCfg.DblClickMode && !dblClick) return; - UserEntity->moveToExtractionPhrase(SlotUnderCursor, MaxExtractionDistance, ~0, ~0, true ); + UserEntity->moveToExtractionPhrase(SlotUnderCursor, MaxExtractionDistance, std::numeric_limits::max(), std::numeric_limits::max(), true ); } //----------------------------------------------- diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index fc2aa43de..94dd6855b 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -494,6 +494,90 @@ void CEntityManager::reinit() initialize(_NbMaxEntity); } +CShapeInstanceReference CEntityManager::createInstance(const string& shape, const CVector &pos, const string& text, const string& url, bool bbox_active) +{ + CShapeInstanceReference nullinstref(UInstance(), string(""), string("")); + if (!Scene) return nullinstref; + + UInstance instance = Scene->createInstance(shape); + if (text.empty()) + bbox_active = false; + CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, bbox_active); + if(!instance.empty()) + { + _ShapeInstances.push_back(instref); + } + return instref; +} + +bool CEntityManager::removeInstances() +{ + if (!Scene) return false; + // Remove all instances. + for(uint i=0; i<_ShapeInstances.size(); ++i) + { + if (!_ShapeInstances[i].Instance.empty()) + Scene->deleteInstance(_ShapeInstances[i].Instance); + } + _ShapeInstances.clear(); + return true; +} + +CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float y) +{ + CShapeInstanceReference selectedInstance(UInstance(), string(""), string("")); + _LastInstanceUnderPos= NULL; + + // If not initialised, return + if (_ShapeInstances.empty()) + return selectedInstance; + + // build the ray + CMatrix camMatrix = MainCam.getMatrix(); + CFrustum camFrust = MainCam.getFrustum(); + CViewport viewport = Driver->getViewport(); + + // Get the Ray made by the mouse. + CVector pos, dir; + viewport.getRayWithPoint(x, y, pos, dir, camMatrix, camFrust); + // Normalize the direction. + dir.normalize(); + + // **** Get instances with box intersecting the ray. + float bestDist = 255; + for(uint i=0; i<_ShapeInstances.size(); i++) + { + if (_ShapeInstances[i].BboxActive) + { + H_AUTO(RZ_Client_GEUP_box_intersect) + + // if intersect the bbox + NLMISC::CAABBox bbox; + //= _ShapeInstances[i].SelectionBox; + _ShapeInstances[i].Instance.getShapeAABBox(bbox); + if (bbox.getCenter() == CVector::Null) + { + bbox.setMinMax(CVector(-0.3f, -0.3f, -0.3f)+_ShapeInstances[i].Instance.getPos(), CVector(0.3f, 0.3f, 0.3f)+_ShapeInstances[i].Instance.getPos()); + } + else + { + bbox.setMinMax((bbox.getMin()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos(), (bbox.getMax()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos()); + } + if(bbox.intersect(pos, pos+dir*15.0f)) + { + float dist = (bbox.getCenter()-pos).norm(); + if (dist < bestDist) + { + selectedInstance = _ShapeInstances[i]; + bestDist = dist; + } + } + } + } + return selectedInstance; +} + + //----------------------------------------------- // Create an entity according to the slot and the form. // \param uint slot : slot for the entity. diff --git a/code/ryzom/client/src/entities.h b/code/ryzom/client/src/entities.h index 502065926..8d0d780c5 100644 --- a/code/ryzom/client/src/entities.h +++ b/code/ryzom/client/src/entities.h @@ -85,8 +85,28 @@ public: uint Slot; }; +/* + * Class to make cache shape instances + */ +class CShapeInstanceReference +{ +public: + CShapeInstanceReference (NL3D::UInstance instance, const string &text, const string &url, bool bbox_active=true) + { + Instance = instance; + ContextText = text; + ContextURL = url; + BboxActive = bbox_active; + } + + NL3D::UInstance Instance; + string ContextText; + string ContextURL; + bool BboxActive; +}; + /** - * Class to manage entities. + * Class to manage entities and shapes instances. * \author Guillaume PUZIN * \author Nevrax France * \date 2001 @@ -106,6 +126,9 @@ private: std::vector _ActiveEntities; std::vector _VisibleEntities; + /// Shapes Instances caches + std::vector _ShapeInstances; + typedef struct { NLMISC::TGameCycle GC; @@ -123,6 +146,8 @@ private: // For selection. NB: the pointer is just a cache. Must not be accessed CEntityCL *_LastEntityUnderPos; + NL3D::UInstance _LastInstanceUnderPos; + ////////////// //// DEBUG /// uint _NbUser; @@ -174,6 +199,11 @@ public: /// Release + initialize void reinit(); + + CShapeInstanceReference createInstance(const string& shape, const CVector &pos, const string &text, const string &url, bool active=true); + bool removeInstances(); + CShapeInstanceReference getShapeInstanceUnderPos(float x, float y); + /** * Create an entity according to the slot and the form. * \param uint slot : slot for the entity. diff --git a/code/ryzom/client/src/entity_cl.cpp b/code/ryzom/client/src/entity_cl.cpp index e046464b3..37324e1ff 100644 --- a/code/ryzom/client/src/entity_cl.cpp +++ b/code/ryzom/client/src/entity_cl.cpp @@ -2511,12 +2511,20 @@ NLMISC::CRGBA CEntityCL::getColor () const { if (isEnemy()) { - return _PvpEnemyColor; + if (getPvpMode()&PVP_MODE::PvpFactionFlagged || getPvpMode()&PVP_MODE::PvpChallenge) + return _PvpEnemyColor; + else + return CRGBA::CRGBA(min(255, _PvpEnemyColor.R+150), min(255, _PvpEnemyColor.G+150), min(255, _PvpEnemyColor.B+150),_PvpEnemyColor.A); } } // neutral pvp if (isNeutralPVP()) { + if (isInTeam()) + return _PvpAllyInTeamColor; + if (isInGuild()) + return _PvpAllyInGuildColor; + return _PvpNeutralColor; } // ally @@ -2526,7 +2534,11 @@ NLMISC::CRGBA CEntityCL::getColor () const return _PvpAllyInTeamColor; if(isInGuild()) return _PvpAllyInGuildColor; - return _PvpAllyColor; + + if (getPvpMode()&PVP_MODE::PvpFactionFlagged) + return _PvpAllyColor; + else + return CRGBA::CRGBA(min(255, _PvpAllyColor.R+150), min(255, _PvpAllyColor.G+150), min(255, _PvpAllyColor.B+150),_PvpAllyColor.A); } // neutral if (isInTeam()) @@ -2795,9 +2807,11 @@ void CEntityCL::updateIsInTeam () presentProp && presentProp->getValueBool() ) { _IsInTeam= true; + buildInSceneInterface(); return; } } + buildInSceneInterface(); } //----------------------------------------------- @@ -3051,13 +3065,15 @@ void CEntityCL::updateVisiblePostPos(const NLMISC::TTime &/* currentTimeInMs */, position = pos().asVector(); position.z= _SelectBox.getMin().z; mat.setPos(position); + mat.setRot(dirMatrix()); _StateFX.setTransformMode(NL3D::UTransformable::DirectMatrix); _StateFX.setMatrix(mat); if (skeleton()) _StateFX.setClusterSystem(skeleton()->getClusterSystem()); } - else if (!_SelectionFX.empty() || !_MouseOverFX.empty()) + + if (!_SelectionFX.empty() || !_MouseOverFX.empty()) { // Build a matrix for the fx NLMISC::CMatrix mat; diff --git a/code/ryzom/client/src/entity_cl.h b/code/ryzom/client/src/entity_cl.h index 725f6b883..1c79161ea 100644 --- a/code/ryzom/client/src/entity_cl.h +++ b/code/ryzom/client/src/entity_cl.h @@ -686,7 +686,7 @@ public: virtual bool isNeutralPVP() const { return false; } /// Return true if this player has the viewing properties of a friend (inscene bars...) - virtual bool isViewedAsFriend() const { return isNeutral() || isFriend(); } + virtual bool isViewedAsFriend() const { return isNeutral() || isFriend() || isInTeam() || isInGuild(); } /// Return the People for the entity (unknown by default) virtual EGSPD::CPeople::TPeople people() const; @@ -760,6 +760,12 @@ public: return _Title; } + /// Return the raw unparsed entity title + const ucstring getTitleRaw() const + { + return ucstring(_TitleRaw); + } + /// Return true if this entity has a reserved title bool hasReservedTitle() const { return _HasReservedTitle; } diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 88bf1ac5a..9b37a1a53 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -1364,6 +1364,10 @@ void loadBackgroundBitmap (TBackground background) string ext = CFile::getExtension (ClientCfg.Launch_BG); string filename; + if (frand(2.0) < 1) + filename = name+"_0."+ext; + else + filename = name+"_1."+ext; switch (background) { case ElevatorBackground: @@ -1397,13 +1401,6 @@ void loadBackgroundBitmap (TBackground background) filename = ClientCfg.Loading_BG; break; default: - /* - if (frand(2.0) < 1) - filename = name+"_0."+ext; - else - filename = name+"_1."+ext; - */ - filename = name+"."+ext; break; } diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 11703d5fa..be0e50b5e 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -2440,6 +2440,174 @@ class CAHTarget : public IActionHandler }; REGISTER_ACTION_HANDLER (CAHTarget, "target"); + + +class CAHAddShape : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &Params) + { + string sShape = getParam(Params, "shape"); + if(sShape.empty()) + { + nlwarning("Command 'add_shape': need at least the parameter shape."); + return; + } + if (!Scene) + { + nlwarning("No scene available"); + return; + } + + double x = UserEntity->pos().x; + double y = UserEntity->pos().y; + double z = UserEntity->pos().z; + CVector userDir = UserEntity->dir(); + float s = 1.0f; + string skeleton = getParam(Params, "skeleton"); + string c = getParam(Params, "text"); + string u = getParam(Params, "url"); + string texture_name = getParam(Params, "texture"); + string highlight = getParam(Params, "texture"); + string transparency = getParam(Params, "transparency"); + + if (!getParam(Params, "x").empty()) + fromString(getParam(Params, "x"), x); + if (!getParam(Params, "y").empty()) + fromString(getParam(Params, "y"), y); + if (!getParam(Params, "z").empty()) + fromString(getParam(Params, "z"), z); + if (!getParam(Params, "scale").empty()) + fromString(getParam(Params, "scale"), s); + if (!getParam(Params, "angle").empty()) + { + float a; + fromString(getParam(Params, "angle"), a); + userDir = CVector(sin(a), cos(a), 0.f); + } + + bool have_shapes = true; + bool first_shape = true; + while(have_shapes) + { + string shape; + string::size_type index = sShape.find(string(" ")); + // multiple shapes/fx + if (index != string::npos) + { + shape = sShape.substr(0, index); + sShape = sShape.substr(index+1); + } else { + shape = sShape; + have_shapes = false; + } + + + CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector((float)x, (float)y, (float)z), c, u, first_shape); + UInstance instance = instref.Instance; + + if(!instance.empty()) + { + for(uint j=0;jgetClusterSystem()); // for simplicity, assume it is in the same + // cluster system than the user + // Compute the direction Matrix + CMatrix dir; + dir.identity(); + CVector vi = userDir^CVector(0.f, 0.f, 1.f); + CVector vk = vi^userDir; + dir.setRot(vi, userDir, vk, true); + // Set Orientation : User Direction should be normalized. + if (!skeleton.empty()) + { + USkeleton skel = Scene->createSkeleton(skeleton); + if (!skel.empty()) + { + skel.bindSkin(instance); + skel.setClusterSystem(UserEntity->getClusterSystem()); + skel.setScale(skel.getScale()*s); + skel.setPos(CVector((float)x, (float)y, (float)z)); + skel.setRotQuat(dir.getRot()); + } + } else { + instance.setScale(instance.getScale()*s); + instance.setPos(CVector((float)x, (float)y, (float)z)); + instance.setRotQuat(dir.getRot()); + } + // if the shape is a particle system, additionnal parameters are user params + UParticleSystemInstance psi; + psi.cast (instance); + /*if (!psi.empty()) + { + // set each user param that is present + for(uint k = 0; k < 4; ++k) + { + if (args.size() >= (k + 2)) + { + float uparam; + if (fromString(args[k + 1], uparam)) + { + psi.setUserParam(k, uparam); + } + else + { + nlwarning("Cant read param %d", k); + } + } + } + }*/ + } + else + nlwarning("Command 'add_shape': cannot find the shape %s.", sShape.c_str()); + } + + return; + } +}; +REGISTER_ACTION_HANDLER (CAHAddShape, "add_shape"); + +class CAHRemoveShapes : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &Params) + { + EntitiesMngr.removeInstances(); + } +}; +REGISTER_ACTION_HANDLER (CAHRemoveShapes, "remove_shapes"); + // *************************************************************************** // See also CHandlerTeamTarget class CAHTargetTeammateShortcut : public IActionHandler diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 4a386fd5e..f9277aa9a 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -104,7 +104,9 @@ static void setupMissionHelp(CSheetHelpSetup &setup); #define INFO_LIST_BRICK_REQUIREMENT "list_brick_requirement" #define INFO_GROUP_MP_STAT "mp_stats" #define INFO_GROUP_CHAR_3D "char3d" - +#define INFO_ITEM_PREVIEW "item_preview" +#define INFO_ITEM_PREVIEW_SCENE_3D "scene_item_preview" +#define ITEM_PREVIEW_WIDTH 200 // *************************************************************************** std::deque CInterfaceHelp::_ActiveWindows; @@ -2178,6 +2180,14 @@ void resetSheetHelp(CSheetHelpSetup &setup) { listItem->setActive(false); } + + // Hide the item preview by default + CInterfaceElement *elt= group->getElement(group->getId()+setup.PrefixForExtra+INFO_ITEM_PREVIEW); + if(elt) + { + elt->setActive(false); + } + // Hide the list of brick by default IListSheetBase *listBrick= dynamic_cast(group->getElement(group->getId()+setup.PrefixForExtra+INFO_LIST_BRICK)); if(listBrick) @@ -2268,6 +2278,151 @@ void setupCosmetic(CSheetHelpSetup &setup, CItemSheet *pIS) } } +// *************************************************************************** +void setupItemPreview(CSheetHelpSetup &setup, CItemSheet *pIS) +{ + nlassert(pIS); + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CCDBNodeBranch *dbBranch = pIM->getDbBranch( setup.SrcSheet->getSheet() ); + + + CInterfaceElement *elt = setup.HelpWindow->getElement(setup.HelpWindow->getId()+setup.PrefixForExtra+INFO_ITEM_PREVIEW); + if (elt == NULL) + return; + + CInterfaceGroup *ig = dynamic_cast(elt); + + if ( ! ig) + { + return; + } + + static sint32 helpWidth = setup.HelpWindow->getW(); + bool scene_inactive = ! pIM->getDbProp("UI:SAVE:SHOW_3D_ITEM_PREVIEW")->getValueBool(); + if (scene_inactive || + (pIS->Family != ITEMFAMILY::ARMOR && + pIS->Family != ITEMFAMILY::MELEE_WEAPON && + pIS->Family != ITEMFAMILY::RANGE_WEAPON && + pIS->Family != ITEMFAMILY::SHIELD)) + { + setup.HelpWindow->setW(helpWidth); + ig->setActive(false); + return; + } + else + { + setup.HelpWindow->setW(helpWidth + ITEM_PREVIEW_WIDTH); + ig->setActive(true); + } + + CInterface3DScene *sceneI = dynamic_cast(ig->getGroup("scene_item_preview")); + if (!sceneI) + { + nlwarning("Can't retrieve character 3d view, or bad type"); + ig->setActive(false); + return; + } + + CInterface3DCharacter *char3DI = NULL; + if (sceneI->getCharacter3DCount() != 0) + char3DI = sceneI->getCharacter3D(0); + + if (char3DI == NULL) + { + nlwarning("Can't retrieve char 3D Interface"); + ig->setActive(false); + return; + } + + CInterface3DCamera *camera = sceneI->getCamera(0); + if (camera == NULL) + { + nlwarning("Can't retrieve camera"); + ig->setActive(false); + return; + } + + + SCharacter3DSetup c3Ds; + + CCharacterSummary cs; + SCharacter3DSetup::setupCharacterSummaryFromSERVERDB( cs ); + + float camHeight = -0.85f; + + if (pIS->Family == ITEMFAMILY::ARMOR) + { + if (pIS->ItemType == ITEM_TYPE::LIGHT_BOOTS || pIS->ItemType == ITEM_TYPE::MEDIUM_BOOTS || pIS->ItemType == ITEM_TYPE::HEAVY_BOOTS) + { + CCDBNodeLeaf *color = dbBranch->getLeaf( setup.SrcSheet->getSheet()+":USER_COLOR", false ); + cs.VisualPropB.PropertySubData.FeetModel = CVisualSlotManager::getInstance()->sheet2Index( CSheetId(setup.SrcSheet->getSheetId()), SLOTTYPE::FEET_SLOT ); + cs.VisualPropB.PropertySubData.FeetColor = color->getValue32(); + SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", cs); + camHeight = -1.15f; + } + else if (pIS->ItemType == ITEM_TYPE::LIGHT_GLOVES || pIS->ItemType == ITEM_TYPE::MEDIUM_GLOVES || pIS->ItemType == ITEM_TYPE::HEAVY_GLOVES) + { + CCDBNodeLeaf *color = dbBranch->getLeaf( setup.SrcSheet->getSheet()+":USER_COLOR", false ); + cs.VisualPropB.PropertySubData.HandsModel = CVisualSlotManager::getInstance()->sheet2Index( CSheetId(setup.SrcSheet->getSheetId()), SLOTTYPE::HANDS_SLOT ); + cs.VisualPropB.PropertySubData.HandsColor = color->getValue32(); + SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", cs); + //cs.VisualPropB.PropertySubData.HandsColor = pIS->Color; + } + else if (pIS->ItemType == ITEM_TYPE::LIGHT_SLEEVES || pIS->ItemType == ITEM_TYPE::MEDIUM_SLEEVES || pIS->ItemType == ITEM_TYPE::HEAVY_SLEEVES) + { + CCDBNodeLeaf *color = dbBranch->getLeaf( setup.SrcSheet->getSheet()+":USER_COLOR", false ); + cs.VisualPropA.PropertySubData.ArmModel = CVisualSlotManager::getInstance()->sheet2Index( CSheetId(setup.SrcSheet->getSheetId()), SLOTTYPE::ARMS_SLOT ); + SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", cs); + SCharacter3DSetup::setDB("UI:TEMP:CHAR3D:VPA:ARMCOLOR", pIS->Color); + //cs.VisualPropA.PropertySubData.ArmColor = pIS->Color; + camHeight = -0.55f; + } + else if (pIS->ItemType == ITEM_TYPE::LIGHT_PANTS || pIS->ItemType == ITEM_TYPE::MEDIUM_PANTS || pIS->ItemType == ITEM_TYPE::HEAVY_PANTS) + { + CCDBNodeLeaf *color = dbBranch->getLeaf( setup.SrcSheet->getSheet()+":USER_COLOR", false ); + cs.VisualPropA.PropertySubData.TrouserModel = CVisualSlotManager::getInstance()->sheet2Index( CSheetId(setup.SrcSheet->getSheetId()), SLOTTYPE::LEGS_SLOT ); + cs.VisualPropA.PropertySubData.TrouserColor = color->getValue32(); + SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", cs); + camHeight = -1.00f; + } + else if (pIS->ItemType == ITEM_TYPE::LIGHT_VEST || pIS->ItemType == ITEM_TYPE::MEDIUM_VEST || pIS->ItemType == ITEM_TYPE::HEAVY_VEST) + { + CCDBNodeLeaf *color = dbBranch->getLeaf( setup.SrcSheet->getSheet()+":USER_COLOR", false ); + cs.VisualPropA.PropertySubData.JacketModel = CVisualSlotManager::getInstance()->sheet2Index( CSheetId(setup.SrcSheet->getSheetId()), SLOTTYPE::CHEST_SLOT ); + cs.VisualPropA.PropertySubData.JacketColor = color->getValue32(); + SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", cs); + camHeight = -0.55f; + } + else if (pIS->ItemType == ITEM_TYPE::HEAVY_HELMET) + { + CCDBNodeLeaf *color = dbBranch->getLeaf( setup.SrcSheet->getSheet()+":USER_COLOR", false ); + cs.VisualPropA.PropertySubData.HatModel = CVisualSlotManager::getInstance()->sheet2Index( CSheetId(setup.SrcSheet->getSheetId()), SLOTTYPE::HEAD_SLOT ); + cs.VisualPropA.PropertySubData.HatColor = color->getValue32(); + SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", cs); + camHeight = -0.35f; + } + } + else if (pIS->Family == ITEMFAMILY::SHIELD) + { + cs.VisualPropA.PropertySubData.WeaponLeftHand = CVisualSlotManager::getInstance()->sheet2Index( CSheetId(setup.SrcSheet->getSheetId()), SLOTTYPE::LEFT_HAND_SLOT ); + SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", cs); + } + else if (pIS->Family == ITEMFAMILY::MELEE_WEAPON || pIS->Family == ITEMFAMILY::RANGE_WEAPON) + { + cs.VisualPropA.PropertySubData.WeaponRightHand = CVisualSlotManager::getInstance()->sheet2Index( CSheetId(setup.SrcSheet->getSheetId()), SLOTTYPE::RIGHT_HAND_SLOT ); + SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", cs); + } + else + nlwarning(" Invalid armour or weapon item type '%s'", ITEM_TYPE::toString( pIS->ItemType ).c_str() ); + + if (camera == NULL) + return; + + camera->setTgtZ(camHeight); + char3DI->setAnim(CAnimationStateSheet::Idle); +} + // *************************************************************************** void refreshItemHelp(CSheetHelpSetup &setup) { @@ -2291,6 +2446,9 @@ void refreshItemHelp(CSheetHelpSetup &setup) // ---- Cosmetic only setupCosmetic (setup, pIS); + + // ---- item preview + setupItemPreview(setup, pIS); } // if this is a R2 plot item, Add comment and description diff --git a/code/ryzom/client/src/interface_v3/chat_filter.cpp b/code/ryzom/client/src/interface_v3/chat_filter.cpp index 7d8d8841e..da0645ed6 100644 --- a/code/ryzom/client/src/interface_v3/chat_filter.cpp +++ b/code/ryzom/client/src/interface_v3/chat_filter.cpp @@ -312,8 +312,7 @@ void CChatTargetFilter::msgEntered(const ucstring &msg, CChatWindow *chatWindow) else if (!_TargetPlayer.empty()) { // the target must be a player, make a tell on him - // TODO: adapt this to unicode when this is OK on server side - ChatMngr.tell(_TargetPlayer.toString(), msg.toString()); + ChatMngr.tell(_TargetPlayer.toString(), msg); // direct output in the chat chatWindow->displayLocalPlayerTell(msg); } diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 9033c7c77..199195ea0 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -472,7 +472,13 @@ void CChatWindow::displayLocalPlayerTell(const ucstring &msg, uint numBlinks /*= CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); encodeColorTag(prop.getRGBA(), finalMsg, false); - finalMsg += CI18N::get("youTell") + ": "; + ucstring cur_time; + if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + { + cur_time = CInterfaceManager::getTimestampHuman(); + } + ucstring csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + finalMsg += cur_time + csr + CI18N::get("youTell") + ": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); encodeColorTag(prop.getRGBA(), finalMsg, true); finalMsg += msg; @@ -1241,6 +1247,13 @@ public: return; } + // Parse any tokens in the text + if ( ! CInterfaceManager::parseTokens(text)) + { + pEB->setInputString (string("")); + return; + } + // if, it s a command, execute it and don't send the command to the server if(text[0] == '/') { @@ -1256,7 +1269,7 @@ public: else { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo (ucstring(cmd+" : ")+CI18N::get ("uiCommandNotExists")); + im->displaySystemInfo (ucstring(cmd+": ")+CI18N::get ("uiCommandNotExists")); } } else diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index baad72f30..f0f9e2308 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -45,6 +45,10 @@ extern "C" #include "lua_ihm.h" #include "../time_client.h" +#include "nel/misc/i18n.h" +#include "nel/misc/md5.h" +#include "nel/3d/texture_file.h" +#include "nel/misc/big_file.h" using namespace std; using namespace NLMISC; @@ -107,15 +111,106 @@ void CGroupHTML::addImageDownload(const string &url, CViewBase *img) curl_easy_setopt(curl, CURLOPT_FILE, fp); curl_multi_add_handle(MultiCurl, curl); - Curls.push_back(CImageDownload(curl, url, fp, img)); + Curls.push_back(CDataDownload(curl, url, fp, ImgType, img)); #ifdef LOG_DL nlwarning("adding handle %x, %d curls", curl, Curls.size()); #endif RunningCurls++; } -// Call this evenly to check if an image in downloaded and then display it -void CGroupHTML::checkImageDownload() +void CGroupHTML::initImageDownload() +{ +#ifdef LOG_DL + nlwarning("Init Image Download"); +#endif +/* +// Get current flag +int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); +// Turn on leak-checking bit +tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF; +// Set flag to the new value +_CrtSetDbgFlag( tmpFlag ); +*/ + string pathName = "cache"; + if ( ! CFile::isExists( pathName ) ) + CFile::createDirectory( pathName ); +} + + +// Get an url and return the local filename with the path where the bnp should be +string CGroupHTML::localBnpName(const string &url) +{ + size_t lastIndex = url.find_last_of("/"); + string dest = "user/"+url.substr(lastIndex+1); + return dest; +} + +// Add a bnp download request in the multi_curl +void CGroupHTML::addBnpDownload(const string &url, const string &action) +{ + // Search if we are not already downloading this url. + for(uint i = 0; i < Curls.size(); i++) + { + if(Curls[i].url == url) + { +#ifdef LOG_DL + nlwarning("already downloading '%s'", url.c_str()); +#endif + return; + } + } + + CURL *curl = curl_easy_init(); + if (!MultiCurl || !curl) + return; + + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + + string dest = localBnpName(url); +#ifdef LOG_DL + nlwarning("add to download '%s' dest '%s'", url.c_str(), dest.c_str()); +#endif + // create the local file + if (NLMISC::CFile::fileExists(dest)) + { + if (action == "override" || action == "delete") + { + CFile::setRWAccess(dest); + NLMISC::CFile::deleteFile(dest.c_str()); + } + } + if (action != "delete") + { + FILE *fp = fopen (dest.c_str(), "wb"); + if (fp == NULL) + { + nlwarning("Can't open file '%s' for writing: code=%d '%s'", dest.c_str (), errno, strerror(errno)); + return; + } + curl_easy_setopt(curl, CURLOPT_FILE, fp); + + curl_multi_add_handle(MultiCurl, curl); + Curls.push_back(CDataDownload(curl, url, fp, BnpType, NULL)); +#ifdef LOG_DL + nlwarning("adding handle %x, %d curls", curl, Curls.size()); +#endif + RunningCurls++; + } +} + +void CGroupHTML::initBnpDownload() +{ +#ifdef LOG_DL + nlwarning("Init Bnp Download"); +#endif + string pathName = "user"; + if ( ! CFile::isExists( pathName ) ) + CFile::createDirectory( pathName ); +} + +// Call this evenly to check if an element is downloaded and then manage it +void CGroupHTML::checkDownloads() { //nlassert(_CrtCheckMemory()); @@ -142,7 +237,7 @@ void CGroupHTML::checkImageDownload() { if (msg->msg == CURLMSG_DONE) { - for (vector::iterator it=Curls.begin(); it::iterator it=Curls.begin(); iteasy_handle == it->curl) { @@ -156,58 +251,87 @@ void CGroupHTML::checkImageDownload() #endif curl_easy_cleanup(it->curl); - string image = localImageName(it->url); + string file; - if(CURLE_OK != res || r < 200 || r >= 300) + if (it->type == ImgType) + file = localImageName(it->url)+".tmp"; + else + file = localBnpName(it->url); + + if(res != CURLE_OK || r < 200 || r >= 300) { - NLMISC::CFile::deleteFile((image+".tmp").c_str()); + NLMISC::CFile::deleteFile(file.c_str()); } else { string finalUrl; - CFile::moveFile(image.c_str(), (image+".tmp").c_str()); - if (lookupLocalFile (finalUrl, image.c_str(), false)) + if (it->type == ImgType) { - for(uint i = 0; i < it->imgs.size(); i++) + string image = localImageName(it->url); + CFile::moveFile(image.c_str(), (image+".tmp").c_str()); + if (lookupLocalFile (finalUrl, image.c_str(), false)) { - // don't display image that are not power of 2 - uint32 w, h; - CBitmap::loadSize (image, w, h); - if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures())) - image.clear(); + for(uint i = 0; i < it->imgs.size(); i++) + { + // don't display image that are not power of 2 + uint32 w, h; + CBitmap::loadSize (image, w, h); + if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures())) + image.clear(); - CCtrlButton *btn = dynamic_cast(it->imgs[i]); - if(btn) - { -#ifdef LOG_DL - nlwarning("refresh new downloading image %d button %p", i, it->imgs[i]); -#endif - btn->setTexture (image); - btn->setTexturePushed(image); - btn->invalidateCoords(); - btn->invalidateContent(); - btn->resetInvalidCoords(); - btn->updateCoords(); - paragraphChange(); - } - else - { - CViewBitmap *btm = dynamic_cast(it->imgs[i]); - if(btm) + CCtrlButton *btn = dynamic_cast(it->imgs[i]); + if(btn) { -#ifdef LOG_DL - nlwarning("refresh new downloading image %d image %p", i, it->imgs[i]); -#endif - btm->setTexture (image); - btm->invalidateCoords(); - btm->invalidateContent(); - btm->resetInvalidCoords(); - btm->updateCoords(); + #ifdef LOG_DL + nlwarning("refresh new downloading image %d button %p", i, it->imgs[i]); + #endif + btn->setTexture (image); + btn->setTexturePushed(image); + btn->invalidateCoords(); + btn->invalidateContent(); + btn->resetInvalidCoords(); + btn->updateCoords(); paragraphChange(); } + else + { + CViewBitmap *btm = dynamic_cast(it->imgs[i]); + if(btm) + { + #ifdef LOG_DL + nlwarning("refresh new downloading image %d image %p", i, it->imgs[i]); + #endif + btm->setTexture (image); + btm->invalidateCoords(); + btm->invalidateContent(); + btm->resetInvalidCoords(); + btm->updateCoords(); + paragraphChange(); + } + } } } } + else + { + if (lookupLocalFile (finalUrl, file.c_str(), false)) + { + nlinfo("BNPCHECK : downloaded"); + + bool memoryCompressed = CPath::isMemoryCompressed(); + if (memoryCompressed) + { + CPath::memoryUncompress(); + } + CPath::addSearchPath("user/", true, false, NULL); + if (memoryCompressed) + { + CPath::memoryCompress(); + } + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->executeLuaScript("game:onBnpDownloadFinish()", true); + } + } } Curls.erase(it); @@ -220,32 +344,11 @@ void CGroupHTML::checkImageDownload() RunningCurls = NewRunningCurls; } -void CGroupHTML::initImageDownload() + +void CGroupHTML::releaseDownloads() { #ifdef LOG_DL - nlwarning("Init Image Download"); -#endif - MultiCurl = curl_multi_init(); - RunningCurls = 0; -/* -// Get current flag -int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); -// Turn on leak-checking bit -tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF; -// Set flag to the new value -_CrtSetDbgFlag( tmpFlag ); -*/ - - - string pathName = "cache"; - if ( ! CFile::isExists( pathName ) ) - CFile::createDirectory( pathName ); -} - -void CGroupHTML::releaseImageDownload() -{ -#ifdef LOG_DL - nlwarning("Release Image Download"); + nlwarning("Release Downloads"); #endif if(MultiCurl) curl_multi_cleanup(MultiCurl); @@ -1251,6 +1354,21 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c endParagraph(); _UL.push_back(true); break; + case HTML_OBJECT: + _ObjectType = ""; + _ObjectData = ""; + _ObjectMD5Sum = ""; + _ObjectAction = ""; + if (present[HTML_OBJECT_TYPE] && value[HTML_OBJECT_TYPE]) + _ObjectType = value[HTML_OBJECT_TYPE]; + if (present[HTML_OBJECT_DATA] && value[HTML_OBJECT_DATA]) + _ObjectData = value[HTML_OBJECT_DATA]; + if (present[HTML_OBJECT_ID] && value[HTML_OBJECT_ID]) + _ObjectMD5Sum = value[HTML_OBJECT_ID]; + if (present[HTML_OBJECT_STANDBY] && value[HTML_OBJECT_STANDBY]) + _ObjectAction = value[HTML_OBJECT_STANDBY]; + + break; } } } @@ -1371,6 +1489,14 @@ void CGroupHTML::endElement (uint element_number) popIfNotEmpty (_UL); } break; + case HTML_OBJECT: + if (_ObjectType=="application/ryzom-data") + { + if (!_ObjectData.empty()) + { + addBnpDownload(_ObjectData, _ObjectAction); + } + } } } } @@ -1483,7 +1609,11 @@ CGroupHTML::CGroupHTML(const TCtorParam ¶m) DefaultBackgroundBitmapView = "bg"; clearContext(); + MultiCurl = curl_multi_init(); + RunningCurls = 0; + initImageDownload(); + initBnpDownload(); } // *************************************************************************** @@ -2313,9 +2443,14 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/ ctrlButton->setActionOnLeftClick (actionHandler); ctrlButton->setParamsOnLeftClick (actionHandlerParams); - // Translate the tooltip + // Translate the tooltip or display raw text (tooltip from webig) if (tooltip) - ctrlButton->setDefaultContextHelp (CI18N::get (tooltip)); + { + if (CI18N::hasTranslation(tooltip)) + ctrlButton->setDefaultContextHelp (CI18N::get(tooltip)); + else + ctrlButton->setDefaultContextHelp (ucstring(tooltip)); + } getParagraph()->addChild (ctrlButton); paragraphChange (); @@ -2913,7 +3048,7 @@ void CGroupHTML::handle () void CGroupHTML::draw () { - checkImageDownload(); + checkDownloads(); CGroupScrollText::draw (); } diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index daf0792e9..1d8fd9229 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -293,6 +293,8 @@ protected : // the script to execute std::string _LuaScript; + bool _ParsingBnpUrl; + std::string _BnpUrl; // Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client. static CGroupHTML *_ConnectingLock; @@ -481,6 +483,12 @@ protected : bool _SelectOption; ucstring _SelectOptionStr; + // Current node is a object + std::string _ObjectType; + std::string _ObjectData; + std::string _ObjectMD5Sum; + std::string _ObjectAction; + // Get last char ucchar getLastChar() const; @@ -527,25 +535,38 @@ private: static ucstring decodeHTMLEntities(const ucstring &str); // ImageDownload system + enum TDataType {ImgType= 0, BnpType}; - struct CImageDownload + struct CDataDownload { - CImageDownload(CURL *c, const std::string &u, FILE *f, CViewBase *i) : curl(c), url(u), fp(f) { imgs.push_back(i); } + CDataDownload(CURL *c, const std::string &u, FILE *f, TDataType t, CViewBase *i) : curl(c), url(u), fp(f), type(t) { imgs.push_back(i); } CURL *curl; std::string url; + TDataType type; FILE *fp; std::vector imgs; }; - std::vector Curls; + std::vector Curls; CURLM *MultiCurl; int RunningCurls; void initImageDownload(); - void releaseImageDownload(); void checkImageDownload(); void addImageDownload(const std::string &url, CViewBase *img); std::string localImageName(const std::string &url); + + + + // BnpDownload system + void initBnpDownload(); + void checkBnpDownload(); + void addBnpDownload(const std::string &url, const std::string &action); + std::string localBnpName(const std::string &url); + + void releaseDownloads(); + void checkDownloads(); + }; // adapter group that store y offset for inputs inside an html form diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index cfce12775..a5dae02f3 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -514,6 +514,13 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (class CEntityCL *entity) if (!isForageSource) { + CViewBase * invisibleLogo = info->getView("invisible_logo"); + if (entity->isUser() && invisibleLogo) + { + bool invisible = pIM->getDbProp("SERVER:USER:IS_INVISIBLE")->getValueBool(); + invisibleLogo->setActive(invisible); + } + // Get the target bitmap CViewBase *target = leftGroup->getView ("target"); if (target) @@ -532,25 +539,91 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (class CEntityCL *entity) info->_MissionTarget = bitmap; } - // set or inactive pvp logos + CViewBase * pvpCivLogo = info->getView ("pvp_faction_civ_logo"); + CViewBase * pvpCultLogo = info->getView ("pvp_faction_cult_logo"); + CPlayerCL * pPlayer = dynamic_cast(entity); - if (pPlayer != NULL && needPvPLogo) + if (pPlayer == NULL) + needPvPLogo = false; + + // set or inactive pvp logos + bool needCivPvpLogo = needPvPLogo; + bool needCultPvpLogo = needPvPLogo; + + if (pPlayer != NULL && needPvPLogo && pvpCivLogo && pvpCultLogo) { - CViewBase * pvpFactionLogo = info->getView ("pvp_faction_logo"); - if (pvpFactionLogo) + uint8 civToDisplay = (uint8)(pPlayer->getClanCivMaxFame() & 0xFF); + uint8 cultToDisplay = (uint8)(pPlayer->getClanCultMaxFame() & 0xFF); + + if (!entity->isUser()) { - if( pPlayer->getPvpMode()&PVP_MODE::PvpFaction || pPlayer->getPvpMode()&PVP_MODE::PvpFactionFlagged) - { - CViewBitmap * pvpFactionLogoBmp = dynamic_cast(pvpFactionLogo); - if( pvpFactionLogoBmp ) - pvpFactionLogoBmp->setTexture( pIM->getDefine(PVP_CLAN::toIconDefineString(pPlayer->getPvpClan())) ); - } - else - { - pvpFactionLogo->setActive(false); - } + // Check if are Civ Allies + for (uint8 i = 0; i < 4; i++) + if ( (pPlayer->isPvpAlly(i) && UserEntity->isPvpAlly(i)) || + (pPlayer->isPvpEnnemy(i) && UserEntity->isPvpEnnemy(i)) ) + civToDisplay = i; + + // Check if are Civ Ennemies + for (uint8 i = 0; i < 4; i++) + if ( (pPlayer->isPvpAlly(i) && UserEntity->isPvpEnnemy(i)) || + (pPlayer->isPvpEnnemy(i) && UserEntity->isPvpAlly(i)) ) + civToDisplay = i; + + // Check if are Cult Allies + for (uint8 i = 4; i < 7; i++) + if ( (pPlayer->isPvpAlly(i) && UserEntity->isPvpAlly(i)) || + (pPlayer->isPvpEnnemy(i) && UserEntity->isPvpEnnemy(i)) ) + cultToDisplay = i; + + // Check if are Cult Ennemies + for (uint8 i = 4; i < 7; i++) + if ( (pPlayer->isPvpAlly(i) && UserEntity->isPvpEnnemy(i)) || + (pPlayer->isPvpEnnemy(i) && UserEntity->isPvpAlly(i)) ) + cultToDisplay = i; } + if ((pPlayer->getPvpMode() & PVP_MODE::PvpFaction) || (pPlayer->getPvpMode() & PVP_MODE::PvpFactionFlagged)) + { + CViewBitmap * pvpCivLogoBmp = dynamic_cast(pvpCivLogo); + if( pvpCivLogoBmp ) + { + if (pPlayer->isPvpAlly(civToDisplay)) + if (pPlayer->isPvpRanger()) + pvpCivLogoBmp->setTexture("pvp_ally_ranger.tga"); + else + pvpCivLogoBmp->setTexture("pvp_ally_"+toString(civToDisplay)+".tga"); + else if (pPlayer->isPvpEnnemy(civToDisplay)) + if (pPlayer->isPvpMarauder()) + pvpCivLogoBmp->setTexture("pvp_enemy_marauder.tga"); + else + pvpCivLogoBmp->setTexture("pvp_enemy_"+toString(civToDisplay)+".tga"); + else + needCivPvpLogo = false; + } + + CViewBitmap * pvpCultLogoBmp = dynamic_cast(pvpCultLogo); + if( pvpCultLogoBmp ) + { + if (pPlayer->isPvpAlly(cultToDisplay)) + if (pPlayer->isPvpPrimas()) + pvpCultLogoBmp->setTexture("pvp_ally_primas.tga"); + else + pvpCultLogoBmp->setTexture("pvp_ally_"+toString(cultToDisplay)+".tga"); + else if (pPlayer->isPvpEnnemy(cultToDisplay)) + if (pPlayer->isPvpTrytonist()) + pvpCultLogoBmp->setTexture("pvp_enemy_trytonist.tga"); + else + pvpCultLogoBmp->setTexture("pvp_enemy_"+toString(cultToDisplay)+".tga"); + else + needCultPvpLogo = false; + } + } + else + { + needCivPvpLogo = false; + needCultPvpLogo = false; + } + CViewBase * pvpOutpostLogo = info->getView ("pvp_outpost_logo"); if (pvpOutpostLogo) { @@ -563,7 +636,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (class CEntityCL *entity) CViewBase * pvpDuelLogo = info->getView ("pvp_duel_logo"); if (pvpDuelLogo) { - if( !(pPlayer->getPvpMode()&PVP_MODE::PvpDuel) ) + if( !(pPlayer->getPvpMode()&PVP_MODE::PvpDuel || pPlayer->getPvpMode()&PVP_MODE::PvpChallenge) ) { pvpDuelLogo->setActive(false); } @@ -571,11 +644,6 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (class CEntityCL *entity) } else { - // unactive pvp logos - CViewBase * pvpFactionLogo = info->getView ("pvp_faction_logo"); - if (pvpFactionLogo) - pvpFactionLogo->setActive(false); - CViewBase * pvpOutpostLogo = info->getView ("pvp_outpost_logo"); if (pvpOutpostLogo) pvpOutpostLogo->setActive(false); @@ -584,6 +652,13 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (class CEntityCL *entity) if (pvpDuelLogo) pvpDuelLogo->setActive(false); } + + if (pvpCivLogo) + pvpCivLogo->setActive(needCivPvpLogo); + + if (pvpCultLogo) + pvpCultLogo->setActive(needCultPvpLogo); + } // No bar and no string ? diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 2be4808f0..8ecf90a96 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -47,6 +47,7 @@ using namespace std; using namespace NLMISC; +extern CPeopleInterraction PeopleInterraction; NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListAscensor, std::string, "list_sheet_guild"); @@ -54,26 +55,27 @@ NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListAscensor, std::string, "list_sheet // Interface part // *************************************************************************** -#define WIN_GUILD "ui:interface:guild" -#define WIN_GUILD_CHAT "ui:interface:guild_chat" -#define WIN_GUILD_FORUM "ui:interface:guild_forum" -#define VIEW_TEXT_GUILD_QUIT "ui:interface:guild:content:tab_guild:quit_guild" -#define CTRL_SHEET_GUILD_BLASON "ui:interface:guild:content:tab_guild:blason" -#define VIEW_TEXT_GUILD_MEMBER_COUNT "ui:interface:guild:content:tab_guild:member_count" +#define WIN_GUILD "ui:interface:guild" +#define WIN_GUILD_CHAT "ui:interface:guild_chat" +#define WIN_GUILD_FORUM "ui:interface:guild_forum" +#define VIEW_TEXT_GUILD_QUIT "ui:interface:guild:content:tab_guild:quit_guild" +#define CTRL_SHEET_GUILD_BLASON "ui:interface:guild:content:tab_guild:blason" +#define VIEW_TEXT_GUILD_MEMBER_COUNT "ui:interface:guild:content:tab_guild:member_count" -#define LIST_GUILD_MEMBERS "ui:interface:guild:content:tab_guild:list_member:guild_members" -#define CTRL_QUIT_GUILD "ui:interface:guild:content:tab_guild:quit_guild" -#define TEMPLATE_GUILD_MEMBER "member_template" -#define TEMPLATE_GUILD_MEMBER_NAME "name" -#define TEMPLATE_GUILD_MEMBER_GRADE "grade" -#define TEMPLATE_GUILD_MEMBER_SCORE "score" -#define MENU_GUILD_MEMBER "ui:interface:menu_member" +#define LIST_GUILD_MEMBERS "ui:interface:guild:content:tab_guild:list_member:guild_members" +#define CTRL_QUIT_GUILD "ui:interface:guild:content:tab_guild:quit_guild" +#define TEMPLATE_GUILD_MEMBER "member_template" +#define TEMPLATE_GUILD_MEMBER_NAME "name" +#define TEMPLATE_GUILD_MEMBER_GRADE "grade" +#define TEMPLATE_GUILD_MEMBER_SCORE "score" +#define TEMPLATE_GUILD_MEMBER_ENTER_DATE "enter_date" +#define MENU_GUILD_MEMBER "ui:interface:menu_member" -#define WIN_ASCENSOR "ui:interface:ascensor_teleport_list" +#define WIN_ASCENSOR "ui:interface:ascensor_teleport_list" -#define WIN_JOIN_PROPOSAL "ui:interface:join_guild_proposal" -#define VIEW_JOIN_PROPOSAL_PHRASE "ui:interface:join_guild_proposal:content:inside:phrase" +#define WIN_JOIN_PROPOSAL "ui:interface:join_guild_proposal" +#define VIEW_JOIN_PROPOSAL_PHRASE "ui:interface:join_guild_proposal:content:inside:phrase" CGuildManager* CGuildManager::_Instance = NULL; @@ -109,16 +111,53 @@ static inline bool lt_member_grade(const SGuildMember &m1, const SGuildMember &m return m1.Grade < m2.Grade; } +static inline bool lt_member_online(const SGuildMember &m1, const SGuildMember &m2) +{ + if (m1.Online == m2.Online) + { + return lt_member_grade(m1, m2); + } + + // Compare online status + switch (m1.Online) + { + case ccs_online: + // m1 is < if m1 is online + return true; + break; + case ccs_online_abroad: + // m1 is < if m2 is offline + return (m2.Online == ccs_offline); + break; + case ccs_offline: + default: + // m2 is always < if m1 is offline + return false; + break; + } +} + + // *************************************************************************** -void CGuildManager::sortGuildMembers() +void CGuildManager::sortGuildMembers(TSortOrder order) { if (_GuildMembers.size() < 2) return; - // First sort by name - sort(_GuildMembers.begin(), _GuildMembers.end(), lt_member_name); - - // Second sort by grade - stable_sort(_GuildMembers.begin(), _GuildMembers.end(), lt_member_grade); + switch (order) + { + default: + case sort_grade: + sort(_GuildMembers.begin(), _GuildMembers.end(), lt_member_name); + stable_sort(_GuildMembers.begin(), _GuildMembers.end(), lt_member_grade); + break; + case sort_name: + sort(_GuildMembers.begin(), _GuildMembers.end(), lt_member_name); + break; + case sort_online: + sort(_GuildMembers.begin(), _GuildMembers.end(), lt_member_name); + stable_sort(_GuildMembers.begin(), _GuildMembers.end(), lt_member_online); + break; + } } bool CGuildManager::isProxy() @@ -715,8 +754,9 @@ class CAHGuildSheetOpen : public IActionHandler // *** Update Members, if necessary if(updateMembers) { + CGuildManager::TSortOrder order = (CGuildManager::TSortOrder)(pIM->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->getValue32()); // Sort the members in Guild Manager - pGM->sortGuildMembers(); + pGM->sortGuildMembers(order); // update member count view const vector &rGuildMembers = pGM->getGuildMembers(); @@ -784,6 +824,21 @@ class CAHGuildSheetOpen : public IActionHandler } } + // Enter Date + CViewText *pViewEnterDate = dynamic_cast(pLine->getView(TEMPLATE_GUILD_MEMBER_ENTER_DATE)); + if (pViewEnterDate != NULL) + { + CRyzomTime rt; + rt.updateRyzomClock(rGuildMembers[i].EnterDate); + ucstring str = toString("%04d", rt.getRyzomYear()) + " "; + str += CI18N::get("uiJenaYear") + " : "; + str += CI18N::get("uiAtysianCycle") + " "; + str += toString("%01d", rt.getRyzomCycle()+1) +", "; + str += CI18N::get("ui"+MONTH::toString( (MONTH::EMonth)rt.getRyzomMonthInCurrentCycle() )) + ", "; + str += toString("%02d", rt.getRyzomDayOfMonth()+1); + pViewEnterDate->setText(str); + } + // Add to the list pLine->setParent (pParent); pParent->addChild (pLine); @@ -852,15 +907,7 @@ class CAHGuildSheetMenuOpen : public IActionHandler return; } - // *** Check with the grade of the local player wich types of actions we can do on the player selected - // Grade less or equal cant do anything - if (pGM->getGrade() >= rGuildMembers[nLineNb].Grade) - { - // Close - pIM->disableModalWindow(); - return; - } // enable or disable menu entries if (pGM->isProxy()) @@ -871,7 +918,11 @@ class CAHGuildSheetMenuOpen : public IActionHandler else { // Depending on the grade we can do things or other - if (pGM->getGrade() == EGSPD::CGuildGrade::Leader) + + // Grade less or equal can't do anything + if (pGM->getGrade() >= rGuildMembers[nLineNb].Grade) + setRights(false, false, false, false, false, false, false); + else if (pGM->getGrade() == EGSPD::CGuildGrade::Leader) setRights(true, true, true, true, true, true, true); else if (pGM->getGrade() == EGSPD::CGuildGrade::HighOfficer) setRights(false, false, true, true, true, true, true); @@ -928,6 +979,70 @@ static void sendMsgSetGrade(EGSPD::CGuildGrade::TGuildGrade Grade) } } +// *************************************************************************** +// Sort the guild member list +class CAHGuildSheetSortGuildList : public IActionHandler +{ +public: + void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) + { + CInterfaceManager* pIM= CInterfaceManager::getInstance(); + CGuildManager::TSortOrder order = (CGuildManager::TSortOrder)(pIM->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->getValue32()); + + order = (CGuildManager::TSortOrder)(order + 1); + if (order == CGuildManager::END_SORT_ORDER) + { + order = CGuildManager::START_SORT_ORDER; + } + + pIM->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->setValue32((sint32)order); + pIM->runActionHandler("guild_sheet_open", NULL, toString("update_members=1")); + } +}; +REGISTER_ACTION_HANDLER(CAHGuildSheetSortGuildList, "sort_guild_list"); + +// *************************************************************************** +// Invoke the 'tell' command on a contact from its menu +// The tell command is displayed in the 'around me' window +class CAHGuildSheetTellMember : public IActionHandler +{ +public: + void execute (CCtrlBase * pCaller, const std::string &/* sParams */) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CGuildManager *pGM = CGuildManager::getInstance(); + const vector &rGuildMembers = pGM->getGuildMembers(); + // *** Check and retrieve the current member index (index in the member list) + CCtrlBase *ctrlLaunchingModal= pIM->getCtrlLaunchingModal(); + if (pCaller == NULL) + { + // Error -> Close + return; + } + string sId = pCaller->getId(); + sId = sId.substr(sId.rfind('m')+1,sId.size()); + sint32 nLineNb; + fromString(sId, nLineNb); + if ((nLineNb < 0) || (nLineNb >= (sint32)rGuildMembers.size())) + { + // Error -> Close + return; + } + MemberIndexSelected= nLineNb; + MemberNameSelected = rGuildMembers[nLineNb].Name; + + CPeopleInterraction::displayTellInMainChat(MemberNameSelected); + } + + // Current selection + static sint32 MemberIndexSelected; // Index of the member selected when left clicked + static ucstring MemberNameSelected; // Name of the member selected when lef clicked +}; +REGISTER_ACTION_HANDLER(CAHGuildSheetTellMember, "guild_tell_member"); + +sint32 CAHGuildSheetTellMember::MemberIndexSelected= -1; +ucstring CAHGuildSheetTellMember::MemberNameSelected; + // *************************************************************************** class CAHGuildSheetSetLeader : public IActionHandler { diff --git a/code/ryzom/client/src/interface_v3/guild_manager.h b/code/ryzom/client/src/interface_v3/guild_manager.h index db5cbc0ec..17b21c74c 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.h +++ b/code/ryzom/client/src/interface_v3/guild_manager.h @@ -98,7 +98,16 @@ public: const SGuild &getGuild() { return _Guild; } const std::vector &getGuildMembers() { return _GuildMembers; } - void sortGuildMembers(); + enum TSortOrder + { + sort_grade, + START_SORT_ORDER = sort_grade, + sort_name, + sort_online, + END_SORT_ORDER + }; + + void sortGuildMembers(TSortOrder order = sort_grade); /// Check if the guild is a proxified guild (not managed on the actual shard) bool isProxy(); diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index dd6047b1a..324edf91a 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -506,7 +506,10 @@ void CInterface3DScene::draw () for (i = 0; i < _Characters.size(); ++i) _Characters[i]->setClusterSystem ((UInstanceGroup*)-1); for (i = 0; i < _Shapes.size(); ++i) - _Shapes[i]->getShape().setClusterSystem ((UInstanceGroup*)-1); + { + if (!_Shapes[i]->getShape().empty()) + _Shapes[i]->getShape().setClusterSystem ((UInstanceGroup*)-1); + } for (i = 0; i < _FXs.size(); ++i) if (!_FXs[i]->getPS().empty()) _FXs[i]->getPS().setClusterSystem ((UInstanceGroup*)-1); @@ -1344,7 +1347,20 @@ std::string CInterface3DShape::getName() const // ---------------------------------------------------------------------------- void CInterface3DShape::setName (const std::string &ht) { - string lwrname = strlwr(ht); + if (ht.empty()) + { + CInterface3DScene *pI3DS = dynamic_cast(_Parent); + nlassert(pI3DS != NULL); + + if (!_Instance.empty()) + { + pI3DS->getScene()->deleteInstance(_Instance); + } + return; + _Name.clear(); + } + + string lwrname = toLower(ht); if (lwrname != _Name) { CInterface3DScene *pI3DS = dynamic_cast(_Parent); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 66610dbf2..65a59a6b4 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -101,6 +101,7 @@ #include "../entity_animation_manager.h" // for emotes #include "../net_manager.h" // for emotes #include "../client_chat_manager.h" // for emotes +#include "../entities.h" #include "chat_text_manager.h" #include "../npc_icon.h" @@ -1288,6 +1289,18 @@ void CInterfaceManager::updateFrameEvents() pVT = dynamic_cast(getElementFromId("ui:interface:map:content:map_content:time")); if (pVT != NULL) pVT->setText(str); + + str.clear(); + // Update the clock in the compass if enabled. + pVT = dynamic_cast(getElementFromId("ui:interface:compass:clock:time")); + if (pVT != NULL) + { + if (pVT->getActive()) + { + str = getTimestampHuman("%H:%M"); + pVT->setText(str); + } + } } } @@ -6274,3 +6287,300 @@ void CInterfaceManager::CServerToLocalAutoCopy::onLocalChange(ICDBNode *localNod } } +// ------------------------------------------------------------------------------------------------ +char* CInterfaceManager::getTimestampHuman(const char* format /* "[%H:%M:%S] " */) +{ + static char cstime[25]; + time_t date; + time (&date); + struct tm *tms = localtime(&date); + if (tms) + { + strftime(cstime, 25, format, tms); + } + else + { + strcpy(cstime, ""); + } + + return cstime; +} + + +/* + * Parse tokens in a chatmessage or emote + * + * Valid subjects: + * $me$ + * $t$ + * $tt$ + * $tm1$..$tm8$ + * + * Valid parameters: + * $.name$ + * $.title$ + * $.race$ + * $.guild$ + * $.gs(m/f/n)$ + * + * Default parameter if parameter result is empty: + * $./$ + * + * All \d's in default parameter remove a following character. + */ +bool CInterfaceManager::parseTokens(ucstring& ucstr) +{ + ucstring str = ucstr; + ucstring start_token = "$"; + ucstring end_token = "$"; + size_t start_pos = 0; + size_t end_pos = 1; + + sint endless_loop_protector = 0; + while ((start_pos < str.length() - 1) && + ((start_pos = str.find(start_token, start_pos)) != string::npos)) + { + endless_loop_protector++; + if (endless_loop_protector > 100) + { + break; + } + + // Get the whole token substring first + end_pos = str.find(end_token, start_pos + 1); + + if ((start_pos == string::npos) || + (end_pos == string::npos) || + (end_pos <= start_pos + 1)) + { + // Wrong formatting; give up on this one. + start_pos = max(start_pos, end_pos); + continue; + } + + // Get everything between the two "$" + size_t token_start_pos = start_pos + start_token.length(); + size_t token_end_pos = end_pos - end_token.length(); + if ((token_start_pos - token_end_pos) < 0) + { + // Wrong formatting; give up on this one. + start_pos = end_pos; + continue; + } + + ucstring token_whole = str.luabind_substr(start_pos, end_pos - start_pos + 1); + ucstring token_string = token_whole.luabind_substr(1, token_whole.length() - 2); + ucstring token_replacement = token_whole; + ucstring token_default = token_whole; + + ucstring token_subject; + ucstring token_param; + + // Does the token have a parameter? + // If not it is 'name' by default + vector token_vector; + vector param_vector; + splitUCString(token_string, ucstring("."), token_vector); + token_subject = token_vector[0]; + if (token_vector.size() == 1) + { + splitUCString(token_subject, ucstring("/"), param_vector); + token_subject = param_vector[0]; + token_param = ucstring("name"); + } + else + { + token_param = token_vector[1]; + if (token_param.luabind_substr(0, 3) != ucstring("gs(")) + { + splitUCString(token_vector[1], ucstring("/"), param_vector); + token_param = param_vector[0]; + } + } + + // Get any default value, if not gs + sint extra_replacement = 0; + if (token_param.luabind_substr(0, 3) != ucstring("gs(")) + { + if (param_vector.size() == 2) + { + // Set default value + token_replacement = param_vector[1]; + // Delete following chars for every '\d' in default + string::size_type token_replacement_pos; + while ((token_replacement_pos = token_replacement.find(ucstring("\\d"))) != string::npos) + { + token_replacement.replace(token_replacement_pos, 2, ucstring("")); + extra_replacement++; + } + token_default = token_replacement; + } + } + + CEntityCL *pTokenSubjectEntity = NULL; + + if (token_subject == ucstring("me")) + { + pTokenSubjectEntity = static_cast(UserEntity); + } + else if (token_subject == ucstring("t")) + { + // Target + uint targetSlot = UserEntity->targetSlot(); + pTokenSubjectEntity = EntitiesMngr.entity(targetSlot); + } + else if (token_subject == ucstring("tt")) + { + // Target's target + uint targetSlot = UserEntity->targetSlot(); + CEntityCL *target = EntitiesMngr.entity(targetSlot); + + if (target) + { + // Check the new slot. + CLFECOMMON::TCLEntityId newSlot = target->targetSlot(); + CEntityCL* pE = EntitiesMngr.entity(newSlot); + if (pE) + { + pTokenSubjectEntity = pE; + } + } + } + else if ((token_subject.length() == 3) && + (token_subject.luabind_substr(0, 2) == ucstring("tm"))) + { + // Teammate + uint indexInTeam = 0; + fromString(token_subject.luabind_substr(2, 1).toString(), indexInTeam); + + // Make 0-based + --indexInTeam; + if (indexInTeam < PeopleInterraction.TeamList.getNumPeople() ) + { + // Index is the database index (serverIndex() not used for team list) + CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp( NLMISC::toString(TEAM_DB_PATH ":%hu:NAME", indexInTeam ), false); + if (pNL && pNL->getValueBool() ) + { + // There is a character corresponding to this index + pNL = CInterfaceManager::getInstance()->getDbProp( NLMISC::toString( TEAM_DB_PATH ":%hu:UID", indexInTeam ), false ); + if (pNL) + { + CLFECOMMON::TClientDataSetIndex compressedIndex = pNL->getValue32(); + + // Search entity in vision + CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex( compressedIndex ); + if (entity) + { + pTokenSubjectEntity = entity; + } + } + } + } + } + else + { + // Unknown token subject, skip it + start_pos = end_pos; + continue; + } + + if (pTokenSubjectEntity != NULL) + { + // Parse the parameter + if (token_param == ucstring("name")) + { + ucstring name = pTokenSubjectEntity->getDisplayName(); + // special case where there is only a title, very rare case for some NPC + if (name.empty()) + { + name = pTokenSubjectEntity->getTitle(); + } + token_replacement = name.empty() ? token_replacement : name; + } + else if (token_param == ucstring("title")) + { + ucstring title = pTokenSubjectEntity->getTitle(); + token_replacement = title.empty() ? token_replacement : title; + } + else if (token_param == ucstring("race")) + { + CCharacterCL *pC = (CCharacterCL*)(pTokenSubjectEntity); + if (pC) + { + EGSPD::CPeople::TPeople race = pC->people(); + if (race >= EGSPD::CPeople::Playable && race <= EGSPD::CPeople::EndPlayable) + { + ucstring srace = NLMISC::CI18N::get("io" + EGSPD::CPeople::toString(race)); + token_replacement = srace.empty() ? token_replacement : srace; + } + } + } + else if (token_param == ucstring("guild")) + { + STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); + ucstring ucGuildName; + if (pSMC->getString(pTokenSubjectEntity->getGuildNameID(), ucGuildName)) + { + token_replacement = ucGuildName.empty() ? token_replacement : ucGuildName; + } + } + else if (token_param.luabind_substr(0, 3) == ucstring("gs(") && + token_param.luabind_substr(token_param.length() - 1 , 1) == ucstring(")")) + { + // Gender string + vector strList; + ucstring gender_string = token_param.luabind_substr(3, token_param.length() - 4); + splitUCString(gender_string, ucstring("/"), strList); + + if (strList.size() <= 1) + { + start_pos = end_pos; + continue; + } + + // Only care about gender if it's a humanoid. + GSGENDER::EGender gender = GSGENDER::neutral; + if (pTokenSubjectEntity->isUser() || pTokenSubjectEntity->isPlayer() || pTokenSubjectEntity->isNPC()) + { + CCharacterCL *pC = (CCharacterCL*)(pTokenSubjectEntity); + if (pC) + { + gender = pC->getGender(); + } + } + + // Neuter part is optional. + // Fallback to male if something is wrong. + GSGENDER::EGender g = ((uint)gender >= strList.size()) ? GSGENDER::male : gender; + token_replacement = strList[g]; + } + } + + if (token_whole == token_replacement) + { + // Nothing to replace; show message and exit + CInterfaceManager *im = CInterfaceManager::getInstance(); + ucstring message = ucstring(CI18N::get("uiUntranslatedToken")); + message.replace(message.find(ucstring("%s")), 2, token_whole); + im->displaySystemInfo(message); + return false; + } + + + // Replace all occurances of token with the replacement + size_t token_whole_pos = str.find(token_whole); + start_pos = 0; + + // Only do extra replacement if using default + extra_replacement = (token_replacement == token_default) ? extra_replacement : 0; + while (str.find(token_whole, start_pos) != string::npos) + { + str = str.replace(token_whole_pos, token_whole.length() + extra_replacement, token_replacement); + start_pos = token_whole_pos + token_replacement.length(); + token_whole_pos = str.find(token_whole, start_pos); + } + } + + ucstr = str; + return true;; +} \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 9c22c57a1..cd3ad23ba 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -712,6 +712,14 @@ public: void updateTooltipCoords(); + /** Returns a human readable timestamp with the given format. + */ + static char* getTimestampHuman(const char* format = "[%H:%M:%S] "); + + /** Parses any tokens in the ucstring like $t$ or $g()$ + */ + static bool parseTokens(ucstring& ucstr); + // ------------------------------------------------------------------------------------------------ private: diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 585b6cb58..f85992bb8 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -25,6 +25,7 @@ #include "nel/misc/algo.h" #include "nel/misc/mem_stream.h" #include "nel/misc/factory.h" +#include "nel/misc/big_file.h" #include "game_share/xml_auto_ptr.h" @@ -106,6 +107,7 @@ #include "../commands.h" #include "lua_helper.h" #include "lua_ihm.h" +#include "../r2/editor.h" #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger @@ -114,6 +116,23 @@ const uint32 UI_CACHE_SERIAL_CHECK = (uint32) 'IUG_'; using namespace NLMISC; +void badLuaParseMessageBox() +{ + NL3D::UDriver::TMessageBoxId ret = Driver->systemMessageBox( "LUA files reading failed!\n" + "Some LUA files are corrupted, moved or may have been removed.\n" + "Ryzom may need to be restarted to run properly.\n" + "Would you like to quit now?", + "LUA reading failed!", + NL3D::UDriver::yesNoType, + NL3D::UDriver::exclamationIcon); + if (ret == NL3D::UDriver::yesId) + { + extern void quitCrashReport (); + quitCrashReport (); + exit (EXIT_FAILURE); + } +} + void saveXMLTree(COFile &f, xmlNodePtr node) { // save node name @@ -494,10 +513,16 @@ static void interfaceScriptAsMemStream(const std::string &script, CMemStream &de } // ---------------------------------------------------------------------------- -bool CInterfaceParser::parseInterface (const std::vector & strings, bool reload, bool isFilename) +bool CInterfaceParser::parseInterface (const std::vector & strings, bool reload, bool isFilename, bool checkInData) { bool ok; + bool needCheck = checkInData; + +#if !FINAL_VERSION + needCheck = false; +#endif + // TestYoyo. UnHide For Parsing Profile /* NLMISC::CHTimer::startBench(); @@ -524,7 +549,19 @@ bool CInterfaceParser::parseInterface (const std::vector & strings, { //get the first file document pointer firstFileName = *it; - if (!file.open (CPath::lookup(firstFileName))) + string filename = CPath::lookup(firstFileName); + bool isInData = false; + if (filename.find ("@") != string::npos) + { + vector bigFilePaths; + CBigFile::getInstance().getBigFilePaths(bigFilePaths); + if (CBigFile::getInstance().getBigFileName(filename.substr(0, filename.find ("@"))) != "data/"+filename.substr(0, filename.find ("@"))) + isInData = false; + else + isInData = true; + } + + if ((needCheck && !isInData) || !file.open (CPath::lookup(firstFileName))) { // todo hulud interface syntax error nlwarning ("could not open file %s, skipping xml parsing",firstFileName.c_str()); @@ -929,7 +966,10 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) else if ( !strcmp((char*)root->name,"lua") ) { if(!parseLUAScript(root)) + { + badLuaParseMessageBox(); nlwarning ("could not parse 'lua'"); + } } root = root->next; @@ -4648,6 +4688,13 @@ void CInterfaceParser::uninitLUA() bool CInterfaceParser::loadLUA(const std::string &fileName, std::string &error) { // get file + + bool needCheck = true; + + #if !FINAL_VERSION + needCheck = false; + #endif + string pathName= CPath::lookup(fileName, false); if(pathName.empty()) { @@ -4655,6 +4702,20 @@ bool CInterfaceParser::loadLUA(const std::string &fileName, std::string &error) return false; } + bool isInData = false; + if (pathName.find ("@") != string::npos) + { + if (CBigFile::getInstance().getBigFileName(pathName.substr(0, pathName.find ("@"))) != "data/"+pathName.substr(0, pathName.find ("@"))) + isInData = false; + else + isInData = true; + } + + if (needCheck && !isInData) + { + return false; + } + // Parse script nlassert(_LuaState); try diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 449a8f60d..753432ddc 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -103,7 +103,7 @@ public: * \param isFilename true if xmlFileNames array contains the names of the xml file, false, if each * array is a script itself */ - bool parseInterface (const std::vector &xmlFileNames, bool reload, bool isFilename = true); + bool parseInterface (const std::vector &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false); bool parseXMLDocument (xmlNodePtr root, bool reload); diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.cpp b/code/ryzom/client/src/interface_v3/lua_ihm.cpp index 01186668e..2b9752b52 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm.cpp @@ -4287,7 +4287,14 @@ void CLuaIHM::tell(const ucstring &player, const ucstring &msg) { if (!msg.empty()) { - ChatMngr.tell(player.toUtf8(), msg); + // Parse any tokens in the message. + ucstring msg_modified = msg; + // Parse any tokens in the text + if ( ! CInterfaceManager::parseTokens(msg_modified)) + { + return; + } + ChatMngr.tell(player.toUtf8(), msg_modified); } else { diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index 17c6eadce..a8900a3ab 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -18,6 +18,7 @@ #include "stdpch.h" // client +#include "../string_manager_client.h" #include "people_interraction.h" #include "interface_expr.h" #include "interface_manager.h" @@ -756,6 +757,7 @@ void CPeopleInterraction::createGuildChat() chatDesc.Title = "uiGuildChat"; chatDesc.Listener = &GuildChatEntryHandler; chatDesc.Localize = true; + chatDesc.Savable = true; chatDesc.Id = "guild_chat"; chatDesc.AHOnCloseButton = "proc"; chatDesc.AHOnCloseButtonParams = "guild_chat_proc_close"; @@ -774,6 +776,7 @@ void CPeopleInterraction::createYuboChat() chatDesc.Title = "uiYuboChat"; chatDesc.Listener = &YuboChatEntryHandler; chatDesc.Localize = true; + chatDesc.Savable = true; chatDesc.Id = "yubo_chat"; chatDesc.AHOnCloseButton = "proc"; chatDesc.AHOnCloseButtonParams = "yubo_chat_proc_close"; @@ -781,6 +784,7 @@ void CPeopleInterraction::createYuboChat() YuboChat = getChatWndMgr().createChatWindow(chatDesc); if (!YuboChat) return; + YuboChat->setMenu(STD_CHAT_SOURCE_MENU); } @@ -795,6 +799,7 @@ void CPeopleInterraction::createDynamicChats() DynamicChatEntryHandler[i].DbIndex= i; chatDesc.Listener = &DynamicChatEntryHandler[i]; chatDesc.Localize = false; + chatDesc.Savable = true; chatDesc.ChatTemplate ="dynamic_chat_id"; chatDesc.ChatTemplateParams.push_back(make_pair(string("dyn_chat_nb"),toString(i))); chatDesc.Id = string("dynamic_chat") + toString(i); @@ -804,6 +809,8 @@ void CPeopleInterraction::createDynamicChats() chatDesc.HeaderColor = "UI:SAVE:WIN:COLORS:MEM"; DynamicChat[i] = getChatWndMgr().createChatWindow(chatDesc); + if (!DynamicChat[i]) continue; + DynamicChat[i]->setMenu(STD_CHAT_SOURCE_MENU); } } @@ -956,7 +963,23 @@ class CHandlerChatGroupFilter : public IActionHandler case CChatGroup::team: pUserBut->setHardText("uiFilterTeam"); break; case CChatGroup::guild: pUserBut->setHardText("uiFilterGuild"); break; case CChatGroup::universe: pUserBut->setHardText("uiFilterUniverse"); break; - // NB: user chat cannot have yubo_chat or dyn_chat target + case CChatGroup::dyn_chat: + uint32 index = PeopleInterraction.TheUserChat.Filter.getTargetDynamicChannelDbIndex(); + uint32 textId = pIM->getDbProp("SERVER:DYN_CHAT:CHANNEL"+toString(index)+":NAME")->getValue32(); + ucstring title; + STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); + if (title.empty()) + { + // Dyn channel not available yet, so set to around + PeopleInterraction.TheUserChat.Filter.setTargetGroup(CChatGroup::arround); + pUserBut->setHardText("uiFilterAround"); + } + else + { + pUserBut->setHardText(title.toUtf8()); + } + break; + // NB: user chat cannot have yubo_chat target } pUserBut->setActive(true); @@ -1276,6 +1299,10 @@ void CPeopleInterraction::initContactLists( const std::vector &vFriendLi for (uint i = 0; i < vIgnoreListName.size(); ++i) addContactInList(contactIdPool++, vIgnoreListName[i], ccs_offline, 1); updateAllFreeTellerHeaders(); + + CInterfaceManager* pIM= CInterfaceManager::getInstance(); + CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); + FriendList.sortEx(order); } //================================================================================================================= @@ -1758,6 +1785,20 @@ void CPeopleInterraction::talkInDynamicChannel(uint32 channelNb,ucstring sentenc } } +//================================================================================================================= +void CPeopleInterraction::displayTellInMainChat(const ucstring &playerName) +{ + //CChatWindow *chat = PeopleInterraction.MainChat.Window; + CChatWindow *chat = PeopleInterraction.ChatGroup.Window; + if (!chat) return; + chat->getContainer()->setActive (true); + // make the container blink + chat->getContainer()->enableBlink(2); + // TODO : center the view on the newly created container ? + // display a new command '/name' in the chat. The player must enter a new unique name for the party chat. + chat->setCommand("tell " + playerName + " ", false); + chat->setKeyboardFocus(); +} ///////////////////////////////////// // ACTION HANDLERS FOR PEOPLE LIST // @@ -1945,22 +1986,6 @@ public: }; REGISTER_ACTION_HANDLER( CHandlerRemoveContact, "remove_contact"); - -//================================================================================================================= -static void displayTellInMainChat(const ucstring &playerName) -{ - //CChatWindow *chat = PeopleInterraction.MainChat.Window; - CChatWindow *chat = PeopleInterraction.ChatGroup.Window; - if (!chat) return; - chat->getContainer()->setActive (true); - // make the container blink - chat->getContainer()->enableBlink(2); - // TODO : center the view on the newly created container ? - // display a new command '/name' in the chat. The player must enter a new unique name for the party chat. - chat->setCommand("tell " + playerName + " ", false); - chat->setKeyboardFocus(); -} - //================================================================================================================= // Invoke the 'tell' command on a contact from its menu // The tell command is displayed in the 'around me' window @@ -1974,7 +1999,7 @@ public: uint peopleIndex; if (PeopleInterraction.getPeopleFromCurrentMenu(list, peopleIndex)) { - displayTellInMainChat(list->getName(peopleIndex)); + CPeopleInterraction::displayTellInMainChat(list->getName(peopleIndex)); } } }; @@ -1996,7 +2021,7 @@ class CHandlerTellContact : public IActionHandler uint peopleIndex; if (PeopleInterraction.getPeopleFromContainerID(gc->getId(), list, peopleIndex)) { - displayTellInMainChat(list->getName(peopleIndex)); + CPeopleInterraction::displayTellInMainChat(list->getName(peopleIndex)); } } @@ -2150,9 +2175,20 @@ class CHandlerSortContacts : public IActionHandler public: void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { + CInterfaceManager* pIM= CInterfaceManager::getInstance(); + nlinfo("Load Order : %d", pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); + CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); + + order = (CPeopleList::TSortOrder)(order + 1); + if (order == CPeopleList::END_SORT_ORDER) { + order = CPeopleList::START_SORT_ORDER; + } + + nlinfo("Save Order : %d", order); + pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->setValue32((sint32)order); CPeopleList *pl = PeopleInterraction.getPeopleListFromCurrentMenu(); if (pl) - pl->sort(); + pl->sortEx(order); } }; REGISTER_ACTION_HANDLER( CHandlerSortContacts, "sort_contacts"); @@ -2441,6 +2477,30 @@ public: if (pMenuUniverse) pMenuUniverse->setGrayed (false); if (pMenuTeam) pMenuTeam->setGrayed (!teamActive); if (pMenuGuild) pMenuGuild->setGrayed (!guildActive); + + // Remove existing dynamic chats + while (pMenu->getNumLine() > 5) + pMenu->deleteLine(pMenu->getNumLine()-1); + + // Add dynamic chats + uint insertion_index = 0; + for (uint i = 0; i < CChatGroup::MaxDynChanPerPlayer; i++) + { + string s = toString(i); + uint32 textId = im->getDbProp("SERVER:DYN_CHAT:CHANNEL"+s+":NAME")->getValue32(); + bool active = (textId != 0); + if (active) + { + uint32 canWrite = im->getDbProp("SERVER:DYN_CHAT:CHANNEL"+s+":WRITE_RIGHT")->getValue32(); + if (canWrite != 0) + { + ucstring title; + STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); + pMenu->addLineAtIndex(5 + insertion_index, title+" @{T8}/"+s, "chat_target_selected", "dyn"+s, "dyn"+s); + insertion_index++; + } + } + } } // activate the menu @@ -2465,28 +2525,42 @@ class CHandlerChatTargetSelected : public IActionHandler CChatTargetFilter &cf = fc->Filter; // Team if (nlstricmp(sParams, "team") == 0) + { cf.setTargetGroup(CChatGroup::team); - + } // Guild - if (nlstricmp(sParams, "guild") == 0) + else if (nlstricmp(sParams, "guild") == 0) + { cf.setTargetGroup(CChatGroup::guild); - + } // Say - if (nlstricmp(sParams, "say") == 0) + else if (nlstricmp(sParams, "say") == 0) + { cf.setTargetGroup(CChatGroup::say); - + } // Shout - if (nlstricmp(sParams, "shout") == 0) + else if (nlstricmp(sParams, "shout") == 0) + { cf.setTargetGroup(CChatGroup::shout); - + } // Region - if (nlstricmp(sParams, "region") == 0) + else if (nlstricmp(sParams, "region") == 0) + { cf.setTargetGroup(CChatGroup::region); - + } // Universe - if (nlstricmp(sParams, "universe") == 0) + else if (nlstricmp(sParams, "universe") == 0) + { cf.setTargetGroup(CChatGroup::universe); - + } + else + { + for (uint i = 0; i < CChatGroup::MaxDynChanPerPlayer; i++) { + if (nlstricmp(sParams, "dyn"+toString("%d", i)) == 0) { + cf.setTargetGroup(CChatGroup::dyn_chat, i); + } + } + } // Case of user chat in grouped chat window if (cw == PeopleInterraction.ChatGroup.Window) @@ -2593,6 +2667,25 @@ class CHandlerSelectChatSource : public IActionHandler // select main chat menu menu = dynamic_cast(im->getElementFromId(MAIN_CHAT_SOURCE_MENU)); + // Remove all unused dynamic channels and set the names + for (uint i = 0; i < CChatGroup::MaxDynChanPerPlayer; i++) + { + string s = toString(i); + CViewTextMenu *pVTM = dynamic_cast(im->getElementFromId(MAIN_CHAT_SOURCE_MENU+":tab:dyn"+s)); + if (pVTM) + { + uint32 textId = im->getDbProp("SERVER:DYN_CHAT:CHANNEL"+s+":NAME")->getValue32(); + bool active = (textId != 0); + pVTM->setActive(active); + if (active) + { + ucstring title; + STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); + pVTM->setText("["+s+"] " + title); + } + } + } + // Menu with Filters CChatGroupWindow *pWin = pi.getChatGroupWindow(); if (pWin->getTabIndex() == 5) // (5 == user) -> complete menu diff --git a/code/ryzom/client/src/interface_v3/people_interraction.h b/code/ryzom/client/src/interface_v3/people_interraction.h index 43391c718..183bb0f36 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.h +++ b/code/ryzom/client/src/interface_v3/people_interraction.h @@ -256,6 +256,8 @@ public: void updateAllFreeTellerHeaders(); void removeAllFreeTellers(); + + static void displayTellInMainChat(const ucstring &playerName); private: // create various chat & people lists void createTeamChat(); diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index d42c24a47..073c42daa 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -185,6 +185,85 @@ sint CPeopleList::getIndexFromContainerID(const std::string &id) const return -1; } +//================================================================== +bool CPeopleList::sortExByContactId(const CPeople& a, const CPeople& b) +{ + return (a.ContactId < b.ContactId); +} + +//================================================================== +bool CPeopleList::sortExByName(const CPeople& a, const CPeople& b) +{ + ucstring name_a = toUpper(a.getName()); + ucstring name_b = toUpper(b.getName()); + + return (name_a < name_b); +} + +//================================================================== +bool CPeopleList::sortExByOnline(const CPeople& a, const CPeople& b) +{ + ucstring name_a = toUpper(a.getName()); + ucstring name_b = toUpper(b.getName()); + + // We want order: online/alpha, offworld/alpha, offline/alpha + if (a.Online == b.Online) { + return (name_a < name_b); + } + else { + // Compare online status + switch (a.Online) { + case ccs_online: + // a is > if a is online + return true; + break; + case ccs_online_abroad: + // a is > if b is offline + return (b.Online == ccs_offline); + break; + case ccs_offline: + default: + // b is always > if a is offline + return false; + break; + } + } + + // Should not get here so just return something + return true; +} + +//================================================================== +void CPeopleList::sortEx(TSortOrder order) +{ + // remove all people from the father container + if (!_BaseContainer) return; + uint k; + for(k = 0; k < _Peoples.size(); ++k) + { + _BaseContainer->detachContainer(_Peoples[k].Container); + } + + switch (order) { + default: + case sort_index: + std::sort(_Peoples.begin(), _Peoples.end(), CPeopleList::sortExByContactId); + break; + case sort_name: + std::sort(_Peoples.begin(), _Peoples.end(), CPeopleList::sortExByName); + break; + + case sort_online: + std::sort(_Peoples.begin(), _Peoples.end(), CPeopleList::sortExByOnline); + break; + } + + for(k = 0; k < _Peoples.size(); ++k) + { + _BaseContainer->attachContainer(_Peoples[k].Container); + } +} + //================================================================== void CPeopleList::sort() { @@ -384,7 +463,14 @@ void CPeopleList::displayLocalPlayerTell(uint index,const ucstring &msg,uint num nlwarning(" can't get group list."); return; } - ucstring finalMsg = /*UserEntity->getName() + " " +*/ CI18N::get("youTell") + ": " + msg; + + ucstring cur_time; + if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + { + cur_time = CInterfaceManager::getTimestampHuman(); + } + ucstring csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + ucstring finalMsg = cur_time + csr + CI18N::get("youTell") + ": " + msg; // display msg with good color CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); @@ -788,12 +874,19 @@ class CHandlerContactEntry : public IActionHandler if(text.size() == 0) return; + // Parse any tokens in the text + if ( ! CInterfaceManager::parseTokens(text)) + { + pEB->setInputString (string("")); + return; + } + // is it a command ? if(text[0] == '/') { CChatWindow::_ChatWindowLaunchingCommand = NULL; // no CChatWindow instance there .. // TODO : have NLMISC::ICommand accept unicode strings - std::string str = text.toString().substr(1); + std::string str = text.toUtf8().substr(1); NLMISC::ICommand::execute( str, g_log ); pEB->setInputString (string("")); return; @@ -804,6 +897,7 @@ class CHandlerContactEntry : public IActionHandler CGroupContainer *gc = pCaller->getParent()->getEnclosingContainer(); // title gives the name of the player ucstring playerName = gc->getUCTitle(); + // Simply do a tell on the player ChatMngr.tell(playerName.toString(), text); pEB->setInputString (string("")); @@ -816,8 +910,9 @@ class CHandlerContactEntry : public IActionHandler } // Retrieve name of the container in the list - string str = gc->getId().substr(0,gc->getId().rfind('_')); - if (str != "ui:interface:free_chat") + string ui_interface_free_chat = "ui:interface:free_chat"; + string str = gc->getId().substr(0, ui_interface_free_chat.length()); + if (str != ui_interface_free_chat) { string str2 = gc->getId().substr(gc->getId().rfind('_')+1,gc->getId().size()); str = str.substr(0,str.rfind('_')); @@ -839,7 +934,13 @@ class CHandlerContactEntry : public IActionHandler prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); ucstring final; CChatWindow::encodeColorTag(prop.getRGBA(), final, false); - final += CI18N::get("youTell")+": "; + ucstring cur_time; + if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + { + cur_time = CInterfaceManager::getTimestampHuman(); + } + ucstring csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + final += cur_time + csr + CI18N::get("youTell")+": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); CChatWindow::encodeColorTag(prop.getRGBA(), final, true); final += text; diff --git a/code/ryzom/client/src/interface_v3/people_list.h b/code/ryzom/client/src/interface_v3/people_list.h index caa7167cd..0ab0f3508 100644 --- a/code/ryzom/client/src/interface_v3/people_list.h +++ b/code/ryzom/client/src/interface_v3/people_list.h @@ -81,6 +81,18 @@ public: ucstring getName(uint index) const; // Sort people alphabetically void sort(); + + enum TSortOrder + { + sort_index = 0, + START_SORT_ORDER = sort_index, + sort_name, + sort_online, + END_SORT_ORDER + }; + + void sortEx(TSortOrder order); + /** Add a people to the list, and returns its index or -1 if the creation failed * If this is a team mate, tells its index so that ic can be bound to the database in the right location */ @@ -165,6 +177,10 @@ private: void updatePeopleMenu(uint index); // from CGroupContainer::IChildrenObs virtual void childrenMoved(uint srcIndex, uint destIndex, CGroupContainer *children); + + static bool sortExByContactId(const CPeople& a, const CPeople& b); + static bool sortExByName(const CPeople& a, const CPeople& b); + static bool sortExByOnline(const CPeople& a, const CPeople& b); }; #endif diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.cpp b/code/ryzom/client/src/interface_v3/view_bitmap.cpp index f750ccaba..dba18c194 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap.cpp @@ -224,7 +224,7 @@ void CViewBitmap::setTexture(const std::string & TxName) // CInterfaceManager *pIM = CInterfaceManager::getInstance(); // CViewRenderer &rVR = pIM->getViewRenderer(); - _TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight); + _TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false); } // ---------------------------------------------------------------------------- diff --git a/code/ryzom/client/src/light_cycle_manager.cpp b/code/ryzom/client/src/light_cycle_manager.cpp index ef12dc096..cb34c0dd0 100644 --- a/code/ryzom/client/src/light_cycle_manager.cpp +++ b/code/ryzom/client/src/light_cycle_manager.cpp @@ -344,16 +344,22 @@ void CLightCycleManager::setHour(float hour, const CWeatherManagerClient &wm, NL } _Touched = false; - // Set the Sun color - CRGBA color; - color.add(_LastDiffuse, lightningColor); - Scene->setLightGroupColor (LightGroupDay, color); - // Set the Night color - float nightLevel = _LightLevel*255.f; - clamp (nightLevel, 0, 255); - color.set ((uint8)nightLevel, (uint8)nightLevel, (uint8)nightLevel); - Scene->setLightGroupColor (LightGroupNight, color); + // Set the Sun color only if not indoor + if (ContinentMngr.cur()->Indoor) + { + Scene->setSunAmbient(CRGBA(150, 150, 150, 255)); + } + else + { + CRGBA color; + color.add(_LastDiffuse, lightningColor); + Scene->setLightGroupColor (LightGroupDay, color); + float nightLevel = _LightLevel*255.f; + clamp (nightLevel, 0, 255); + color.set ((uint8)nightLevel, (uint8)nightLevel, (uint8)nightLevel); + Scene->setLightGroupColor (LightGroupNight, color); + } if (Landscape) { diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index a13b9feab..dc9d3d756 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -606,7 +606,7 @@ static CInterfaceChatDisplayer InterfaceChatDisplayer; void CInterfaceChatDisplayer::colorizeSender(ucstring &text, const ucstring &senderName, CRGBA baseColor) { // find the sender/text separator to put color tags - ucstring::size_type pos = text.find(ucchar(':')); + ucstring::size_type pos = senderName.length() - 1; if (pos != ucstring::npos) { ucstring str; @@ -635,14 +635,17 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c bool bubbleWanted = true; + // Subtract rawMessage from ucstr so that the 'sender' part remains. + ucstring senderPart = ucstr.luabind_substr(0, ucstr.length() - rawMessage.length()); + // search a "{no_bubble}" tag { - ucstring::size_type index = finalString.find (ucstring("{no_bubble}")); - const size_t tokenSize= 11; // strlen de "{no_bubble}" + ucstring::size_type index = finalString.find(ucstring("{no_bubble}")); + const size_t tokenSize= 11; // length of "{no_bubble}" if (index != ucstring::npos) { bubbleWanted = false; - finalString = finalString.substr (0, index) + finalString.substr(index+tokenSize,finalString.size()); + finalString = finalString.luabind_substr(0, index) + finalString.substr(index+tokenSize,finalString.size()); } } @@ -654,9 +657,9 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // Remove all {break} for(;;) { - ucstring::size_type index = finalString.find (ucstring("{break}")); + ucstring::size_type index = finalString.find(ucstring("{break}")); if (index == ucstring::npos) break; - finalString = finalString.substr (0, index) + finalString.substr(index+7,finalString.size()); + finalString = finalString.luabind_substr(0, index) + finalString.luabind_substr(index+7,finalString.size()); } // select DB @@ -696,7 +699,15 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (mode != CChatGroup::system) { // find the sender/text separator to put color tags - colorizeSender(finalString, senderName, col); + if (senderPart.empty() && stringCategory == "emt") + { + size_t pos = finalString.find(ucstring(": "), 0); + if (pos != ucstring::npos) + { + senderPart = finalString.luabind_substr(0, pos + 2); + } + } + colorizeSender(finalString, senderPart, col); } // play associated fx if any @@ -839,10 +850,15 @@ void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const u prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); bool windowVisible; - - colorizeSender(finalString, senderName, prop.getRGBA()); - ucstring goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName); + + // The sender part is up to and including the first ":" after the goodSenderName + ucstring::size_type pos = finalString.find(goodSenderName); + pos = finalString.find(':', pos); + pos = finalString.find(' ', pos); + ucstring senderPart = finalString.substr(0, pos+1); + colorizeSender(finalString, senderPart, prop.getRGBA()); + PeopleInterraction.ChatInput.Tell.displayTellMessage(/*senderIndex, */finalString, goodSenderName, prop.getRGBA(), 2, &windowVisible); // Open the free teller window @@ -1764,6 +1780,14 @@ void impulseTeamContactStatus(NLMISC::CBitMemStream &impulse) // 0<=FriendList (actually ignore list does not show online state) PeopleInterraction.updateContactInList(contactId, online, 0); + // Resort the contact list if needed + CInterfaceManager* pIM= CInterfaceManager::getInstance(); + CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); + + if (order == CPeopleList::sort_online) + { + PeopleInterraction.FriendList.sortEx(order); + } }// impulseTeamContactStatus // @@ -3069,7 +3093,7 @@ void impulseItemCloseRoomInventory(NLMISC::CBitMemStream &impulse) void impulseUserBars(NLMISC::CBitMemStream &impulse) { uint8 msgNumber; - sint16 hp, sap, sta, focus; + sint32 hp, sap, sta, focus; impulse.serial(msgNumber); impulse.serial(hp); impulse.serial(sap); @@ -3164,7 +3188,6 @@ private: if(contentStr.size()>=6 && contentStr[0]=='W' && contentStr[1]=='E' && contentStr[2]=='B' && contentStr[3]==' ' && contentStr[4]==':' && contentStr[5]==' ' ) { - ucstring web_app; uint i; const uint digitStart= 6; const uint digitMaxEnd= (uint)contentStr.size(); @@ -3176,18 +3199,17 @@ private: if(contentStr[i] == ' ') break; } - nlinfo("%d", i); if(i != digitMaxEnd) - web_app = contentStr.substr(digitStart, i-digitStart); + { + ucstring web_app = contentStr.substr(digitStart, i-digitStart); + contentStr = ucstring("http://atys.ryzom.com/start/")+web_app+ucstring(".php?")+contentStr.substr(i+1); + } else { - web_app = ucstring("index"); + contentStr = ""; i = digitStart; - nlinfo("no app"); } - contentStr = ucstring("http://atys.ryzom.com/start/")+web_app+ucstring(".php?")+contentStr.substr(i+1); - nlinfo("contentStr = %s", contentStr.toString().c_str()); - } + } else if(contentStr.size()>=5 && contentStr[0]=='@' && contentStr[1]=='{' && contentStr[2]=='W') { uint i; @@ -3218,12 +3240,19 @@ private: { CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:webig")); - pGC->setActive(true); - string url = contentStr.toString(); - addWebIGParams(url); - groupHtml->browse(url.c_str()); - pIM->setTopWindow(pGC); + if (contentStr.empty()) + { + pGC->setActive(false); + } + else + { + pGC->setActive(true); + string url = contentStr.toString(); + addWebIGParams(url); + groupHtml->browse(url.c_str()); + pIM->setTopWindow(pGC); + } } } else diff --git a/code/ryzom/client/src/player_cl.cpp b/code/ryzom/client/src/player_cl.cpp index c85708ab6..e757aaf6d 100644 --- a/code/ryzom/client/src/player_cl.cpp +++ b/code/ryzom/client/src/player_cl.cpp @@ -227,15 +227,21 @@ bool CPlayerCL::isEnemy () const } // Faction - if( getPvpMode()&PVP_MODE::PvpFactionFlagged && - (UserEntity->getPvpMode()&PVP_MODE::PvpFaction || UserEntity->getPvpMode()&PVP_MODE::PvpFactionFlagged) ) + if ((getPvpMode()&PVP_MODE::PvpFaction || getPvpMode()&PVP_MODE::PvpFactionFlagged) && + (UserEntity->getPvpMode()&PVP_MODE::PvpFaction || UserEntity->getPvpMode()&PVP_MODE::PvpFactionFlagged)) { - if( CFactionWarManager::getInstance()->areFactionsInWar(getPvpClan(),UserEntity->getPvpClan()) ) + // Check if is not ally + if (!isInTeam() && !isInGuild()) { - return true; + // Check for each Clan if is in opposition + for (uint8 i = 0; i < PVP_CLAN::NbClans; i++) + { + if ((isPvpEnnemy(i) && UserEntity->isPvpAlly(i)) || (isPvpAlly(i) && UserEntity->isPvpEnnemy(i))) + return true; + } } + } - return false; } // isEnemy // @@ -293,15 +299,24 @@ bool CPlayerCL::isAlly() const } // Faction - if( getPvpMode()&PVP_MODE::PvpFactionFlagged && + if ((getPvpMode()&PVP_MODE::PvpFaction || getPvpMode()&PVP_MODE::PvpFactionFlagged) && (UserEntity->getPvpMode()&PVP_MODE::PvpFaction || UserEntity->getPvpMode()&PVP_MODE::PvpFactionFlagged)) { - if( getPvpClan()!=PVP_CLAN::Neutral && UserEntity->getPvpClan()!=PVP_CLAN::Neutral ) + if (isInTeam() && isInGuild()) + return true; + + // Check for each Clan if is in opposition + for (uint8 i = 0; i < PVP_CLAN::NbClans; i++) { - if( getPvpClan()==UserEntity->getPvpClan() ) - { + if ((isPvpEnnemy(i) && UserEntity->isPvpAlly(i)) || (isPvpAlly(i) && UserEntity->isPvpEnnemy(i))) + return false; + } + + // Check for each Clan if is in same clan + for (uint8 i = 0; i < PVP_CLAN::NbClans; i++) + { + if ((isPvpEnnemy(i) && UserEntity->isPvpEnnemy(i)) || (isPvpAlly(i) && UserEntity->isPvpAlly(i))) return true; - } } } @@ -365,19 +380,19 @@ bool CPlayerCL::isNeutralPVP() const return true; } - // Faction - if( getPvpMode()&PVP_MODE::PvpFactionFlagged ) + if ((getPvpMode()&PVP_MODE::PvpFaction || getPvpMode()&PVP_MODE::PvpFactionFlagged) && + (UserEntity->getPvpMode()&PVP_MODE::PvpFaction || UserEntity->getPvpMode()&PVP_MODE::PvpFactionFlagged)) { - // if only target is in faction pvp - if( !(UserEntity->getPvpMode()&PVP_MODE::PvpFaction || UserEntity->getPvpMode()&PVP_MODE::PvpFactionFlagged) ) + // Check for each Clan if is in opposition or same + for (uint8 i = 0; i < PVP_CLAN::NbClans; i++) { - return true; - } - // else if factions not in war - if( CFactionWarManager::getInstance()->areFactionsInWar(getPvpClan(),UserEntity->getPvpClan())==false ) - { - return true; + if ((isPvpEnnemy(i) && UserEntity->isPvpAlly(i)) || + (isPvpAlly(i) && UserEntity->isPvpEnnemy(i)) || + (isPvpEnnemy(i) && UserEntity->isPvpEnnemy(i)) || + (isPvpAlly(i) && UserEntity->isPvpAlly(i))) + return false; } + return true; } return false; diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index cd9925e05..aebd2bcc9 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -198,6 +198,16 @@ CUserEntity::~CUserEntity() _MountSpeeds.release(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); + + { + CCDBNodeLeaf *node = pIM->getDbProp("SERVER:USER:IS_INVISIBLE", false); + if (node) + { + ICDBNode::CTextId textId; + node->removeObserver(&_InvisibleObs, textId); + } + } + for(uint i=0;igetDbProp(toString("SERVER:USER:SKILL_POINTS_%d:VALUE", i), false); @@ -347,8 +357,17 @@ bool CUserEntity::build(const CEntitySheet *sheet) // virtual // Rebuild interface buildInSceneInterface (); - // Add an observer on skill points + // Add observer on invisible property CInterfaceManager *pIM = CInterfaceManager::getInstance(); + { + CCDBNodeLeaf *node = pIM->getDbProp("SERVER:USER:IS_INVISIBLE", false); + if (node) { + ICDBNode::CTextId textId; + node->addObserver(&_InvisibleObs, textId); + } + } + + // Add an observer on skill points for(uint i=0;ibuildInSceneInterface(); +} + //--------------------------------------------------- void CUserEntity::CSkillPointsObserver::update(ICDBNode* node ) { diff --git a/code/ryzom/client/src/user_entity.h b/code/ryzom/client/src/user_entity.h index 785a5d0f3..d3f814fc8 100644 --- a/code/ryzom/client/src/user_entity.h +++ b/code/ryzom/client/src/user_entity.h @@ -589,7 +589,12 @@ protected: }; CSkillPointsObserver _SkillPointObs[EGSPD::CSPType::EndSPType]; - + class CInvisibleObserver : public ICDBNode::IPropertyObserver + { + public : + virtual void update(ICDBNode* node); + }; + CInvisibleObserver _InvisibleObs; /// Fame observer class CFameObserver : public ICDBNode::IPropertyObserver From d2fb854a0edb54e794a2a4809256d8df7f1d08dd Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 20:27:04 +0200 Subject: [PATCH 45/60] Changed: #1129 Compilation under Linux --- code/nel/src/misc/i18n.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index e76dc73eb..f7e7721e6 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -48,10 +48,10 @@ void CI18N::initLanguages() _LanguageCodes.push_back("de"); _LanguageCodes.push_back("ru"); - _LanguageNames.push_back("English"); - _LanguageNames.push_back("French"); - _LanguageNames.push_back("German"); - _LanguageNames.push_back("Russian"); + _LanguageNames.push_back(ucstring("English")); + _LanguageNames.push_back(ucstring("French")); + _LanguageNames.push_back(ucstring("German")); + _LanguageNames.push_back(ucstring("Russian")); _LanguagesNamesLoaded = true; } From 34d34340f92b6a9f4f3d02f0db2ca0e1f5da3847 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 20:31:19 +0200 Subject: [PATCH 46/60] Changed: #1135 Merge changes from Ryzom patch 1.10 --- code/ryzom/client/src/entity_cl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/entity_cl.cpp b/code/ryzom/client/src/entity_cl.cpp index 37324e1ff..42ee1c7de 100644 --- a/code/ryzom/client/src/entity_cl.cpp +++ b/code/ryzom/client/src/entity_cl.cpp @@ -2514,7 +2514,7 @@ NLMISC::CRGBA CEntityCL::getColor () const if (getPvpMode()&PVP_MODE::PvpFactionFlagged || getPvpMode()&PVP_MODE::PvpChallenge) return _PvpEnemyColor; else - return CRGBA::CRGBA(min(255, _PvpEnemyColor.R+150), min(255, _PvpEnemyColor.G+150), min(255, _PvpEnemyColor.B+150),_PvpEnemyColor.A); + return CRGBA(min(255, _PvpEnemyColor.R+150), min(255, _PvpEnemyColor.G+150), min(255, _PvpEnemyColor.B+150),_PvpEnemyColor.A); } } // neutral pvp @@ -2538,7 +2538,7 @@ NLMISC::CRGBA CEntityCL::getColor () const if (getPvpMode()&PVP_MODE::PvpFactionFlagged) return _PvpAllyColor; else - return CRGBA::CRGBA(min(255, _PvpAllyColor.R+150), min(255, _PvpAllyColor.G+150), min(255, _PvpAllyColor.B+150),_PvpAllyColor.A); + return CRGBA(min(255, _PvpAllyColor.R+150), min(255, _PvpAllyColor.G+150), min(255, _PvpAllyColor.B+150),_PvpAllyColor.A); } // neutral if (isInTeam()) From 1355d22e43a03a15ed50e3f066a894cd950e8d4f Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 20:50:38 +0200 Subject: [PATCH 47/60] Changed: #1135 Merge changes from Ryzom patch 1.10 (thanks Naush) --- code/ryzom/client/src/interface_v3/chat_window.cpp | 3 ++- code/ryzom/client/src/interface_v3/interface_manager.cpp | 4 ++-- code/ryzom/client/src/interface_v3/people_list.cpp | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 199195ea0..e247c3d53 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -477,7 +477,8 @@ void CChatWindow::displayLocalPlayerTell(const ucstring &msg, uint numBlinks /*= { cur_time = CInterfaceManager::getTimestampHuman(); } - ucstring csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + ucstring csr; + if (CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw())) csr += ucstring("(CSR) "); finalMsg += cur_time + csr + CI18N::get("youTell") + ": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); encodeColorTag(prop.getRGBA(), finalMsg, true); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 65a59a6b4..c332539dd 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -6331,8 +6331,8 @@ char* CInterfaceManager::getTimestampHuman(const char* format /* "[%H:%M:%S] " * bool CInterfaceManager::parseTokens(ucstring& ucstr) { ucstring str = ucstr; - ucstring start_token = "$"; - ucstring end_token = "$"; + ucstring start_token("$"); + ucstring end_token("$"); size_t start_pos = 0; size_t end_pos = 1; diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index 073c42daa..83642687f 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -469,7 +469,8 @@ void CPeopleList::displayLocalPlayerTell(uint index,const ucstring &msg,uint num { cur_time = CInterfaceManager::getTimestampHuman(); } - ucstring csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + ucstring csr; + if (CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw())) csr += ucstring("(CSR) "); ucstring finalMsg = cur_time + csr + CI18N::get("youTell") + ": " + msg; // display msg with good color CInterfaceProperty prop; @@ -939,7 +940,8 @@ class CHandlerContactEntry : public IActionHandler { cur_time = CInterfaceManager::getTimestampHuman(); } - ucstring csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + ucstring csr; + if (CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw())) csr += ucstring("(CSR) "); final += cur_time + csr + CI18N::get("youTell")+": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); CChatWindow::encodeColorTag(prop.getRGBA(), final, true); From c09789b340b9234c9c65c2319ef4f2f8781350a4 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 20:50:46 +0200 Subject: [PATCH 48/60] Changed: #1135 Merge changes from Ryzom patch 1.10 --- code/ryzom/client/src/cursor_functions.cpp | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index f4190f69a..634019d25 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -27,9 +27,12 @@ #include "entities.h" #include "net_manager.h" #include "interface_v3/interface_manager.h" +#include "interface_v3/interface_3d_scene.h" +#include "interface_v3/group_container.h" #include "sheet_manager.h" #include "interface_v3/inventory_manager.h" #include "interface_v3/guild_manager.h" +#include "nel/3d/u_instance.h" #include "main_loop.h" // GAME SHARE #include "game_share/bot_chat_types.h" @@ -41,6 +44,7 @@ // USING // /////////// using namespace NLMISC; +using namespace NL3D; //////////// @@ -51,6 +55,9 @@ CContextualCursor ContextCur; CLFECOMMON::TCLEntityId SlotUnderCursor; uint32 MissionId = 0; uint32 MissionRingId = 0; +UInstance selectedInstance; +const UInstance noSelectedInstance; +string selectedInstanceURL; /////////////// @@ -76,6 +83,7 @@ void contextTalk (bool rightClick, bool dblClick); void contextExtractRM (bool rightClick, bool dblClick); void contextMission (bool rightClick, bool dblClick); void contextWebPage (bool rightClick, bool dblClick); +void contextWebIG (bool rightClick, bool dblClick); void contextRingMission (bool rightClick, bool dblClick); void contextOutpost (bool rightClick, bool dblClick); void contextBuildTotem (bool rightClick, bool dblClick); @@ -113,6 +121,7 @@ void initContextualCursor() ContextCur.add(true, "EXTRACT_RM", string("uimGcmExtractRM"), 0.0f, checkUnderCursor, contextExtractRM); ContextCur.add(true, "MISSION", string(""), 0.0f, checkUnderCursor, contextMission); ContextCur.add(true, "WEB PAGE", string(""), 0.0f, checkUnderCursor, contextWebPage); + ContextCur.add(true, "WEBIG", string(""), 0.0f, checkUnderCursor, contextWebIG); ContextCur.add(true, "OUTPOST", string(""), 0.0f, checkUnderCursor, contextOutpost); ContextCur.add(true, "RING MISSION", string(""), 0.0f, checkUnderCursor, contextRingMission); ContextCur.add(true, "BUILD_TOTEM", string("uimGcmChooseBuilding"), 0.0f, checkUnderCursor, contextBuildTotem); @@ -511,7 +520,51 @@ void checkUnderCursor() } } else + { + CShapeInstanceReference instref = EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY); + UInstance instance = instref.Instance; + if (!instance.empty()) + { + if (instance.getObjectPtr() != selectedInstance.getObjectPtr()) + { + for(uint j=0;jmoveTo(SlotUnderCursor, 3.0, CUserEntity::WebPage); }// contextWebPage // +//----------------------------------------------- +// contextWebIG : +//----------------------------------------------- +void contextWebIG(bool rightClick, bool dblClick) +{ + CInterfaceManager *IM = CInterfaceManager::getInstance(); + CInterfaceElement *pGC = IM->getElementFromId("ui:interface:bot_chat_object"); + CInterface3DShape *el= dynamic_cast(IM->getElementFromId("ui:interface:bot_chat_object:scene3d:object")); + if (el != NULL) + el->setName(selectedInstance.getShapeName()); + if (selectedInstanceURL.empty()) + { + if (pGC != NULL) + pGC->setActive(true); + } + else + { + if (pGC != NULL) + pGC->setActive(false); + IM->runActionHandler("browse", NULL, "name=ui:interface:webig:content:html|url="+selectedInstanceURL); + } +}// contextWebIG // + //----------------------------------------------- // contextOutpost //----------------------------------------------- From 04eaf119d74a4e0d2dd0fbffc782be0d487793f4 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 21:15:22 +0200 Subject: [PATCH 49/60] Changed: #1135 Merge changes from Ryzom patch 1.10 --- code/ryzom/client/src/character_cl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/character_cl.cpp b/code/ryzom/client/src/character_cl.cpp index 4e7a45885..e74539f74 100644 --- a/code/ryzom/client/src/character_cl.cpp +++ b/code/ryzom/client/src/character_cl.cpp @@ -1863,8 +1863,8 @@ void CCharacterCL::updateVisualPropertyPvpClan(const NLMISC::TGameCycle &/* game // get fames signs from prop for (uint8 fameIdx = 0; fameIdx < 7; fameIdx++) { - _PvpAllies[fameIdx] = prop & (1 << 2*fameIdx); - _PvpEnemies[fameIdx] = prop & (1 << ((2*fameIdx)+1)); + _PvpAllies[fameIdx] = (prop & (SINT64_CONSTANT(1) << (2*fameIdx))) != 0; + _PvpEnemies[fameIdx] = (prop & (SINT64_CONSTANT(1) << (2*fameIdx+1))) != 0; } _ClanCivMaxFame = PVP_CLAN::TPVPClan((prop & (0x03 << 2*7)) >> 2*7); From fec5b3f596784a4832fc346122afcede6d883786 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 23:12:07 +0200 Subject: [PATCH 50/60] Changed: Build world_editor only under Windows --- code/ryzom/tools/leveldesign/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/code/ryzom/tools/leveldesign/CMakeLists.txt b/code/ryzom/tools/leveldesign/CMakeLists.txt index ae9f502d3..0e49fedf0 100644 --- a/code/ryzom/tools/leveldesign/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/CMakeLists.txt @@ -3,13 +3,11 @@ ADD_SUBDIRECTORY(prim_export) ADD_SUBDIRECTORY(uni_conv) ADD_SUBDIRECTORY(csv_transform) ADD_SUBDIRECTORY(icon_search) -ADD_SUBDIRECTORY(world_editor) IF(WIN32) ADD_SUBDIRECTORY(export) + ADD_SUBDIRECTORY(world_editor) ENDIF(WIN32) -# Legacy folders, do not build -#ADD_SUBDIRECTORY(export) # folders not handled yet. #georges_convert From b62ac30ebba07572abc47cf49bf046315065b943 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 23:21:24 +0200 Subject: [PATCH 51/60] Changed: #1135 Some crashes under Linux --- code/ryzom/client/src/client_chat_manager.cpp | 14 +++++++++----- code/ryzom/client/src/interface_v3/chat_window.cpp | 3 ++- code/ryzom/client/src/interface_v3/people_list.cpp | 6 ++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index 97814abe1..0d23e5cd4 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -959,7 +959,7 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin bool bWoman = entity && entity->getGender() == GSGENDER::female; name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); - } + } else { // Does the char have a CSR title? @@ -967,7 +967,8 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin } ucstring cur_time; - if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false); + if (pNL && pNL->getValueBool()) { cur_time = CInterfaceManager::getTimestampHuman(); } @@ -1008,7 +1009,8 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde ucstring cur_time; if (cat.toString() != "&bbl&") { - if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false); + if (pNL && pNL->getValueBool()) { cur_time = CInterfaceManager::getTimestampHuman(); } @@ -1183,11 +1185,13 @@ class CHandlerTell : public IActionHandler ucstring finalMsg; CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, false); ucstring cur_time; - if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false); + if (pNL && pNL->getValueBool()) { cur_time = CInterfaceManager::getTimestampHuman(); } - ucstring csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + ucstring csr; + if (CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw())) csr += ucstring("(CSR) "); finalMsg += cur_time + csr + CI18N::get("youTell") + ": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, true); diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index e247c3d53..e8378ea10 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -473,7 +473,8 @@ void CChatWindow::displayLocalPlayerTell(const ucstring &msg, uint numBlinks /*= prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); encodeColorTag(prop.getRGBA(), finalMsg, false); ucstring cur_time; - if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false); + if (pNL && pNL->getValueBool()) { cur_time = CInterfaceManager::getTimestampHuman(); } diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index 83642687f..8ffa051a7 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -465,7 +465,8 @@ void CPeopleList::displayLocalPlayerTell(uint index,const ucstring &msg,uint num } ucstring cur_time; - if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false); + if (pNL && pNL->getValueBool()) { cur_time = CInterfaceManager::getTimestampHuman(); } @@ -936,7 +937,8 @@ class CHandlerContactEntry : public IActionHandler ucstring final; CChatWindow::encodeColorTag(prop.getRGBA(), final, false); ucstring cur_time; - if (CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false)->getValueBool()) + CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false); + if (pNL && pNL->getValueBool()) { cur_time = CInterfaceManager::getTimestampHuman(); } From 7bd13f3ccb3f35497e45a9418a47043d95ca46f9 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 23:51:50 +0200 Subject: [PATCH 52/60] Fixed: Bad detection if a file is in a BNP under Linux --- .../client/src/interface_v3/interface_parser.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index f85992bb8..f09df1f4a 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -4703,12 +4703,13 @@ bool CInterfaceParser::loadLUA(const std::string &fileName, std::string &error) } bool isInData = false; - if (pathName.find ("@") != string::npos) + std::string::size_type pos = pathName.find("@"); + if (pos != string::npos) { - if (CBigFile::getInstance().getBigFileName(pathName.substr(0, pathName.find ("@"))) != "data/"+pathName.substr(0, pathName.find ("@"))) - isInData = false; - else - isInData = true; + std::string bigFilename = CBigFile::getInstance().getBigFileName(pathName.substr(0, pos)); + std::string path = "data/"+pathName.substr(0, pos); + + isInData = bigFilename.find(path) != std::string::npos; } if (needCheck && !isInData) From 574d84fa75f81bd65385697a6790d9f9afed3142 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 19 Oct 2010 14:19:10 +0200 Subject: [PATCH 53/60] Fixed: Compilation with recent boost versions --- .../client/src/interface_v3/lua_helper.cpp | 17 +++++++++++------ code/ryzom/client/src/interface_v3/lua_ihm.cpp | 12 ++++++++++-- .../ryzom/client/src/interface_v3/lua_loadlib.h | 9 ++++++--- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/lua_helper.cpp b/code/ryzom/client/src/interface_v3/lua_helper.cpp index 80a275523..bd01d42f9 100644 --- a/code/ryzom/client/src/interface_v3/lua_helper.cpp +++ b/code/ryzom/client/src/interface_v3/lua_helper.cpp @@ -26,15 +26,20 @@ #endif -extern "C" -{ -#include "lualib.h" -} +#include "lua_loadlib.h" // to get rid of you_must_not_use_assert___use_nl_assert___read_debug_h_file messages #include -#undef assert -#define assert nlassert +#ifdef assert + #undef assert +#endif + +#ifdef NL_DEBUG + #define assert(x) nlassert(x) +#else + #define assert(x) +#endif + #include using namespace std; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.cpp b/code/ryzom/client/src/interface_v3/lua_ihm.cpp index 2b9752b52..b43c7f4ba 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm.cpp @@ -28,8 +28,16 @@ // to get rid of you_must_not_use_assert___use_nl_assert___read_debug_h_file messages #include -#undef assert -#define assert nlassert +#ifdef assert + #undef assert +#endif + +#ifdef NL_DEBUG + #define assert(x) nlassert(x) +#else + #define assert(x) +#endif + #include // in luabind > 0.6, LUABIND_MAX_ARITY is set to 10 #if LUABIND_MAX_ARITY == 10 diff --git a/code/ryzom/client/src/interface_v3/lua_loadlib.h b/code/ryzom/client/src/interface_v3/lua_loadlib.h index 32907d096..b68ed94fd 100644 --- a/code/ryzom/client/src/interface_v3/lua_loadlib.h +++ b/code/ryzom/client/src/interface_v3/lua_loadlib.h @@ -17,9 +17,12 @@ #ifndef LUA_LOADLIB_H #define LUA_LOADLIB_H -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" +extern "C" +{ +#include +#include +#include +} // load the lua dll, return 1 on success //int loadLuaDLL(); From 42d1cbf9fde7b4aa96e9489cbfcb954a44adc75f Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 19 Oct 2010 14:22:10 +0200 Subject: [PATCH 54/60] Changed: Use of getRyzomModes --- .../src/interface_v3/action_handler_game.cpp | 53 +---------------- code/ryzom/client/src/login.cpp | 57 ++----------------- 2 files changed, 6 insertions(+), 104 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index be0e50b5e..4b0fa1212 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -2904,59 +2904,10 @@ public: { if (Driver == NULL) return; - // **** Init Video Modes VideoModes.clear(); - Driver->getModes(VideoModes); - // Remove modes under 800x600 and get the unique string vector stringModeList; - sint i, j, nFoundMode = -1; - for (i=0; i < (sint)VideoModes.size(); ++i) - { - if ((VideoModes[i].Width < 800) || (VideoModes[i].Height < 600)) - { - VideoModes.erase(VideoModes.begin()+i); - --i; - } - else - { - bool bFound = false; - string tmp = toString(VideoModes[i].Width)+" x "+toString(VideoModes[i].Height); - for (j = 0; j < (sint)stringModeList.size(); ++j) - if (stringModeList[j] == tmp) - { - bFound = true; - break; - } - if (!bFound) - { - stringModeList.push_back(tmp); - if ((VideoModes[i].Width <= ClientCfg.Width) && (VideoModes[i].Height <= ClientCfg.Height)) - { - if (nFoundMode == -1) - { - nFoundMode = j; - } - else - { - if ((VideoModes[i].Width >= VideoModes[nFoundMode].Width) && - (VideoModes[i].Height >= VideoModes[nFoundMode].Height)) - nFoundMode = j; - } - } - } - } - } - // If no modes are available, display a message and exit - if (!ClientCfg.Windowed && nFoundMode == -1) - { - Driver->systemMessageBox("No Video Modes available!\n" - "Minimum Video mode to play Ryzom is 800x600.\n", - "No Video Mode!", - NL3D::UDriver::okType, - NL3D::UDriver::exclamationIcon); - exit(EXIT_SUCCESS); - } + sint nFoundMode = getRyzomModes(VideoModes, stringModeList); // Initialize interface combo box CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -2964,7 +2915,7 @@ public: if( pCB ) { pCB->resetTexts(); - for (j = 0; j < (sint)stringModeList.size(); j++) + for (sint j = 0; j < (sint)stringModeList.size(); j++) pCB->addText(ucstring(stringModeList[j])); } // -1 is important to indicate we set this value in edit mode diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index aad1a3a3e..35d7e00be 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -31,6 +31,7 @@ #include "nel/net/tcp_sock.h" #include "nel/3d/u_driver.h" +#include "nel/misc/big_file.h" #include "interface_v3/interface_manager.h" #include "interface_v3/input_handler_manager.h" @@ -1893,61 +1894,11 @@ class CAHInitResLod : public IActionHandler //nlinfo("CAHInitResLod called"); if (Driver == NULL) return; - // **** Init Video Modes VideoModes.clear(); - Driver->getModes(VideoModes); + StringModeList.clear(); StringModeList.push_back("uiConfigWindowed"); - // Remove modes under 800x600 and get the unique strings - sint i, j; - for (i=0; i < (sint)VideoModes.size(); ++i) - { - if ((VideoModes[i].Width < 800) || (VideoModes[i].Height < 600)) - { - VideoModes.erase(VideoModes.begin()+i); - --i; - } - else - { - bool bFound = false; - string tmp = toString(VideoModes[i].Width)+" x "+toString(VideoModes[i].Height); - for (j = 0; j < (sint)StringModeList.size(); ++j) - { - if (StringModeList[j] == tmp) - { - bFound = true; - break; - } - } - if (!bFound) - { - StringModeList.push_back(tmp); - if ((VideoModes[i].Width <= ClientCfg.Width) && (VideoModes[i].Height <= ClientCfg.Height)) - { - if (CurrentMode == -1) - { - CurrentMode = j; - } - else - { - if ((VideoModes[i].Width >= VideoModes[CurrentMode].Width) && - (VideoModes[i].Height >= VideoModes[CurrentMode].Height)) - CurrentMode = j; - } - } - } - } - } - - // If no modes are available, display a message and exit - if (VideoModes.empty()) - { - Driver->systemMessageBox("No Video Modes available!\n" - "Minimum Video mode to play Ryzom is 800x600.\n", - "No Video Mode!", - NL3D::UDriver::okType, - NL3D::UDriver::exclamationIcon); - exit(EXIT_SUCCESS); - } + + CurrentMode = getRyzomModes(VideoModes, StringModeList); // If the client is in windowed mode, still in windowed mode and do not change anything if (ClientCfg.Windowed) From 097ef0a8e8f56c97a060e91c6d34f80b20b868a5 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 19 Oct 2010 21:06:05 +0200 Subject: [PATCH 55/60] Changed: #1051 ForceRemovePatchCategories is using a bad index --- code/ryzom/client/src/login_patch.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 655f0221b..3a8cac886 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -1132,14 +1132,20 @@ void CPatchManager::readDescFile(sint32 nVersion) } } + CBNPFileSet &bnpFS = const_cast(DescFile.getFiles()); + for(cat = 0; cat < DescFile.getCategories().categoryCount();) { + const CBNPCategory &bnpCat = DescFile.getCategories().getCategory(cat); + if (std::find(ForceRemovePatchCategories.begin(), ForceRemovePatchCategories.end(), - DescFile.getCategories().getCategory(cat).getName()) != ForceRemovePatchCategories.end()) + bnpCat.getName()) != ForceRemovePatchCategories.end()) { - std::string fileName = DescFile.getCategories().getFile(cat); - CBNPFileSet &bnpFS = const_cast(DescFile.getFiles()); - bnpFS.removeFile(fileName); + for(uint file = 0; file < bnpCat.fileCount(); ++file) + { + std::string fileName = bnpCat.getFile(file); + bnpFS.removeFile(fileName); + } const_cast(DescFile.getCategories()).deleteCategory(cat); } else From f7f6ace84f50cdf3d946d0b25042e00b5bc11647 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 19 Oct 2010 21:11:42 +0200 Subject: [PATCH 56/60] Changed: #1051 Crash when index is out of bounds --- code/ryzom/tools/client/client_patcher/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/client/client_patcher/main.cpp b/code/ryzom/tools/client/client_patcher/main.cpp index c05c2097b..3eb779ed6 100644 --- a/code/ryzom/tools/client/client_patcher/main.cpp +++ b/code/ryzom/tools/client/client_patcher/main.cpp @@ -103,7 +103,7 @@ void printDownload(const std::string &str) length = (uint)ucstr.length(); if (length > maxLength) { - ucstr = ucstr.luabind_substr(length - maxLength - 3); + ucstr = ucstr.luabind_substr(length - maxLength + 3); nstr = std::string("...") + ucstr.toUtf8(); length = maxLength; } @@ -113,7 +113,7 @@ void printDownload(const std::string &str) length = (uint)nstr.length(); if (length > maxLength) { - nstr = std::string("...") + nstr.substr(length - maxLength - 3); + nstr = std::string("...") + nstr.substr(length - maxLength + 3); length = maxLength; } } From ff1de97c985d417c02c91303f080ccbe2e89bf93 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 19 Oct 2010 21:12:34 +0200 Subject: [PATCH 57/60] Changed: #1051 Check for client.cfg in Ryzom application directory --- code/ryzom/tools/client/client_patcher/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/ryzom/tools/client/client_patcher/main.cpp b/code/ryzom/tools/client/client_patcher/main.cpp index 3eb779ed6..052bd40d2 100644 --- a/code/ryzom/tools/client/client_patcher/main.cpp +++ b/code/ryzom/tools/client/client_patcher/main.cpp @@ -160,6 +160,10 @@ int main(int argc, char *argv[]) std::string config = "client.cfg"; + // if client.cfg is not in current directory, use client.cfg from user directory + if (!CFile::isExists(config)) + config = CPath::getApplicationDirectory("Ryzom") + config; + // if client.cfg is not in current directory, use client_default.cfg if (!CFile::isExists(config)) config = "client_default.cfg"; From c6acfb86f324df278995f4a936f27da136cb1640 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 19 Oct 2010 21:45:21 +0200 Subject: [PATCH 58/60] Changed: #825 Remove all warning when compiling Ryzom --- code/nel/include/nel/misc/eid_translator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/code/nel/include/nel/misc/eid_translator.h b/code/nel/include/nel/misc/eid_translator.h index 26b296ea1..695f7724e 100644 --- a/code/nel/include/nel/misc/eid_translator.h +++ b/code/nel/include/nel/misc/eid_translator.h @@ -20,6 +20,7 @@ #include #include #include +#include #include "types_nl.h" #include "entity_id.h" From 934883d4d0f6e37646c325a3bba9244f12f8c76b Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 20 Oct 2010 16:16:32 +0200 Subject: [PATCH 59/60] Changed: #1135 Merge changes from Ryzom patch 1.10 --- .../entities_game_service/player_manager/character.cpp | 8 ++++---- .../entities_game_service/player_manager/character.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/code/ryzom/server/src/entities_game_service/player_manager/character.cpp b/code/ryzom/server/src/entities_game_service/player_manager/character.cpp index 6b3bd6ea5..24cbf2173 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -17662,10 +17662,10 @@ void CCharacter::barUpdate() _PhysScores._PhysicalScores[ SCORES::focus].Current() != _OldFocusBarSentToPlayer ) { // bkup cache - _OldHpBarSentToPlayer= (sint16)_PhysScores._PhysicalScores[ SCORES::hit_points ].Current(); - _OldSapBarSentToPlayer= (sint16)_PhysScores._PhysicalScores[ SCORES::sap].Current(); - _OldStaBarSentToPlayer= (sint16)_PhysScores._PhysicalScores[ SCORES::stamina].Current(); - _OldFocusBarSentToPlayer= (sint16)_PhysScores._PhysicalScores[ SCORES::focus].Current(); + _OldHpBarSentToPlayer= _PhysScores._PhysicalScores[ SCORES::hit_points ].Current(); + _OldSapBarSentToPlayer= _PhysScores._PhysicalScores[ SCORES::sap].Current(); + _OldStaBarSentToPlayer= _PhysScores._PhysicalScores[ SCORES::stamina].Current(); + _OldFocusBarSentToPlayer= _PhysScores._PhysicalScores[ SCORES::focus].Current(); // Since client must listen only the last message (no delta like DB here...), use a small counter _BarSentToPlayerMsgNumber++; diff --git a/code/ryzom/server/src/entities_game_service/player_manager/character.h b/code/ryzom/server/src/entities_game_service/player_manager/character.h index e1c190513..76bf8c64d 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/character.h +++ b/code/ryzom/server/src/entities_game_service/player_manager/character.h @@ -2914,11 +2914,11 @@ private: /// temp values used to test if Players bars need an update or not uint8 _BarSentToPlayerMsgNumber; - /// NB: 16 bits because guigui ensure me cannot goes beyond something like 6000 - sint16 _OldHpBarSentToPlayer; - sint16 _OldSapBarSentToPlayer; - sint16 _OldStaBarSentToPlayer; - sint16 _OldFocusBarSentToPlayer; + + sint32 _OldHpBarSentToPlayer; + sint32 _OldSapBarSentToPlayer; + sint32 _OldStaBarSentToPlayer; + sint32 _OldFocusBarSentToPlayer; NLMISC::TGameCycle _LastTickSaved; NLMISC::TGameCycle _LastTickCompassUpdated; From e7158700502d93c3e9799b06e4056ba151214b71 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 22 Oct 2010 09:19:39 +0200 Subject: [PATCH 60/60] Fixed: Names and exported symbols for sound drivers (thanks to Krolock) --- .../src/sound/driver/dsound/CMakeLists.txt | 18 ++++++------ code/nel/src/sound/driver/fmod/CMakeLists.txt | 18 ++++++------ .../src/sound/driver/openal/CMakeLists.txt | 28 +++++++++++-------- .../src/sound/driver/xaudio2/CMakeLists.txt | 18 ++++++------ 4 files changed, 44 insertions(+), 38 deletions(-) diff --git a/code/nel/src/sound/driver/dsound/CMakeLists.txt b/code/nel/src/sound/driver/dsound/CMakeLists.txt index aeef35c8b..f2d13d785 100644 --- a/code/nel/src/sound/driver/dsound/CMakeLists.txt +++ b/code/nel/src/sound/driver/dsound/CMakeLists.txt @@ -1,19 +1,19 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.def) -NL_TARGET_DRIVER(nel_drv_dsound ${SRC}) +NL_TARGET_DRIVER(nel_drv_dsound_win ${SRC}) INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(nel_drv_dsound nelmisc nelsnd_lowlevel ${DXSDK_DSOUND_LIBRARY} ${DXSDK_GUID_LIBRARY}) +TARGET_LINK_LIBRARIES(nel_drv_dsound_win nelmisc nelsnd_lowlevel ${DXSDK_DSOUND_LIBRARY} ${DXSDK_GUID_LIBRARY}) -NL_DEFAULT_PROPS(nel_drv_dsound "NeL, Driver, Sound: DirectSound") -NL_ADD_RUNTIME_FLAGS(nel_drv_dsound) -NL_ADD_LIB_SUFFIX(nel_drv_dsound) +NL_DEFAULT_PROPS(nel_drv_dsound_win "NeL, Driver, Sound: DirectSound") +NL_ADD_RUNTIME_FLAGS(nel_drv_dsound_win) +NL_ADD_LIB_SUFFIX(nel_drv_dsound_win) IF(WITH_PCH) - ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_dsound ${CMAKE_CURRENT_SOURCE_DIR}/stddsound.h ${CMAKE_CURRENT_SOURCE_DIR}/stddsound.cpp) + ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_dsound_win ${CMAKE_CURRENT_SOURCE_DIR}/stddsound.h ${CMAKE_CURRENT_SOURCE_DIR}/stddsound.cpp) ENDIF(WITH_PCH) -INSTALL(TARGETS nel_drv_dsound RUNTIME DESTINATION bin LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib COMPONENT driverssound) +INSTALL(TARGETS nel_drv_dsound_win RUNTIME DESTINATION bin LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib COMPONENT driverssound) IF(WITH_MAXPLUGIN) - INSTALL(TARGETS nel_drv_dsound RUNTIME DESTINATION maxplugin COMPONENT driverssound) + INSTALL(TARGETS nel_drv_dsound_win RUNTIME DESTINATION maxplugin COMPONENT driverssound) ENDIF(WITH_MAXPLUGIN) diff --git a/code/nel/src/sound/driver/fmod/CMakeLists.txt b/code/nel/src/sound/driver/fmod/CMakeLists.txt index 616b62300..049d8b627 100644 --- a/code/nel/src/sound/driver/fmod/CMakeLists.txt +++ b/code/nel/src/sound/driver/fmod/CMakeLists.txt @@ -1,19 +1,19 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.def) -NL_TARGET_DRIVER(nel_drv_fmod ${SRC}) +NL_TARGET_DRIVER(nel_drv_fmod_win ${SRC}) INCLUDE_DIRECTORIES(${FMOD_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(nel_drv_fmod ${FMOD_LIBRARY} nelmisc nelsnd_lowlevel) +TARGET_LINK_LIBRARIES(nel_drv_fmod_win ${FMOD_LIBRARY} nelmisc nelsnd_lowlevel) -NL_DEFAULT_PROPS(nel_drv_fmod "NeL, Driver, Sound: FMOD") -NL_ADD_RUNTIME_FLAGS(nel_drv_fmod) -NL_ADD_LIB_SUFFIX(nel_drv_fmod) +NL_DEFAULT_PROPS(nel_drv_fmod_win "NeL, Driver, Sound: FMOD") +NL_ADD_RUNTIME_FLAGS(nel_drv_fmod_win) +NL_ADD_LIB_SUFFIX(nel_drv_fmod_win) IF(WITH_PCH) - ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_fmod ${CMAKE_CURRENT_SOURCE_DIR}/stdfmod.h ${CMAKE_CURRENT_SOURCE_DIR}/stdfmod.cpp) + ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_fmod_win ${CMAKE_CURRENT_SOURCE_DIR}/stdfmod.h ${CMAKE_CURRENT_SOURCE_DIR}/stdfmod.cpp) ENDIF(WITH_PCH) -INSTALL(TARGETS nel_drv_fmod RUNTIME DESTINATION bin LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib COMPONENT driverssound) +INSTALL(TARGETS nel_drv_fmod_win RUNTIME DESTINATION bin LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib COMPONENT driverssound) IF(WITH_MAXPLUGIN) - INSTALL(TARGETS nel_drv_fmod RUNTIME DESTINATION maxplugin COMPONENT driverssound) + INSTALL(TARGETS nel_drv_fmod_win RUNTIME DESTINATION maxplugin COMPONENT driverssound) ENDIF(WITH_MAXPLUGIN) diff --git a/code/nel/src/sound/driver/openal/CMakeLists.txt b/code/nel/src/sound/driver/openal/CMakeLists.txt index 626a5cf07..cfdad7910 100644 --- a/code/nel/src/sound/driver/openal/CMakeLists.txt +++ b/code/nel/src/sound/driver/openal/CMakeLists.txt @@ -1,4 +1,10 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.def) + +IF(WIN32) + SET(NLDRV_AL_LIB "nel_drv_openal_win") +ELSE(WIN32) + SET(NLDRV_AL_LIB "nel_drv_openal") +ENDIF(WIN32) SOURCE_GROUP(efx FILES effect_al.cpp @@ -18,31 +24,31 @@ SOURCE_GROUP(util FILES ext_al.cpp ext_al.h) -NL_TARGET_DRIVER(nel_drv_openal ${SRC}) +NL_TARGET_DRIVER(${NLDRV_AL_LIB} ${SRC}) INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR}) IF(WITH_STLPORT) - TARGET_LINK_LIBRARIES(nel_drv_openal ${CMAKE_THREAD_LIBS_INIT}) + TARGET_LINK_LIBRARIES(${NLDRV_AL_LIB} ${CMAKE_THREAD_LIBS_INIT}) ENDIF(WITH_STLPORT) -TARGET_LINK_LIBRARIES(nel_drv_openal ${OPENAL_LIBRARY} nelmisc nelsnd_lowlevel) -NL_DEFAULT_PROPS(nel_drv_openal "NeL, Driver, Sound: OpenAL") -NL_ADD_RUNTIME_FLAGS(nel_drv_openal) -NL_ADD_LIB_SUFFIX(nel_drv_openal) +TARGET_LINK_LIBRARIES(${NLDRV_AL_LIB} ${OPENAL_LIBRARY} nelmisc nelsnd_lowlevel) +NL_DEFAULT_PROPS(${NLDRV_AL_LIB} "NeL, Driver, Sound: OpenAL") +NL_ADD_RUNTIME_FLAGS(${NLDRV_AL_LIB}) +NL_ADD_LIB_SUFFIX(${NLDRV_AL_LIB}) IF(WIN32) # Find and include EFX-Util on Windows. FIND_PACKAGE(EFXUtil) INCLUDE_DIRECTORIES(${EFXUTIL_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(nel_drv_openal ${EFXUTIL_LIBRARY}) + TARGET_LINK_LIBRARIES(${NLDRV_AL_LIB} ${EFXUTIL_LIBRARY}) ENDIF(WIN32) IF(WITH_PCH) - ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_openal ${CMAKE_CURRENT_SOURCE_DIR}/stdopenal.h ${CMAKE_CURRENT_SOURCE_DIR}/stdopenal.cpp) + ADD_NATIVE_PRECOMPILED_HEADER(${NLDRV_AL_LIB} ${CMAKE_CURRENT_SOURCE_DIR}/stdopenal.h ${CMAKE_CURRENT_SOURCE_DIR}/stdopenal.cpp) ENDIF(WITH_PCH) -INSTALL(TARGETS nel_drv_openal RUNTIME DESTINATION bin LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib COMPONENT driverssound) +INSTALL(TARGETS ${NLDRV_AL_LIB} RUNTIME DESTINATION bin LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib COMPONENT driverssound) IF(WITH_MAXPLUGIN) - INSTALL(TARGETS nel_drv_openal RUNTIME DESTINATION maxplugin COMPONENT driverssound) + INSTALL(TARGETS ${NLDRV_AL_LIB} RUNTIME DESTINATION maxplugin COMPONENT driverssound) ENDIF(WITH_MAXPLUGIN) diff --git a/code/nel/src/sound/driver/xaudio2/CMakeLists.txt b/code/nel/src/sound/driver/xaudio2/CMakeLists.txt index 431d336dd..5e45a9809 100644 --- a/code/nel/src/sound/driver/xaudio2/CMakeLists.txt +++ b/code/nel/src/sound/driver/xaudio2/CMakeLists.txt @@ -1,4 +1,4 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.def) SOURCE_GROUP(sfx FILES buffer_xaudio2.cpp @@ -26,21 +26,21 @@ SOURCE_GROUP(efx FILES effect_xaudio2.cpp effect_xaudio2.h) -NL_TARGET_DRIVER(nel_drv_xaudio2 ${SRC}) +NL_TARGET_DRIVER(nel_drv_xaudio2_win ${SRC}) INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(nel_drv_xaudio2 nelmisc nelsnd_lowlevel ${DXSDK_XAUDIO_LIBRARY} ${DXSDK_GUID_LIBRARY}) +TARGET_LINK_LIBRARIES(nel_drv_xaudio2_win nelmisc nelsnd_lowlevel ${DXSDK_XAUDIO_LIBRARY} ${DXSDK_GUID_LIBRARY}) -NL_DEFAULT_PROPS(nel_drv_xaudio2 "NeL, Driver, Sound: XAudio2") -NL_ADD_RUNTIME_FLAGS(nel_drv_xaudio2) -NL_ADD_LIB_SUFFIX(nel_drv_xaudio2) +NL_DEFAULT_PROPS(nel_drv_xaudio2_win "NeL, Driver, Sound: XAudio2") +NL_ADD_RUNTIME_FLAGS(nel_drv_xaudio2_win) +NL_ADD_LIB_SUFFIX(nel_drv_xaudio2_win) IF(WITH_PCH) - ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_xaudio2 ${CMAKE_CURRENT_SOURCE_DIR}/stdxaudio2.h ${CMAKE_CURRENT_SOURCE_DIR}/stdxaudio2.cpp) + ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_xaudio2_win ${CMAKE_CURRENT_SOURCE_DIR}/stdxaudio2.h ${CMAKE_CURRENT_SOURCE_DIR}/stdxaudio2.cpp) ENDIF(WITH_PCH) -INSTALL(TARGETS nel_drv_xaudio2 RUNTIME DESTINATION bin LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib COMPONENT driverssound) +INSTALL(TARGETS nel_drv_xaudio2_win RUNTIME DESTINATION bin LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib COMPONENT driverssound) IF(WITH_MAXPLUGIN) - INSTALL(TARGETS nel_drv_xaudio2 RUNTIME DESTINATION maxplugin COMPONENT driverssound) + INSTALL(TARGETS nel_drv_xaudio2_win RUNTIME DESTINATION maxplugin COMPONENT driverssound) ENDIF(WITH_MAXPLUGIN)