From 41a803dd408e1f2d40d55e36a05eaec15fffbf8a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 12 Nov 2019 19:00:52 +0800 Subject: [PATCH 01/10] Run pipeline setup in batch file --- code/nel/tools/build_gamedata/all_dev.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/nel/tools/build_gamedata/all_dev.bat b/code/nel/tools/build_gamedata/all_dev.bat index c9c13eba3..12e47f9bd 100644 --- a/code/nel/tools/build_gamedata/all_dev.bat +++ b/code/nel/tools/build_gamedata/all_dev.bat @@ -1,3 +1,5 @@ +title Ryzom Core: 0_setup.py --noconf +0_setup.py --noconf title Ryzom Core: 1_export.py 1_export.py title Ryzom Core: 2_build.py From 41c4cdbc7b7d915d9c94ba98dd34a29e1e52a969 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 13 Nov 2019 09:42:13 +0800 Subject: [PATCH 02/10] Bump NeL version --- code/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index e263da274..46900daa6 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -48,15 +48,15 @@ CHECK_OUT_OF_SOURCE() IF(CMAKE_VERSION VERSION_GREATER "2.8.10") STRING(TIMESTAMP CURRENT_YEAR "%Y") ELSE() - SET(CURRENT_YEAR "2016") + SET(CURRENT_YEAR "2019") ENDIF() CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(RyzomCore CXX C) SET(NL_VERSION_MAJOR 1) SET(NL_VERSION_MINOR 0) -SET(NL_VERSION_PATCH 1) -SET(YEAR "2004-${CURRENT_YEAR}") +SET(NL_VERSION_PATCH 2) +SET(YEAR "2001-${CURRENT_YEAR}") SET(AUTHOR "Winch Gate and The Ryzom Core Community") SET(RYZOM_VERSION_MAJOR 3) From f81f348d6492ccafd2b170d44e973af6e6b7d753 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 13 Nov 2019 10:09:28 +0800 Subject: [PATCH 03/10] Remove sound sheet workaround --- code/nel/src/misc/sheet_id.cpp | 337 ++++++++++++++------------------- 1 file changed, 146 insertions(+), 191 deletions(-) diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index 2dd895153..ecbe84089 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -30,35 +30,30 @@ using namespace std; #ifdef DEBUG_NEW - #define new DEBUG_NEW +#define new DEBUG_NEW #endif -namespace NLMISC { +namespace NLMISC +{ CSheetId::CChar CSheetId::_AllStrings; -CStaticMap CSheetId::_SheetIdToName; -CStaticMap CSheetId::_SheetNameToId; +CStaticMap CSheetId::_SheetIdToName; +CStaticMap CSheetId::_SheetNameToId; //map CSheetId::_SheetIdToName; //map CSheetId::_SheetNameToId; vector CSheetId::_FileExtensions; -bool CSheetId::_Initialised=false; -bool CSheetId::_RemoveUnknownSheet=true; +bool CSheetId::_Initialised = false; +bool CSheetId::_RemoveUnknownSheet = true; bool CSheetId::_DontHaveSheetKnowledge = false; std::map CSheetId::_DevTypeNameToId; -std::vector > CSheetId::_DevSheetIdToName; +std::vector> CSheetId::_DevSheetIdToName; std::map CSheetId::_DevSheetNameToId; -#define NL_TEMP_YUBO_NO_SOUND_SHEET_ID - -#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID -namespace { bool a_NoSoundSheetId = false; const uint32 a_NoSoundSheetType = 80; } -#endif - const CSheetId CSheetId::Unknown(0); -void CSheetId::cbFileChange (const std::string &filename) +void CSheetId::cbFileChange(const std::string &filename) { - nlinfo ("SHEETID: %s changed, reload it", filename.c_str()); + nlinfo("SHEETID: %s changed, reload it", filename.c_str()); loadSheetId(); } @@ -67,14 +62,14 @@ void CSheetId::cbFileChange (const std::string &filename) // CSheetId // //----------------------------------------------- -CSheetId::CSheetId( uint32 sheetRef) +CSheetId::CSheetId(uint32 sheetRef) { _Id.Id = sheetRef; #ifdef NL_DEBUG_SHEET_ID // Yoyo: don't access the static map, because of order of static ctor call. // For now, all static CSheetId are 0 (eg: CSheetId::Unknown) - if(sheetRef) + if (sheetRef) { CStaticMap::iterator it(_SheetIdToName.find(sheetRef)); if (it != _SheetIdToName.end()) @@ -91,19 +86,18 @@ CSheetId::CSheetId( uint32 sheetRef) #endif } - //----------------------------------------------- // CSheetId // //----------------------------------------------- -CSheetId::CSheetId( const string& sheetName ) +CSheetId::CSheetId(const string &sheetName) { if (!buildSheetId(sheetName)) { - if(sheetName.empty()) + if (sheetName.empty()) nlwarning("SHEETID: Try to create an CSheetId with empty name. TODO: check why."); else - nlwarning("SHEETID: The sheet '%s' is not in sheet_id.bin, setting it to Unknown",sheetName.c_str()); + nlwarning("SHEETID: The sheet '%s' is not in sheet_id.bin, setting it to Unknown", sheetName.c_str()); //std::string stack; //NLMISC::getCallStack(stack); //std::vector contexts; @@ -118,11 +112,11 @@ CSheetId::CSheetId( const string& sheetName ) } // CSheetId // -CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType ) +CSheetId::CSheetId(const std::string &sheetName, const std::string &defaultType) { // Don't use this function without defaultType, use the one above. nlassert(defaultType.size() != 0); - + if (sheetName.rfind('.') == std::string::npos) { std::string withType = sheetName + "." + defaultType; @@ -135,15 +129,14 @@ CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType } } - //----------------------------------------------- // Build // //----------------------------------------------- -bool CSheetId::buildSheetId(const std::string& sheetName) +bool CSheetId::buildSheetId(const std::string &sheetName) { nlassert(_Initialised); - + // When no sheet_id.bin is loaded, use dynamically assigned IDs. if (_DontHaveSheetKnowledge) { @@ -188,15 +181,15 @@ bool CSheetId::buildSheetId(const std::string& sheetName) } // try looking up the sheet name in _SheetNameToId - CStaticMap::const_iterator itId; + CStaticMap::const_iterator itId; CChar c; - c.Ptr = new char [sheetName.size()+1]; + c.Ptr = new char[sheetName.size() + 1]; strcpy(c.Ptr, sheetName.c_str()); toLower(c.Ptr); - itId = _SheetNameToId.find (c); - delete [] c.Ptr; - if( itId != _SheetNameToId.end() ) + itId = _SheetNameToId.find(c); + delete[] c.Ptr; + if (itId != _SheetNameToId.end()) { _Id.Id = itId->second; #ifdef NL_DEBUG_SHEET_ID @@ -207,40 +200,21 @@ bool CSheetId::buildSheetId(const std::string& sheetName) } // we failed to find the sheet name in the sheetname map so see if the string is numeric - if (sheetName.size()>1 && sheetName[0]=='#') + if (sheetName.size() > 1 && sheetName[0] == '#') { uint32 numericId; - NLMISC::fromString((const char*)(sheetName.c_str()+1), numericId); - if (NLMISC::toString("#%u",numericId)==sheetName) - { - _Id.Id= numericId; - return true; - } - } - -#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID - if (a_NoSoundSheetId && sheetName.find(".sound") != std::string::npos) - { - std::string sheetNameLc = toLower(sheetName); - std::map::iterator it = _DevSheetNameToId.find(sheetNameLc); - if (it == _DevSheetNameToId.end()) + NLMISC::fromString((const char *)(sheetName.c_str() + 1), numericId); + if (NLMISC::toString("#%u", numericId) == sheetName) { - // nldebug("SHEETID: Creating a temporary sheet id for '%s'", sheetName.c_str()); - _DevSheetIdToName[0].push_back(sheetName); - _Id.IdInfos.Type = a_NoSoundSheetType; - _Id.IdInfos.Id = _DevSheetIdToName[0].size() - 1; - _DevSheetNameToId[sheetNameLc] = _Id.Id; + _Id.Id = numericId; return true; } - _Id.Id = it->second; - return true; } -#endif return false; } -void CSheetId::loadSheetId () +void CSheetId::loadSheetId() { H_AUTO(CSheetIdInit); //nldebug("Loading sheet_id.bin"); @@ -248,18 +222,18 @@ void CSheetId::loadSheetId () // Open the sheet id to sheet file name association CIFile file; std::string path = CPath::lookup("sheet_id.bin", false, false); - if(!path.empty() && file.open(path)) + if (!path.empty() && file.open(path)) { // clear entries - _FileExtensions.clear (); - _SheetIdToName.clear (); - _SheetNameToId.clear (); + _FileExtensions.clear(); + _SheetIdToName.clear(); + _SheetNameToId.clear(); // reserve space for the vector of file extensions _FileExtensions.resize(1 << (NL_SHEET_ID_TYPE_BITS)); // Get the map from the file - map tempMap; + map tempMap; contReset(tempMap); file.serialCont(tempMap); file.close(); @@ -270,23 +244,23 @@ void CSheetId::loadSheetId () uint32 nbfiles = (uint32)tempMap.size(); // now we remove all files that not available - map::iterator itStr2; - for( itStr2 = tempMap.begin(); itStr2 != tempMap.end(); ) + map::iterator itStr2; + for (itStr2 = tempMap.begin(); itStr2 != tempMap.end();) { - if (CPath::exists ((*itStr2).second)) + if (CPath::exists((*itStr2).second)) { ++itStr2; } else { - map::iterator olditStr = itStr2; + map::iterator olditStr = itStr2; //nldebug ("Removing file '%s' from CSheetId because the file not exists", (*olditStr).second.c_str ()); itStr2++; - tempMap.erase (olditStr); + tempMap.erase(olditStr); removednbfiles++; } } - nlinfo ("SHEETID: Removed %d files on %d from CSheetId because these files don't exist", removednbfiles, nbfiles); + nlinfo("SHEETID: Removed %d files on %d from CSheetId because these files don't exist", removednbfiles, nbfiles); } // Convert the map to one big string and 1 static map (id to name) @@ -295,10 +269,10 @@ void CSheetId::loadSheetId () vector tempVec; // Used to initialise the first map uint32 nNb = 0; uint32 nSize = 0; - map::const_iterator it = tempMap.begin(); + map::const_iterator it = tempMap.begin(); while (it != tempMap.end()) { - nSize += (uint32)it->second.size()+1; + nSize += (uint32)it->second.size() + 1; nNb++; it++; } @@ -311,10 +285,10 @@ void CSheetId::loadSheetId () nNb = 0; while (it != tempMap.end()) { - tempVec[nNb].Ptr = _AllStrings.Ptr+nSize; - strcpy(_AllStrings.Ptr+nSize, it->second.c_str()); - toLower(_AllStrings.Ptr+nSize); - nSize += (uint32)it->second.size()+1; + tempVec[nNb].Ptr = _AllStrings.Ptr + nSize; + strcpy(_AllStrings.Ptr + nSize, it->second.c_str()); + toLower(_AllStrings.Ptr + nSize); + nSize += (uint32)it->second.size() + 1; nNb++; it++; } @@ -339,15 +313,15 @@ void CSheetId::loadSheetId () { uint32 nSize = (uint32)_SheetIdToName.size(); _SheetNameToId.reserve(nSize); - CStaticMap::iterator itStr; - for( itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr ) + CStaticMap::iterator itStr; + for (itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr) { // add entry to the inverse map - _SheetNameToId.add( make_pair((*itStr).second, (*itStr).first) ); + _SheetNameToId.add(make_pair((*itStr).second, (*itStr).first)); // work out the type value for this entry in the map TSheetId sheetId; - sheetId.Id=(*itStr).first; + sheetId.Id = (*itStr).first; uint32 type = sheetId.IdInfos.Type; // check whether we need to add an entry to the file extensions vector @@ -365,10 +339,9 @@ void CSheetId::loadSheetId () { nlerror(" Can't open the file sheet_id.bin"); } - nldebug("Finished loading sheet_id.bin: %u entries read",_SheetIdToName.size()); + nldebug("Finished loading sheet_id.bin: %u entries read", _SheetIdToName.size()); } - //----------------------------------------------- // init // @@ -383,30 +356,12 @@ void CSheetId::init(bool removeUnknownSheet) return; } -// CFile::addFileChangeCallback ("sheet_id.bin", cbFileChange); + // CFile::addFileChangeCallback ("sheet_id.bin", cbFileChange); _RemoveUnknownSheet = removeUnknownSheet; - loadSheetId (); - _Initialised=true; - -#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID - if (typeFromFileExtension("sound") == std::numeric_limits::max()) - { - nlwarning("SHEETID: Loading without known sound sheet id, please update sheet_id.bin with .sound sheets"); - nlassert(_FileExtensions.size() == 1 << (NL_SHEET_ID_TYPE_BITS)); - nlassert(_FileExtensions[a_NoSoundSheetType].empty()); - _FileExtensions[a_NoSoundSheetType] = "sound"; - _DevSheetIdToName.push_back(std::vector()); - _DevSheetIdToName[0].push_back("unknown.sound"); - TSheetId id; - id.IdInfos.Type = a_NoSoundSheetType; - id.IdInfos.Id = _DevSheetIdToName[0].size() - 1; - nlassert(id.IdInfos.Id == 0); - _DevSheetNameToId["unknown.sound"] = id.Id; - a_NoSoundSheetId = true; - } -#endif + loadSheetId(); + _Initialised = true; } // init // @@ -422,19 +377,17 @@ void CSheetId::initWithoutSheet() _DontHaveSheetKnowledge = true; // Initialize id 0,0 as unknown.unknown - CSheetId unknownunknown = CSheetId("unknown.unknown"); - nlassert(unknownunknown == CSheetId::Unknown); + CSheetId unknownUnknown = CSheetId("unknown.unknown"); + nlassert(unknownUnknown == CSheetId::Unknown); } - - //----------------------------------------------- // uninit // //----------------------------------------------- void CSheetId::uninit() { - delete [] _AllStrings.Ptr; + delete[] _AllStrings.Ptr; _FileExtensions.clear(); _DevTypeNameToId.clear(); _DevSheetIdToName.clear(); @@ -445,11 +398,12 @@ void CSheetId::uninit() // operator= // //----------------------------------------------- -CSheetId& CSheetId::operator=( const CSheetId& sheetId ) +CSheetId &CSheetId::operator=(const CSheetId &sheetId) { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); - if(this == &sheetId) + if (this == &sheetId) { return *this; } @@ -460,17 +414,15 @@ CSheetId& CSheetId::operator=( const CSheetId& sheetId ) _DebugSheetName = sheetId._DebugSheetName; #endif - return *this; - + return *this; } // operator= // - //----------------------------------------------- // operator= // //----------------------------------------------- -CSheetId& CSheetId::operator=( const string& sheetName ) +CSheetId &CSheetId::operator=(const string &sheetName) { if (!buildSheetId(sheetName)) @@ -482,14 +434,14 @@ CSheetId& CSheetId::operator=( const string& sheetName ) } // operator= // - //----------------------------------------------- // operator= // //----------------------------------------------- -CSheetId& CSheetId::operator=( uint32 sheetRef ) +CSheetId &CSheetId::operator=(uint32 sheetRef) { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); _Id.Id = sheetRef; @@ -497,15 +449,14 @@ CSheetId& CSheetId::operator=( uint32 sheetRef ) } // operator= // - - //----------------------------------------------- // operator< // //----------------------------------------------- -bool CSheetId::operator < (const CSheetId& sheetRef ) const +bool CSheetId::operator<(const CSheetId &sheetRef) const { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); if (_Id.Id < sheetRef.asInt()) { @@ -516,56 +467,62 @@ bool CSheetId::operator < (const CSheetId& sheetRef ) const } // operator< // - - //----------------------------------------------- // toString // //----------------------------------------------- string CSheetId::toString(bool ifNotFoundUseNumericId) const { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); if (_DontHaveSheetKnowledge) { - // FIXME: When someone punches in a fake sheet id this will - // fail. - return _DevSheetIdToName[_Id.IdInfos.Type][_Id.IdInfos.Id]; + if (_Id.IdInfos.Type < _DevSheetIdToName.size() + && _Id.IdInfos.Id < _DevSheetIdToName[_Id.IdInfos.Type].size()) + { + return _DevSheetIdToName[_Id.IdInfos.Type][_Id.IdInfos.Id]; + } + else + { + if (ifNotFoundUseNumericId) + { + return NLMISC::toString("#%u", _Id.Id); + } + else + { + return NLMISC::toString("", _Id.Id); + } + } } - CStaticMap::const_iterator itStr = _SheetIdToName.find (_Id.Id); - if( itStr != _SheetIdToName.end() ) + CStaticMap::const_iterator itStr = _SheetIdToName.find(_Id.Id); + if (itStr != _SheetIdToName.end()) { return string((*itStr).second.Ptr); } else { -#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID - if (a_NoSoundSheetId && _Id.IdInfos.Type == a_NoSoundSheetType) - { - return _DevSheetIdToName[0][_Id.IdInfos.Id]; - } -#endif // This nlwarning is commented out because the loggers are mutexed, therefore // you couldn't use toString() within a nlwarning(). //nlwarning(" The sheet %08x is not in sheet_id.bin",_Id.Id); if (ifNotFoundUseNumericId) { - return NLMISC::toString( "#%u", _Id.Id ); + return NLMISC::toString("#%u", _Id.Id); } else { - return NLMISC::toString( "", _Id.Id ); + return NLMISC::toString("", _Id.Id); } } } // toString // -void CSheetId::serial(NLMISC::IStream &f) +void CSheetId::serial(NLMISC::IStream &f) { nlassert(!_DontHaveSheetKnowledge); - f.serial( _Id.Id ); + f.serial(_Id.Id); #ifdef NL_DEBUG_SHEET_ID CStaticMap::iterator it(_SheetIdToName.find(_Id.Id)); @@ -579,7 +536,7 @@ void CSheetId::serial(NLMISC::IStream &f) void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) { nlassert(_Initialised); - + if (f.isReading()) { std::string sheetName; @@ -595,90 +552,88 @@ void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) } } - //----------------------------------------------- // display // //----------------------------------------------- void CSheetId::display() { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); - CStaticMap::const_iterator itStr; - for( itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr ) + CStaticMap::const_iterator itStr; + for (itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr) { //nlinfo("%d %s",(*itStr).first,(*itStr).second.c_str()); - nlinfo("SHEETID: (%08x %d) %s",(*itStr).first,(*itStr).first,(*itStr).second.Ptr); + nlinfo("SHEETID: (%08x %d) %s", (*itStr).first, (*itStr).first, (*itStr).second.Ptr); } } // display // - - //----------------------------------------------- // display // //----------------------------------------------- void CSheetId::display(uint32 type) { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); - CStaticMap::const_iterator itStr; - for( itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr ) + CStaticMap::const_iterator itStr; + for (itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr) { // work out the type value for this entry in the map TSheetId sheetId; - sheetId.Id=(*itStr).first; + sheetId.Id = (*itStr).first; // decide whether or not to display the entry - if (type==sheetId.IdInfos.Type) + if (type == sheetId.IdInfos.Type) { //nlinfo("%d %s",(*itStr).first,(*itStr).second.c_str()); - nlinfo("SHEETID: (%08x %d) %s",(*itStr).first,(*itStr).first,(*itStr).second.Ptr); + nlinfo("SHEETID: (%08x %d) %s", (*itStr).first, (*itStr).first, (*itStr).second.Ptr); } } } // display // - - //----------------------------------------------- // buildIdVector // //----------------------------------------------- -void CSheetId::buildIdVector(std::vector &result) +void CSheetId::buildIdVector(std::vector &result) { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); - CStaticMap::const_iterator itStr; - for( itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr ) + CStaticMap::const_iterator itStr; + for (itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr) { - result.push_back( (CSheetId)(*itStr).first ); + result.push_back((CSheetId)(*itStr).first); } } // buildIdVector // - //----------------------------------------------- // buildIdVector // //----------------------------------------------- -void CSheetId::buildIdVector(std::vector &result, uint32 type) +void CSheetId::buildIdVector(std::vector &result, uint32 type) { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); nlassert(type < (1 << (NL_SHEET_ID_TYPE_BITS))); - CStaticMap::const_iterator itStr; - for( itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr ) + CStaticMap::const_iterator itStr; + for (itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr) { // work out the type value for this entry in the map TSheetId sheetId; - sheetId.Id=(*itStr).first; + sheetId.Id = (*itStr).first; // decide whether or not to use the entry - if (type==sheetId.IdInfos.Type) + if (type == sheetId.IdInfos.Type) { - result.push_back( (CSheetId)sheetId.Id ); + result.push_back((CSheetId)sheetId.Id); } } @@ -688,23 +643,24 @@ void CSheetId::buildIdVector(std::vector &result, uint32 type) // buildIdVector // //----------------------------------------------- -void CSheetId::buildIdVector(std::vector &result, std::vector &resultFilenames,uint32 type) +void CSheetId::buildIdVector(std::vector &result, std::vector &resultFilenames, uint32 type) { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); nlassert(type < (1 << (NL_SHEET_ID_TYPE_BITS))); - CStaticMap::const_iterator itStr; - for( itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr ) + CStaticMap::const_iterator itStr; + for (itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr) { // work out the type value for this entry in the map TSheetId sheetId; - sheetId.Id=(*itStr).first; + sheetId.Id = (*itStr).first; // decide whether or not to use the entry - if (type==sheetId.IdInfos.Type) + if (type == sheetId.IdInfos.Type) { - result.push_back( (CSheetId)sheetId.Id ); - resultFilenames.push_back( (*itStr).second.Ptr ); + result.push_back((CSheetId)sheetId.Id); + resultFilenames.push_back((*itStr).second.Ptr); } } @@ -714,9 +670,9 @@ void CSheetId::buildIdVector(std::vector &result, std::vector &result,const std::string &fileExtension) +void CSheetId::buildIdVector(std::vector &result, const std::string &fileExtension) { - uint32 type=typeFromFileExtension(fileExtension); + uint32 type = typeFromFileExtension(fileExtension); if (type != std::numeric_limits::max()) buildIdVector(result, type); @@ -726,40 +682,40 @@ void CSheetId::buildIdVector(std::vector &result,const std::string &f // buildIdVector // //----------------------------------------------- -void CSheetId::buildIdVector(std::vector &result, std::vector &resultFilenames,const std::string &fileExtension) +void CSheetId::buildIdVector(std::vector &result, std::vector &resultFilenames, const std::string &fileExtension) { - uint32 type=typeFromFileExtension(fileExtension); + uint32 type = typeFromFileExtension(fileExtension); if (type != std::numeric_limits::max()) - buildIdVector(result,resultFilenames, type); + buildIdVector(result, resultFilenames, type); } // buildIdVector // - //----------------------------------------------- // typeFromFileExtension // //----------------------------------------------- uint32 CSheetId::typeFromFileExtension(const std::string &fileExtension) { - if (!_Initialised) init(false); + if (!_Initialised) + init(false); uint i; - for (i=0;i<_FileExtensions.size();i++) - if (toLower(fileExtension)==_FileExtensions[i]) + for (i = 0; i < _FileExtensions.size(); i++) + if (toLower(fileExtension) == _FileExtensions[i]) return i; return std::numeric_limits::max(); } // typeFromFileExtension // - //----------------------------------------------- // fileExtensionFromType // //----------------------------------------------- const std::string &CSheetId::fileExtensionFromType(uint32 type) { - if (!_Initialised) init(false); - nlassert(type < (1<<(NL_SHEET_ID_TYPE_BITS))); + if (!_Initialised) + init(false); + nlassert(type < (1 << (NL_SHEET_ID_TYPE_BITS))); return _FileExtensions[type]; @@ -769,13 +725,13 @@ const std::string &CSheetId::fileExtensionFromType(uint32 type) // build // //----------------------------------------------- -void CSheetId::buildSheetId(uint32 shortId, uint32 type) +void CSheetId::buildSheetId(uint32 shortId, uint32 type) { - nlassert(shortId < (1<::iterator it(_SheetIdToName.find(_Id.Id)); @@ -786,7 +742,6 @@ void CSheetId::buildSheetId(uint32 shortId, uint32 type) else _DebugSheetName = NULL; #endif - } } // NLMISC From 943a3c239ab6777559075df5c71c9762b983e8eb Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 13 Nov 2019 10:28:57 +0800 Subject: [PATCH 04/10] Revert sound sheet id workaround --- .../misc/make_sheet_id/make_sheet_id.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 c6accc1cb..a7f893237 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 @@ -147,10 +147,8 @@ void readFormId( string& outputFileName ) { // get the file type from form name TFormId fid = (*itIF).first; - string fileType; - bool fileTypeGet = getFileType((*itIF).second, fileType); - if((*itIF).second.empty() || (*itIF).second=="." || (*itIF).second==".." || ((*itIF).second[0]=='_' && fileType != "sound") || (*itIF).second.find(".#")==0) + if ((*itIF).second.empty() || (*itIF).second=="." || (*itIF).second==".." || (*itIF).second[0]=='_' || (*itIF).second.find(".#")==0) { map::iterator itErase = itIF; ++itIF; @@ -158,7 +156,8 @@ void readFormId( string& outputFileName ) } else { - if(fileTypeGet) + string fileType; + if (getFileType((*itIF).second, fileType)) { // insert the association (file type/file type id) map::iterator itFT = FileTypeToId.find(fileType); @@ -294,18 +293,18 @@ void makeId( list& dirs ) //----------------------------------------------- void addId( string fileName ) { - string extStr = CFile::getExtension( fileName ); - if(fileName.empty() || fileName=="." || fileName==".." || (fileName[0]=='_' && extStr != "sound") || fileName.find(".#")==0) + if (fileName.empty() || fileName == "." || fileName == ".." || fileName[0] == '_' || fileName.find(".#") == 0) { - //nlinfo("Discarding file '%s'", fileName.c_str()); - NbFilesDiscarded++; - return; + // nlinfo("Discarding file '%s'", fileName.c_str()); + NbFilesDiscarded++; + return; } else { - if( !ExtensionsAllowed.empty() ) + if (!ExtensionsAllowed.empty()) { - if( ExtensionsAllowed.find(extStr) == ExtensionsAllowed.end() ) + string extStr = CFile::getExtension(fileName); + if (ExtensionsAllowed.find(extStr) == ExtensionsAllowed.end()) { NbFilesDiscarded++; return; From a24c758d95d39322918f97c964e77768c290d400 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 13 Nov 2019 10:29:16 +0800 Subject: [PATCH 05/10] Fix path definitions --- code/nel/tools/3d/zviewer/CMakeLists.txt | 2 +- code/nel/tools/misc/make_sheet_id/CMakeLists.txt | 2 +- code/nel/tools/misc/words_dic_qt/CMakeLists.txt | 2 +- code/nel/tools/pacs/build_ig_boxes/CMakeLists.txt | 2 +- code/nel/tools/pacs/build_indoor_rbank/CMakeLists.txt | 2 +- code/nel/tools/pacs/build_rbank/CMakeLists.txt | 2 +- .../nelns/login_system/nel_launcher_windows_ext2/CMakeLists.txt | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/nel/tools/3d/zviewer/CMakeLists.txt b/code/nel/tools/3d/zviewer/CMakeLists.txt index c4222c992..a78e19ad5 100644 --- a/code/nel/tools/3d/zviewer/CMakeLists.txt +++ b/code/nel/tools/3d/zviewer/CMakeLists.txt @@ -6,7 +6,7 @@ ELSE() ADD_EXECUTABLE(zviewer ${SRC}) ENDIF() -ADD_DEFINITIONS(-DNL_ZVIEWER_CFG="\\"${NL_ETC_PREFIX}/\\"") +ADD_DEFINITIONS(-DNL_ZVIEWER_CFG="${NL_ETC_PREFIX}/") TARGET_LINK_LIBRARIES(zviewer nelmisc nel3d) NL_DEFAULT_PROPS(zviewer "NeL, Tools, 3D: Zone Viewer") diff --git a/code/nel/tools/misc/make_sheet_id/CMakeLists.txt b/code/nel/tools/misc/make_sheet_id/CMakeLists.txt index 9c779f08e..2e77e12e3 100644 --- a/code/nel/tools/misc/make_sheet_id/CMakeLists.txt +++ b/code/nel/tools/misc/make_sheet_id/CMakeLists.txt @@ -4,7 +4,7 @@ SOURCE_GROUP("" FILES ${SRC}) ADD_EXECUTABLE(make_sheet_id ${SRC}) -ADD_DEFINITIONS(-DNL_MK_SH_ID_CFG="\\"${NL_ETC_PREFIX}/\\"") +ADD_DEFINITIONS(-DNL_MK_SH_ID_CFG="${NL_ETC_PREFIX}/") TARGET_LINK_LIBRARIES(make_sheet_id nelmisc) NL_DEFAULT_PROPS(make_sheet_id "NeL, Tools, Misc: make_sheet_id") diff --git a/code/nel/tools/misc/words_dic_qt/CMakeLists.txt b/code/nel/tools/misc/words_dic_qt/CMakeLists.txt index c31de9100..5f5c7d4fd 100644 --- a/code/nel/tools/misc/words_dic_qt/CMakeLists.txt +++ b/code/nel/tools/misc/words_dic_qt/CMakeLists.txt @@ -8,7 +8,7 @@ SET(WORDS_DIC_HDR words_dicDlg.h) SET(WORDS_DIC_UIS words_dic_Qt.ui) SET(WORDS_DIC_RCS words_dic_Qt.qrc) -ADD_DEFINITIONS(-DNL_WORDS_DIC_CFG="\\"${NL_ETC_PREFIX}/\\"") +ADD_DEFINITIONS(-DNL_WORDS_DIC_CFG="${NL_ETC_PREFIX}/") IF(WITH_QT) INCLUDE_DIRECTORIES(${QT_INCLUDES}) diff --git a/code/nel/tools/pacs/build_ig_boxes/CMakeLists.txt b/code/nel/tools/pacs/build_ig_boxes/CMakeLists.txt index cfeb3069e..fdabc84ba 100644 --- a/code/nel/tools/pacs/build_ig_boxes/CMakeLists.txt +++ b/code/nel/tools/pacs/build_ig_boxes/CMakeLists.txt @@ -4,7 +4,7 @@ SOURCE_GROUP("" FILES ${SRC}) ADD_EXECUTABLE(build_ig_boxes ${SRC}) -ADD_DEFINITIONS(-DNL_BIB_CFG="\\"${NL_ETC_PREFIX}/\\"") +ADD_DEFINITIONS(-DNL_BIB_CFG="${NL_ETC_PREFIX}/") TARGET_LINK_LIBRARIES(build_ig_boxes nelmisc nelpacs nel3d) NL_DEFAULT_PROPS(build_ig_boxes "NeL, Tools, PACS: build_ig_boxes") diff --git a/code/nel/tools/pacs/build_indoor_rbank/CMakeLists.txt b/code/nel/tools/pacs/build_indoor_rbank/CMakeLists.txt index 4d39639a2..cd4e929fd 100644 --- a/code/nel/tools/pacs/build_indoor_rbank/CMakeLists.txt +++ b/code/nel/tools/pacs/build_indoor_rbank/CMakeLists.txt @@ -4,7 +4,7 @@ SOURCE_GROUP("" FILES ${SRC}) ADD_EXECUTABLE(build_indoor_rbank ${SRC}) -ADD_DEFINITIONS(-DNL_BIRB_CFG="\\"${NL_ETC_PREFIX}/\\"") +ADD_DEFINITIONS(-DNL_BIRB_CFG="${NL_ETC_PREFIX}/") TARGET_LINK_LIBRARIES(build_indoor_rbank nelmisc nelpacs) NL_DEFAULT_PROPS(build_indoor_rbank "NeL, Tools, PACS: build_indoor_rbank") diff --git a/code/nel/tools/pacs/build_rbank/CMakeLists.txt b/code/nel/tools/pacs/build_rbank/CMakeLists.txt index 9b493b762..234178814 100644 --- a/code/nel/tools/pacs/build_rbank/CMakeLists.txt +++ b/code/nel/tools/pacs/build_rbank/CMakeLists.txt @@ -4,7 +4,7 @@ SOURCE_GROUP("" FILES ${SRC}) ADD_EXECUTABLE(build_rbank ${SRC}) -ADD_DEFINITIONS(-DNL_BRB_CFG="\\"${NL_ETC_PREFIX}/\\"") +ADD_DEFINITIONS(-DNL_BRB_CFG="${NL_ETC_PREFIX}/") TARGET_LINK_LIBRARIES(build_rbank nelpacs nel3d nelligo nelmisc) NL_DEFAULT_PROPS(build_rbank "NeL, Tools, PACS: build_rbank") diff --git a/code/nelns/login_system/nel_launcher_windows_ext2/CMakeLists.txt b/code/nelns/login_system/nel_launcher_windows_ext2/CMakeLists.txt index b283624d1..be794545f 100644 --- a/code/nelns/login_system/nel_launcher_windows_ext2/CMakeLists.txt +++ b/code/nelns/login_system/nel_launcher_windows_ext2/CMakeLists.txt @@ -4,7 +4,7 @@ ADD_EXECUTABLE(nel_launcher_ext2 WIN32 ${SRC} nel_launcher.rc) IF(CURL_FOUND) ADD_DEFINITIONS(-DUSE_CURL) ENDIF() -ADD_DEFINITIONS(-DNL_LAUNCHER_CFG="\\"${NL_ETC_PREFIX}/\\"") +ADD_DEFINITIONS(-DNL_LAUNCHER_CFG="${NL_ETC_PREFIX}/") TARGET_LINK_LIBRARIES(nel_launcher_ext2 nelnet From 67bba962d73b9ffe7e2c912f39f2b76745436d32 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 13 Nov 2019 10:32:45 +0800 Subject: [PATCH 06/10] Revert unused change from TStringId to CSheetId for sounds --- code/nel/include/nel/3d/ps_sound.h | 7 +- code/nel/include/nel/3d/u_ps_sound_impl.h | 2 +- .../nel/include/nel/3d/u_ps_sound_interface.h | 3 +- code/nel/include/nel/sound/audio_mixer_user.h | 9 +- code/nel/include/nel/sound/background_sound.h | 14 ++- .../nel/sound/background_sound_manager.h | 2 +- code/nel/include/nel/sound/clustered_sound.h | 5 +- code/nel/include/nel/sound/complex_sound.h | 6 +- code/nel/include/nel/sound/context_sound.h | 16 ++-- code/nel/include/nel/sound/sound.h | 12 +-- .../nel/include/nel/sound/sound_anim_marker.h | 9 +- code/nel/include/nel/sound/sound_bank.h | 10 +- code/nel/include/nel/sound/source_common.h | 1 - code/nel/include/nel/sound/u_audio_mixer.h | 7 +- code/nel/samples/sound/sound_sources/main.cpp | 3 +- .../samples/sound/stream_file/stream_file.cpp | 3 +- .../stream_ogg_vorbis/stream_ogg_vorbis.cpp | 3 +- code/nel/src/3d/ps_sound.cpp | 21 +++-- code/nel/src/sound/audio_mixer_user.cpp | 21 +++-- code/nel/src/sound/background_sound.cpp | 5 +- .../src/sound/background_sound_manager.cpp | 14 ++- code/nel/src/sound/clustered_sound.cpp | 36 +++++--- code/nel/src/sound/complex_sound.cpp | 17 ++-- code/nel/src/sound/complex_source.cpp | 6 +- code/nel/src/sound/context_sound.cpp | 16 ++-- code/nel/src/sound/sound.cpp | 18 +++- code/nel/src/sound/sound_anim_marker.cpp | 10 +- code/nel/src/sound/sound_animation.cpp | 8 +- code/nel/src/sound/sound_bank.cpp | 91 +++++++------------ code/nel/src/sound/stream_file_sound.cpp | 10 +- .../tools/3d/object_viewer/edit_ps_sound.cpp | 8 +- .../tools/3d/object_viewer/object_viewer.cpp | 1 - .../nel/tools/3d/object_viewer/pick_sound.cpp | 4 +- code/nel/tools/3d/object_viewer/pick_sound.h | 8 +- .../tools/3d/object_viewer/sound_anim_dlg.cpp | 10 +- .../tools/3d/object_viewer/sound_system.cpp | 4 +- .../3d/plugin_max/nel_export/DllEntry.cpp | 2 - .../nel_patch_converter/DllEntry.cpp | 2 - .../3d/plugin_max/nel_patch_edit/np_mods.cpp | 2 - .../plugin_max/nel_patch_paint/DllEntry.cpp | 2 - .../nel_vertex_tree_paint/dllmain.cpp | 2 - .../3d/plugin_max/tile_utility/DllEntry.cpp | 2 - .../sound/build_soundbank/build_soundbank.cpp | 4 - code/ryzom/client/src/commands.cpp | 4 +- code/ryzom/client/src/connection.cpp | 2 +- code/ryzom/client/src/init.cpp | 21 ++--- code/ryzom/client/src/sound_manager.cpp | 14 +-- code/ryzom/client/src/sound_manager.h | 7 +- .../georges_plugin_sound/sound_plugin.cpp | 7 +- 49 files changed, 230 insertions(+), 261 deletions(-) diff --git a/code/nel/include/nel/3d/ps_sound.h b/code/nel/include/nel/3d/ps_sound.h index d1c990770..a6da8f031 100644 --- a/code/nel/include/nel/3d/ps_sound.h +++ b/code/nel/include/nel/3d/ps_sound.h @@ -21,7 +21,6 @@ #include "nel/misc/string_mapper.h" #include "nel/3d/ps_located.h" #include "nel/3d/ps_attrib.h" -#include "nel/misc/sheet_id.h" @@ -64,13 +63,13 @@ public: virtual void step(TPSProcessPass pass); /// set the name of the sound - void setSoundName(const NLMISC::CSheetId &soundName) + void setSoundName(const NLMISC::TStringId &soundName) { _SoundName = soundName; } /// get the name of the sound - const NLMISC::CSheetId &getSoundName(void) const + const NLMISC::TStringId &getSoundName(void) const { return _SoundName; } @@ -162,7 +161,7 @@ protected: void removeAllSources(); CPSAttrib _Sounds; - NLMISC::CSheetId _SoundName; + NLMISC::TStringId _SoundName; float _Gain; CPSAttribMaker * _GainScheme; float _Pitch; diff --git a/code/nel/include/nel/3d/u_ps_sound_impl.h b/code/nel/include/nel/3d/u_ps_sound_impl.h index bf45b6387..f5436c842 100644 --- a/code/nel/include/nel/3d/u_ps_sound_impl.h +++ b/code/nel/include/nel/3d/u_ps_sound_impl.h @@ -162,7 +162,7 @@ public: /// inherited from IPSSoundServer - UPSSoundInstance *createSound(const NLMISC::CSheetId &soundName, bool spawned = true) + UPSSoundInstance *createSound(const NLMISC::TStringId &soundName, bool spawned = true) { if (!_AudioMixer) return NULL; diff --git a/code/nel/include/nel/3d/u_ps_sound_interface.h b/code/nel/include/nel/3d/u_ps_sound_interface.h index 82002470b..c382b01bd 100644 --- a/code/nel/include/nel/3d/u_ps_sound_interface.h +++ b/code/nel/include/nel/3d/u_ps_sound_interface.h @@ -19,7 +19,6 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" -#include "nel/misc/sheet_id.h" #include namespace NLMISC @@ -51,7 +50,7 @@ struct UPSSoundServer * \param spawn true if the sound must be spawned e.g it continues after this interface is removed * \param cb useful only for spawned sound, it tells when a spawned sound has been removed */ - virtual UPSSoundInstance *createSound(const NLMISC::CSheetId &soundName, bool spawn = false) = 0; + virtual UPSSoundInstance *createSound(const NLMISC::TStringId &soundName, bool spawn = false) = 0; }; diff --git a/code/nel/include/nel/sound/audio_mixer_user.h b/code/nel/include/nel/sound/audio_mixer_user.h index 4163bf616..03bd42ad8 100644 --- a/code/nel/include/nel/sound/audio_mixer_user.h +++ b/code/nel/include/nel/sound/audio_mixer_user.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -181,7 +180,7 @@ public: // Load environment sounds ; treeRoot can be null if you don't want an access to the envsounds // virtual void loadEnvSounds( const char *filename, UEnvSound **treeRoot=NULL ); /// Get a TSoundId from a name (returns NULL if not found) - virtual TSoundId getSoundId( const NLMISC::CSheetId &name ); + virtual TSoundId getSoundId( const NLMISC::TStringId &name ); /// Gets the group controller for the given group tree path with separator '/', if it doesn't exist yet it will be created. /// Examples: "music", "effects", "dialog", "music/background", "music/loading", "music/player", etcetera @@ -193,7 +192,7 @@ public: * pass a callback function that will be called (if not NULL) just before deleting the spawned * source. */ - virtual USource *createSource( const NLMISC::CSheetId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL); + virtual USource *createSource( const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL); /// Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*) virtual USource *createSource( TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL); /// Add a source which was created by an EnvSound @@ -224,7 +223,7 @@ public: /// Return the names of the sounds (call this method after loadSounds()) - virtual void getSoundNames( std::vector &names ) const; + virtual void getSoundNames( std::vector &names ) const; /// Return the number of mixing tracks (voices) virtual uint getPolyphony() const { return (uint)_Tracks.size(); } /// Return the number of sources instance. @@ -445,7 +444,7 @@ private: /// Witch parameter to control TControledParamId ParamId; /// The controled sounds names. - std::vector SoundNames; + std::vector SoundNames; /// Current parameter value float Value; /// All the sources controled by this variable diff --git a/code/nel/include/nel/sound/background_sound.h b/code/nel/include/nel/sound/background_sound.h index bf83f0413..859035687 100644 --- a/code/nel/include/nel/sound/background_sound.h +++ b/code/nel/include/nel/sound/background_sound.h @@ -64,12 +64,22 @@ public: /// Associtation clas for storage of sound / filter. struct TSoundInfo { - NLMISC::CSheetId SoundName; + NLMISC::TStringId SoundName; UAudioMixer::TBackgroundFlags Filter; void serial(NLMISC::IStream &s) { - SoundName.serialString(s, "sound"); + std::string soundName; + if (s.isReading()) + { + s.serial(soundName); + SoundName = NLMISC::CStringMapper::map(soundName); + } + else + { + soundName = NLMISC::CStringMapper::unmap(SoundName); + s.serial(soundName); + } s.serial(Filter); } }; diff --git a/code/nel/include/nel/sound/background_sound_manager.h b/code/nel/include/nel/sound/background_sound_manager.h index 11f33d2be..ad06f610f 100644 --- a/code/nel/include/nel/sound/background_sound_manager.h +++ b/code/nel/include/nel/sound/background_sound_manager.h @@ -229,7 +229,7 @@ private: struct TSoundData { /// The name of the sound. - NLMISC::CSheetId SoundName; + NLMISC::TStringId SoundName; /// The reference to the sound. CSound *Sound; /// A source instance of the sound (may be NULL). diff --git a/code/nel/include/nel/sound/clustered_sound.h b/code/nel/include/nel/sound/clustered_sound.h index ed674f879..4b28a71ec 100644 --- a/code/nel/include/nel/sound/clustered_sound.h +++ b/code/nel/include/nel/sound/clustered_sound.h @@ -19,7 +19,6 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" -#include "nel/misc/sheet_id.h" #include #include @@ -254,9 +253,9 @@ private: /// The current cluster playing source indexed with sound group id TClusterSoundCont _Sources; - typedef CHashMap TStringSheetMap; + typedef CHashMap TStringStringMap; /// The sound_group to sound assoc - TStringSheetMap _SoundGroupToSound; + TStringStringMap _SoundGroupToSound; }; } // NLSOUND diff --git a/code/nel/include/nel/sound/complex_sound.h b/code/nel/include/nel/sound/complex_sound.h index a55649433..24d889575 100644 --- a/code/nel/include/nel/sound/complex_sound.h +++ b/code/nel/include/nel/sound/complex_sound.h @@ -52,8 +52,8 @@ public: const std::vector &getSoundSeq() const { return _SoundSeq;} const std::vector &getDelaySeq() const { return _DelaySeq;} - NLMISC::CSheetId getSound(uint index) const { return !_Sounds.empty() ? _Sounds[index%_Sounds.size()]:NLMISC::CSheetId::Unknown;} - const std::vector &getSounds() const { return _Sounds;} + NLMISC::TStringId getSound(uint index) const { return !_Sounds.empty() ? _Sounds[index%_Sounds.size()]:0;} + const std::vector &getSounds() const { return _Sounds;} uint32 getFadeLength() const { return _XFadeLength;} @@ -87,7 +87,7 @@ private: virtual float getMaxDistance() const; TPATTERN_MODE _PatternMode; - std::vector _Sounds; + std::vector _Sounds; float _TicksPerSeconds; std::vector _SoundSeq; /// Sequence of delay in millisec. diff --git a/code/nel/include/nel/sound/context_sound.h b/code/nel/include/nel/sound/context_sound.h index eeb29b433..c4ef50ee6 100644 --- a/code/nel/include/nel/sound/context_sound.h +++ b/code/nel/include/nel/sound/context_sound.h @@ -144,7 +144,7 @@ class CContextSoundContainer : public IContextSoundContainer virtual void addSound(CSound *sound, const std::string &baseName) { - const std::string &patternName = sound->getName().toString(); /*NLMISC::CStringMapper::unmap(sound->getName())*/; + const std::string &patternName = NLMISC::CStringMapper::unmap(sound->getName()); nlassert(patternName.size() >= baseName.size()); std::string arg; @@ -183,7 +183,7 @@ class CContextSoundContainer : public IContextSoundContainer if (i != NbJoker) return; - nlassertex(i==NbJoker, ("Error while adding sound '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); + nlassertex(i==NbJoker, ("Error while adding sound '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); sint randomValue = 0; if (UseRandom) @@ -198,7 +198,7 @@ class CContextSoundContainer : public IContextSoundContainer } else if (!arg.empty()) { - nlassertex (!ok, ("Error while adding sound '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); + nlassertex (!ok, ("Error while adding sound '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); // end of the argument. NLMISC::fromString(arg, randomValue); arg.clear(); @@ -210,13 +210,13 @@ class CContextSoundContainer : public IContextSoundContainer // read the potential last arg. if (!arg.empty()) { - nlassertex (!ok, ("Error while adding sound '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); + nlassertex (!ok, ("Error while adding sound '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); // end of the argument. NLMISC::fromString(arg, randomValue); arg.clear(); ok = true; } - nlassertex (ok, ("Error while adding sound '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); + nlassertex (ok, ("Error while adding sound '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); } else @@ -232,9 +232,9 @@ class CContextSoundContainer : public IContextSoundContainer if (!ret.second) { typename THashContextSound::iterator it = _ContextSounds.find(cm); - nlassertex(it != _ContextSounds.end(), ("Error wile adding soudn '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); + nlassertex(it != _ContextSounds.end(), ("Error wile adding soudn '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); - nlwarning("Sound %s has the same context matcher as the sound %s", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/, it->second->getName().toString().c_str() /*NLMISC::CStringMapper::unmap(it->second->getName()).c_str()*/); + nlwarning("Sound %s has the same context matcher as the sound %s", NLMISC::CStringMapper::unmap(sound->getName()).c_str(), NLMISC::CStringMapper::unmap(it->second->getName()).c_str()); } } @@ -260,7 +260,7 @@ class CContextSoundContainer : public IContextSoundContainer typename THashContextSound::const_iterator first(_ContextSounds.begin()), last(_ContextSounds.end()); for (; first != last; ++first) { - subsounds.push_back(std::make_pair(first->second->getName().toString()/*NLMISC::CStringMapper::unmap(first->second->getName())*/, first->second)); + subsounds.push_back(std::make_pair(NLMISC::CStringMapper::unmap(first->second->getName()), first->second)); } } diff --git a/code/nel/include/nel/sound/sound.h b/code/nel/include/nel/sound/sound.h index 403034a8d..f81f6a9b7 100644 --- a/code/nel/include/nel/sound/sound.h +++ b/code/nel/include/nel/sound/sound.h @@ -22,7 +22,6 @@ #include "nel/misc/string_mapper.h" #include "nel/sound/u_source.h" #include "nel/georges/u_form_elm.h" -#include "nel/misc/sheet_id.h" #include namespace NLSOUND { @@ -36,7 +35,7 @@ class CGroupController; /// Sound names hash map //typedef std::hash_map TSoundMap; -typedef CHashMap TSoundMap; +typedef CHashMap TSoundMap; /// Sound names set (for ambiant sounds) typedef std::set TSoundSet; @@ -54,7 +53,7 @@ class CSound friend class CAudioMixerUser; public: /// Factory for specialized sound. - static CSound *createSound(const std::string &name, NLGEORGES::UFormElm& formRoot); + static CSound *createSound(const std::string &filename, NLGEORGES::UFormElm& formRoot); enum TSOUND_TYPE { @@ -100,7 +99,7 @@ public: /// Return the length of the sound in ms virtual uint32 getDuration() = 0; /// Return the name (must be unique) - const NLMISC::CSheetId& getName() const { return _Name; } + const NLMISC::TStringId& getName() const { return _Name; } /// Return the min distance (if detailed()) (default 1.0f if not implemented by sound type) virtual float getMinDistance() const { return _MinDist; } @@ -122,8 +121,7 @@ public: bool operator<( const CSound& otherSound ) const { - //return NLMISC::CStringMapper::unmap(_Name) < NLMISC::CStringMapper::unmap(otherSound._Name); - return _Name.toString() < otherSound._Name.toString(); + return NLMISC::CStringMapper::unmap(_Name) < NLMISC::CStringMapper::unmap(otherSound._Name); } protected: @@ -144,7 +142,7 @@ protected: float _MaxDist; // Sound name. - NLMISC::CSheetId _Name; + NLMISC::TStringId _Name; /// An optional user var controler. NLMISC::TStringId _UserVarControler; diff --git a/code/nel/include/nel/sound/sound_anim_marker.h b/code/nel/include/nel/sound/sound_anim_marker.h index 8a00a1bed..583febbfc 100644 --- a/code/nel/include/nel/sound/sound_anim_marker.h +++ b/code/nel/include/nel/sound/sound_anim_marker.h @@ -20,7 +20,6 @@ #include "nel/misc/string_mapper.h" #include "nel/3d/cluster.h" #include "nel/sound/u_source.h" -#include "nel/misc/sheet_id.h" namespace NLMISC @@ -32,7 +31,7 @@ namespace NLMISC namespace NLSOUND { -typedef std::set TMarkerSoundSet; +typedef std::set TMarkerSoundSet; class UAudioMixer; @@ -51,13 +50,13 @@ public: virtual float getTime() const { return _Time; } /** Add a new sound in the set of to-be-played sounds for this marker */ - virtual void addSound(const NLMISC::CSheetId &soundName); + virtual void addSound(const NLMISC::TStringId &soundName); /** Remove a sound */ - virtual void removeSound(const NLMISC::CSheetId &soundName); + virtual void removeSound(const NLMISC::TStringId &soundName); /** Return the set of sounds of this marker */ - virtual void getSounds(std::vector &sounds); + virtual void getSounds(std::vector &sounds); /** Play all the sounds of this marker */ virtual void play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundContext &context); diff --git a/code/nel/include/nel/sound/sound_bank.h b/code/nel/include/nel/sound/sound_bank.h index 05993bb07..7d3d7e446 100644 --- a/code/nel/include/nel/sound/sound_bank.h +++ b/code/nel/include/nel/sound/sound_bank.h @@ -20,7 +20,6 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" #include "nel/sound/audio_mixer_user.h" -#include "nel/misc/sheet_id.h" #include namespace NLSOUND { @@ -68,16 +67,16 @@ public: bool isLoaded(); /// Return a sound corresponding to a name. - CSound *getSound(const NLMISC::CSheetId &sheetId); + CSound *getSound(const NLMISC::TStringId &name); /// Return the names of the sounds - void getNames( std::vector &sheetIds ); + void getNames( std::vector &names ); /// Return the number of sounds in this bank. uint countSounds(); void addSound(CSound *sound); - void removeSound(const NLMISC::CSheetId &sheetId); + void removeSound(const NLMISC::TStringId &name); private: @@ -89,8 +88,7 @@ private: typedef CHashMap TBufferAssocContainer; /// Sound names hash map // typedef std::hash_map TSoundTable; -// typedef CHashMap TSoundTable; - typedef std::vector TSoundTable; // list the sheets by shortId of the sheetId + typedef CHashMap TSoundTable; /// Assoc from buffer to sound. Used for sound unloading. TBufferAssocContainer _BufferAssoc; diff --git a/code/nel/include/nel/sound/source_common.h b/code/nel/include/nel/sound/source_common.h index 2369b9a7d..96f11aabe 100644 --- a/code/nel/include/nel/sound/source_common.h +++ b/code/nel/include/nel/sound/source_common.h @@ -23,7 +23,6 @@ #include "nel/3d/cluster.h" #include "nel/sound/sound.h" #include "nel/sound/group_controller.h" -#include "nel/misc/sheet_id.h" namespace NLSOUND { diff --git a/code/nel/include/nel/sound/u_audio_mixer.h b/code/nel/include/nel/sound/u_audio_mixer.h index c3059152c..089013797 100644 --- a/code/nel/include/nel/sound/u_audio_mixer.h +++ b/code/nel/include/nel/sound/u_audio_mixer.h @@ -19,7 +19,6 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" -#include "nel/misc/sheet_id.h" #include "nel/sound/u_source.h" #include "nel/sound/u_group_controller.h" #include "nel/ligo/primitive.h" @@ -285,7 +284,7 @@ public: //@} /// Get a TSoundId from a name (returns NULL if not found) - virtual TSoundId getSoundId( const NLMISC::CSheetId &name ) = 0; + virtual TSoundId getSoundId( const NLMISC::TStringId &name ) = 0; /// Gets the group controller for the given group tree path with separator '/', if it doesn't exist yet it will be created. /// Examples: "music", "effects", "dialog", "music/background", "music/loading", "music/player", etcetera @@ -297,7 +296,7 @@ public: * pass a callback function that will be called (if not NULL) just before deleting the spawned * source. */ - virtual USource *createSource(const NLMISC::CSheetId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0; + virtual USource *createSource(const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0; /// Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*) virtual USource *createSource(TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0; @@ -321,7 +320,7 @@ public: //@{ //@name Statistic and utility methods /// Fill a vector with the names of all loaded sounds. - virtual void getSoundNames( std::vector &names ) const = 0; + virtual void getSoundNames( std::vector &names ) const = 0; /// Return the number of mixing tracks (voices) virtual uint getPolyphony() const = 0; /// Return the number of sources diff --git a/code/nel/samples/sound/sound_sources/main.cpp b/code/nel/samples/sound/sound_sources/main.cpp index 75f732b5a..006a5ad41 100644 --- a/code/nel/samples/sound/sound_sources/main.cpp +++ b/code/nel/samples/sound/sound_sources/main.cpp @@ -49,7 +49,6 @@ void Init() { try { - CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/data", true, false); @@ -101,7 +100,7 @@ USource *OnAddSource( const char *name, float x, float y, float z ) /* * Create a source with sound 'name', and set some of its initial properties, if successful */ - USource *source = AudioMixer->createSource(CSheetId(name, "sound")); + USource *source = AudioMixer->createSource( CStringMapper::map(name) ); if ( source != NULL ) { source->setPos( CVector(x,y,z) ); diff --git a/code/nel/samples/sound/stream_file/stream_file.cpp b/code/nel/samples/sound/stream_file/stream_file.cpp index 6362a0414..cd40d6b76 100644 --- a/code/nel/samples/sound/stream_file/stream_file.cpp +++ b/code/nel/samples/sound/stream_file/stream_file.cpp @@ -62,7 +62,6 @@ static void initSample() { if (!INelContext::isContextInitialised()) new CApplicationContext(); - CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/data", true, false); printf("Sample demonstrating OGG playback using stream file .sound sheets."); @@ -98,7 +97,7 @@ static void initSample() //NLMISC::CHTimer::startBench(); - s_Source = s_AudioMixer->createSource(CSheetId("stream_file.sound")); + s_Source = s_AudioMixer->createSource(CStringMapper::map("stream_file")); nlassert(s_Source); s_StreamFileSource = dynamic_cast(s_Source); nlassert(s_StreamFileSource); diff --git a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp index 1f491b21c..6f3f0d19c 100644 --- a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp +++ b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp @@ -59,7 +59,6 @@ static void initSample() { if (!INelContext::isContextInitialised()) new CApplicationContext(); - CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/database/build/", true, false); printf("Sample demonstrating OGG playback using UStreamSource."); @@ -88,7 +87,7 @@ static void initSample() //NLMISC::CHTimer::startBench(); - USource *source = s_AudioMixer->createSource(CSheetId("default_stream.sound")); + USource *source = s_AudioMixer->createSource(CStringMapper::map("default_stream")); nlassert(source); s_StreamSource = dynamic_cast(source); nlassert(s_StreamSource); diff --git a/code/nel/src/3d/ps_sound.cpp b/code/nel/src/3d/ps_sound.cpp index d0b82adb2..1504cd212 100644 --- a/code/nel/src/3d/ps_sound.cpp +++ b/code/nel/src/3d/ps_sound.cpp @@ -49,7 +49,7 @@ CPSSound::CPSSound() : _Gain(1.f), { NL_PS_FUNC(CPSSound_CPSSound) if (CParticleSystem::getSerializeIdentifierFlag()) _Name = std::string("sound"); - _SoundName = NLMISC::CSheetId::Unknown /*NLMISC::CStringMapper::emptyId()*/; + _SoundName = NLMISC::CStringMapper::emptyId(); } // *************************************************************************************************** @@ -270,13 +270,18 @@ void CPSSound::serial(NLMISC::IStream &f) // FIXME: CPSSound is reserialized from the _ParticleSystemProto // cache when a non-_Shared particle system is instanced, this - // causes unnecessary sheet id lookups from string. - // SLN1: Serialize as uint32, but this requires the editor to know - // the correct sheet id (and thus requires a built sheet_id.bin). - // SLN2: Create a tool that reserializes all ps with sound sheet id - // instead of sheet names, based on a global flag, and serialize - // a flag that specifies if the ps is serialized with id or name. - _SoundName.serialString(f, "sound"); + // causes unnecessary id lookups from string. + if (f.isReading()) + { + std::string soundName; + f.serial(soundName); + _SoundName = NLMISC::CStringMapper::map(soundName); + } + else + { + std::string soundName = NLMISC::CStringMapper::unmap(_SoundName); + f.serial(soundName); + } sint32 nbSounds; bool hasScheme; diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 7ea0e5d6e..23f72644c 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -23,7 +23,6 @@ #include "nel/misc/command.h" #include "nel/misc/file.h" #include "nel/misc/path.h" -#include "nel/misc/sheet_id.h" #include "nel/georges/u_form_loader.h" #include "nel/georges/u_form_elm.h" @@ -1058,8 +1057,9 @@ public: for (uint i=0; igetArrayValue(soundName, i); - nlassert(soundName.find(".sound") != std::string::npos); - cs.SoundNames.push_back(CSheetId(soundName)); + soundName = soundName.substr(0, soundName.find(".sound")); + + cs.SoundNames.push_back(CStringMapper::map(soundName)); } if (!cs.SoundNames.empty()) @@ -1109,7 +1109,7 @@ void CAudioMixerUser::initUserVar() TUserVarControlsContainer::iterator first(_UserVarControls.begin()), last(_UserVarControls.end()); for(; first != last; ++first) { - std::vector::iterator first2(first->second.SoundNames.begin()), last2(first->second.SoundNames.end()); + std::vector::iterator first2(first->second.SoundNames.begin()), last2(first->second.SoundNames.end()); for (; first2 != last2; ++first2) { CSound *sound = getSoundId(*first2); @@ -1140,7 +1140,7 @@ void CAudioMixerUser::CControledSources::serial(NLMISC::IStream &s) for (uint i=0; igetSound(name); } @@ -1902,7 +1902,7 @@ retrySound: if (invalid) { - nlwarning("The sound %s contain an infinite recursion !", id->getName().toString().c_str()/*CStringMapper::unmap(id->getName()).c_str()*/); + nlwarning("The sound %s contain an infinite recursion !", CStringMapper::unmap(id->getName()).c_str()); return NULL; } @@ -2043,7 +2043,7 @@ retrySound: // ****************************************************************** -USource *CAudioMixerUser::createSource( const NLMISC::CSheetId &name, bool spawn, TSpawnEndCallback cb, void *userParam, NL3D::CCluster *cluster, CSoundContext *context, UGroupController *groupController) +USource *CAudioMixerUser::createSource( const NLMISC::TStringId &name, bool spawn, TSpawnEndCallback cb, void *userParam, NL3D::CCluster *cluster, CSoundContext *context, UGroupController *groupController) { return createSource( getSoundId( name ), spawn, cb, userParam, cluster, context, groupController); } @@ -2170,7 +2170,7 @@ bool CAudioMixerUser::unloadSampleBank(const std::string &name) // ****************************************************************** -void CAudioMixerUser::getSoundNames( std::vector &names ) const +void CAudioMixerUser::getSoundNames( std::vector &names ) const { _SoundBank->getNames(names); } @@ -2320,6 +2320,7 @@ void CAudioMixerUser::getLoadedSampleBankInfo(std::vectorgetValueByName(soundName, "Sound"); - nlassert(soundName.find(".sound") != std::string::npos); - sound.SoundName = NLMISC::CSheetId(soundName); + sound.SoundName = CStringMapper::map(CFile::getFilenameWithoutExtension(soundName)); // Read the environnement flag. @@ -134,7 +133,7 @@ void CBackgroundSound::getSubSoundList(std::vectorgetSoundId(first->SoundName); - subsounds.push_back(make_pair(first->SoundName.toString()/*CStringMapper::unmap(first->SoundName)*/, sound)); + subsounds.push_back(make_pair(CStringMapper::unmap(first->SoundName), sound)); } } diff --git a/code/nel/src/sound/background_sound_manager.cpp b/code/nel/src/sound/background_sound_manager.cpp index 4713d03f8..c93e0bab0 100644 --- a/code/nel/src/sound/background_sound_manager.cpp +++ b/code/nel/src/sound/background_sound_manager.cpp @@ -86,7 +86,7 @@ void CBackgroundSoundManager::addSound(const std::string &soundName, uint layerI CAudioMixerUser *mixer = CAudioMixerUser::instance(); TSoundData sd; - sd.SoundName = NLMISC::CSheetId(soundName, "sound"); // note: loaded from .primitive + sd.SoundName = CStringMapper::map(soundName); sd.Sound = mixer->getSoundId(sd.SoundName); sd.Source = 0; @@ -133,7 +133,7 @@ void CBackgroundSoundManager::addSound(const std::string &soundName, uint layerI } else { - nlwarning ("The sound '%s' can't be loaded", sd.SoundName.toString().c_str()/*CStringMapper::unmap(sd.SoundName).c_str()*/); + nlwarning ("The sound '%s' can't be loaded", CStringMapper::unmap(sd.SoundName).c_str()); } } @@ -1431,15 +1431,21 @@ void CBackgroundSoundManager::TBanksData::serial(NLMISC::IStream &s) void CBackgroundSoundManager::TSoundData::serial(NLMISC::IStream &s) { - //std::string str; - SoundName.serialString(s, "sound"); + std::string str; + if (s.isReading()) { CAudioMixerUser *mixer = CAudioMixerUser::instance(); + s.serial(str); + SoundName = NLMISC::CStringMapper::map(str); Sound = mixer->getSoundId(SoundName); Source = NULL; Selected = false; } + else + { + s.serial(const_cast(NLMISC::CStringMapper::unmap(SoundName))); + } s.serial(MinBox); s.serial(MaxBox); s.serial(Surface); diff --git a/code/nel/src/sound/clustered_sound.cpp b/code/nel/src/sound/clustered_sound.cpp index 25f0e5b64..6e62f3176 100644 --- a/code/nel/src/sound/clustered_sound.cpp +++ b/code/nel/src/sound/clustered_sound.cpp @@ -70,7 +70,7 @@ float EAX_MATERIAL_PARAM[] = class CSoundGroupSerializer { public: - std::vector > _SoundGroupAssoc; + std::vector > _SoundGroupAssoc; // load the values using the george sheet (called by GEORGE::loadForm) void readGeorges (const NLMISC::CSmartPtr &form, const std::string &/* name */) @@ -95,9 +95,15 @@ public: item->getValueByName(soundGroup, ".SoundGroup"); item->getValueByName(sound, ".Sound"); - nlassert(sound.find(".sound") != std::string::npos); + string::size_type n = sound.rfind(".sound"); - _SoundGroupAssoc.push_back(make_pair(CStringMapper::map(soundGroup), CSheetId(sound))); + if (n != string::npos) + { + // remove the tailing .sound + sound = sound.substr(0, n); + } + + _SoundGroupAssoc.push_back(make_pair(CStringMapper::map(soundGroup), CStringMapper::map(sound))); } } catch(...) @@ -119,18 +125,24 @@ public: { if (s.isReading()) { - TStringId soundGroup; - CSheetId sound; + std::string soundGroup; + std::string sound; - CStringMapper::serialString(s, soundGroup); - sound.serialString(s, "sound"); + s.serial(soundGroup); + s.serial(sound); - _SoundGroupAssoc.push_back(make_pair(soundGroup, sound)); + _SoundGroupAssoc.push_back(make_pair(CStringMapper::map(soundGroup), CStringMapper::map(sound))); } else { - CStringMapper::serialString(s, _SoundGroupAssoc[i].first); - _SoundGroupAssoc[i].second.serialString(s, "sound"); + std::string soundGroup; + std::string sound; + + soundGroup = CStringMapper::unmap(_SoundGroupAssoc[i].first); + sound = CStringMapper::unmap(_SoundGroupAssoc[i].second); + + s.serial(soundGroup); + s.serial(sound); } } } @@ -277,10 +289,10 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view // nldebug("Searching sound assoc for group [%s]", CStringMapper::unmap(soundGroup).c_str()); - TStringSheetMap::iterator it2(_SoundGroupToSound.find(soundGroup)); + TStringStringMap::iterator it2(_SoundGroupToSound.find(soundGroup)); if (it2 != _SoundGroupToSound.end()) { - NLMISC::CSheetId soundName = it2->second; + NLMISC::TStringId soundName = it2->second; CClusterSound cs; // nldebug("Found the sound [%s] for sound group [%s]", CStringMapper::unmap(soundName).c_str(), CStringMapper::unmap(soundGroup).c_str()); diff --git a/code/nel/src/sound/complex_sound.cpp b/code/nel/src/sound/complex_sound.cpp index 9e0ab2022..30b97347f 100644 --- a/code/nel/src/sound/complex_sound.cpp +++ b/code/nel/src/sound/complex_sound.cpp @@ -19,7 +19,6 @@ #include "nel/misc/path.h" #include "nel/misc/common.h" #include "nel/sound/audio_mixer_user.h" -#include "nel/misc/sheet_id.h" using namespace std; using namespace NLMISC; @@ -64,11 +63,11 @@ void CComplexSound::parseSequence(const std::string &str, std::vector &s void CComplexSound::getSubSoundList(std::vector > &subsounds) const { CAudioMixerUser *mixer = CAudioMixerUser::instance(); - std::vector::const_iterator first(_Sounds.begin()), last(_Sounds.end()); + std::vector::const_iterator first(_Sounds.begin()), last(_Sounds.end()); for (; first != last; ++first) { CSound *sound = mixer->getSoundId(*first); - subsounds.push_back(make_pair((*first).toString()/*CStringMapper::unmap(*first)*/, sound)); + subsounds.push_back(make_pair(CStringMapper::unmap(*first), sound)); } } @@ -84,7 +83,7 @@ uint32 CComplexSound::getDuration() CAudioMixerUser *mixer = CAudioMixerUser::instance(); vector durations; - std::vector::iterator first(_Sounds.begin()), last(_Sounds.end()); + std::vector::iterator first(_Sounds.begin()), last(_Sounds.end()); for (; first != last; ++first) { CSound *sound = mixer->getSoundId(*first); @@ -205,7 +204,7 @@ float CComplexSound::getMaxDistance() const CComplexSound *This = const_cast(this); This->_MaxDist = 0.0f; - std::vector::const_iterator first(_Sounds.begin()), last(_Sounds.end()); + std::vector::const_iterator first(_Sounds.begin()), last(_Sounds.end()); for (; first != last; ++first) { @@ -237,7 +236,7 @@ void CComplexSound::serial(NLMISC::IStream &s) { std::string name; s.serial(name); - _Sounds.push_back(NLMISC::CSheetId(name, "sound")); + _Sounds.push_back(CStringMapper::map(name)); } } else @@ -246,7 +245,7 @@ void CComplexSound::serial(NLMISC::IStream &s) s.serial(nb); for (uint i=0; igetArrayValue(soundname, i)) { - nlassert(soundname.find(".sound") != std::string::npos); - _Sounds.push_back(NLMISC::CSheetId(soundname)); + soundname = CFile::getFilenameWithoutExtension(soundname); + _Sounds.push_back(CStringMapper::map(soundname)); } } } diff --git a/code/nel/src/sound/complex_source.cpp b/code/nel/src/sound/complex_source.cpp index 3caee06f6..86cb29d12 100644 --- a/code/nel/src/sound/complex_source.cpp +++ b/code/nel/src/sound/complex_source.cpp @@ -191,9 +191,9 @@ void CComplexSource::playStuf() case CComplexSound::MODE_ALL_IN_ONE: { // just spanw all the listed source. - const std::vector &sounds = _PatternSound->getSounds(); + const std::vector &sounds = _PatternSound->getSounds(); - std::vector::const_iterator first(sounds.begin()), last(sounds.end()); + std::vector::const_iterator first(sounds.begin()), last(sounds.end()); if (_AllSources.empty()) { @@ -525,7 +525,7 @@ void CComplexSource::onUpdate() else { // no sound after, just set an event at end of current sound to stop the complex sound. - nldebug("Setting last event for sound %s in %u millisec.", _Source1->getSound()->getName().toString().c_str()/*CStringMapper::unmap(_Source1->getSound()->getName()).c_str()*/, _Source1->getSound()->getDuration()); + nldebug("Setting last event for sound %s in %u millisec.", CStringMapper::unmap(_Source1->getSound()->getName()).c_str(), _Source1->getSound()->getDuration()); if (_PatternSound->doFadeOut()) { // set the event to begin fade out. diff --git a/code/nel/src/sound/context_sound.cpp b/code/nel/src/sound/context_sound.cpp index fe2512ac0..932a69f19 100644 --- a/code/nel/src/sound/context_sound.cpp +++ b/code/nel/src/sound/context_sound.cpp @@ -187,7 +187,7 @@ void CContextSound::init() } else { - nlassertex(nbJoker < SoundContextNbArgs, ("Error will trying to play ContextSound '%s'", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/)); + nlassertex(nbJoker < SoundContextNbArgs, ("Error will trying to play ContextSound '%s'", CStringMapper::unmap(_Name).c_str())); fromString(index, contextArgIndex[nbJoker++]); parseArg = false; index.clear(); @@ -195,13 +195,13 @@ void CContextSound::init() } else if (*first == 'r') { - nlassertex(useRandom == false, ("Error will trying to play ContextSound '%s'", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/)); + nlassertex(useRandom == false, ("Error will trying to play ContextSound '%s'", CStringMapper::unmap(_Name).c_str())); useRandom = true; } } else if (*first == '%') { - nlassertex(useRandom == false, ("Error will trying to play ContextSound '%s'", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/)); + nlassertex(useRandom == false, ("Error will trying to play ContextSound '%s'", CStringMapper::unmap(_Name).c_str())); parseArg = true; } } @@ -215,7 +215,7 @@ void CContextSound::init() } else { - nlassertex(nbJoker < SoundContextNbArgs, ("Error will trying to play ContextSound '%s'", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/)); + nlassertex(nbJoker < SoundContextNbArgs, ("Error will trying to play ContextSound '%s'", CStringMapper::unmap(_Name).c_str())); fromString(index, contextArgIndex[nbJoker++]); parseArg = false; } @@ -247,7 +247,7 @@ void CContextSound::init() LM_CASE_CONTAINER_CREATOR(9) LM_CASE_CONTAINER_CREATOR(10) default: - nlwarning("Unsuported number of context argument in context sound '%s'!", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/); + nlwarning("Unsuported number of context argument in context sound '%s'!", CStringMapper::unmap(_Name).c_str()); return; } // cleanup macro @@ -257,14 +257,14 @@ void CContextSound::init() // ok, we have the container, now fill it with the sound { - std::vector allSounds; + std::vector allSounds; // CSoundBank::getSoundNames(allSounds); CAudioMixerUser::instance()->getSoundNames(allSounds); - std::vector::iterator first(allSounds.begin()), last(allSounds.end()); + std::vector::iterator first(allSounds.begin()), last(allSounds.end()); for (; first != last; ++first) { - const std::string &soundName = first->toString()/*CStringMapper::unmap(*first)*/; + const std::string &soundName = CStringMapper::unmap(*first); if (soundName.size() > _BaseName.size()) { uint i; diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index 6c204be10..5963ccc5b 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -133,9 +133,18 @@ void CSound::serial(NLMISC::IStream &s) s.serial(_Direction); s.serial(_Looping); s.serial(_MaxDist); - - _Name.serialString(s, "sound"); - + if (s.isReading()) + { + std::string name; + s.serial(name); + _Name = CStringMapper::map(name); + } + else + { + std::string name = CStringMapper::unmap(_Name); + s.serial(name); + } + nlassert(CGroupControllerRoot::isInitialized()); // not sure #if NLSOUND_SHEET_VERSION_BUILT < 2 if (s.isReading()) _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER); @@ -161,8 +170,7 @@ void CSound::serial(NLMISC::IStream &s) void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root) { // Name - nlassert(filename.find(".sound") != std::string::npos); - _Name = NLMISC::CSheetId(filename); + _Name = CStringMapper::map(CFile::getFilenameWithoutExtension(filename)); // InternalConeAngle uint32 inner; diff --git a/code/nel/src/sound/sound_anim_marker.cpp b/code/nel/src/sound/sound_anim_marker.cpp index b64e02f3c..cf1198280 100644 --- a/code/nel/src/sound/sound_anim_marker.cpp +++ b/code/nel/src/sound/sound_anim_marker.cpp @@ -53,19 +53,19 @@ void CSoundAnimMarker::play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundC // ******************************************************** -void CSoundAnimMarker::addSound(const NLMISC::CSheetId& soundName) +void CSoundAnimMarker::addSound(const NLMISC::TStringId& soundName) { pair inserted; inserted = _Sounds.insert(soundName); if (inserted.second == false) { - nlwarning("Duplicate sound (%s)",/* CStringMapper::unmap(soundName).c_str()*/soundName.toString().c_str()); + nlwarning("Duplicate sound (%s)", CStringMapper::unmap(soundName).c_str()); } } // ******************************************************** -void CSoundAnimMarker::removeSound(const NLMISC::CSheetId &soundName) +void CSoundAnimMarker::removeSound(const NLMISC::TStringId &soundName) { TMarkerSoundSet::iterator iter = _Sounds.find(soundName); if (iter != _Sounds.end()) @@ -74,13 +74,13 @@ void CSoundAnimMarker::removeSound(const NLMISC::CSheetId &soundName) } else { - nlwarning("No sound was removed (%s)", soundName.toString().c_str()/*CStringMapper::unmap(soundName).c_str()*/); + nlwarning("No sound was removed (%s)", CStringMapper::unmap(soundName).c_str()); } } // ******************************************************** -void CSoundAnimMarker::getSounds(vector &sounds) +void CSoundAnimMarker::getSounds(vector &sounds) { sounds.insert(sounds.end(), _Sounds.begin(), _Sounds.end()); diff --git a/code/nel/src/sound/sound_animation.cpp b/code/nel/src/sound/sound_animation.cpp index 1d1f9093a..1f80b6223 100644 --- a/code/nel/src/sound/sound_animation.cpp +++ b/code/nel/src/sound/sound_animation.cpp @@ -73,7 +73,7 @@ void CSoundAnimation::save() { // File stream COFile file; - vector sounds; + vector sounds; // Open the file if (!file.open(_Filename.c_str())) @@ -108,11 +108,11 @@ void CSoundAnimation::save() marker->getSounds(sounds); - vector::iterator iter2; + vector::iterator iter2; for (iter2 = sounds.begin(); iter2 != sounds.end(); iter2++) { xmlNodePtr soundNode = xmlNewChild ( markerNode, NULL, (const xmlChar*)"SOUND", NULL ); - xmlSetProp (soundNode, (const xmlChar*)"name", (const xmlChar*)iter2->toString().c_str() /*CStringMapper::unmap(*iter2).c_str()*/); + xmlSetProp (soundNode, (const xmlChar*)"name", (const xmlChar*) CStringMapper::unmap(*iter2).c_str()); } sounds.clear(); @@ -193,7 +193,7 @@ void CSoundAnimation::load() throw NLMISC::Exception("Invalid sound animation marker"); } - marker->addSound(NLMISC::CSheetId(string(name), "sound")); + marker->addSound(CStringMapper::map(string(name))); xmlFree ((void*)name); diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index 29621d337..5ffc8927b 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -127,16 +127,14 @@ CSoundBank::~CSoundBank() void CSoundBank::addSound(CSound *sound) { - // nlassert(_Sounds.size() > sound->getName().getShortId()); - // nldebug("SOUNDBANK: Add %s", sound->getName().toString().c_str()); - if (_Sounds.size() <= sound->getName().getShortId()) - _Sounds.resize(sound->getName().getShortId() + 1); - _Sounds[sound->getName().getShortId()] = sound; + std::pair ret; + ret = _Sounds.insert(make_pair(sound->getName(), sound)); + nlassert(ret.second); } -void CSoundBank::removeSound(const NLMISC::CSheetId &sheetId) +void CSoundBank::removeSound(const NLMISC::TStringId &name) { - _Sounds[sheetId.getShortId()] = NULL; + _Sounds.erase(name); } @@ -264,59 +262,35 @@ public: void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) { // this structure is fill by the loadForm() function and will contain all you need - std::map container; // load the old way for compatibility + std::map Container; nlassert(!_Loaded); // Just call the GEORGE::loadFrom method to read all available sounds - ::loadForm("sound", packedSheetDir + "sounds.packed_sheets", container, packedSheetUpdate, false); + ::loadForm("sound", packedSheetDir + "sounds.packed_sheets", Container, packedSheetUpdate, false); _Loaded = true; - // get the largest sheet id needed and init the sound bank - uint32 maxShortId = 0; - { - std::map::iterator first(container.begin()), last(container.end()); - for (; first != last; ++first) - { - if (first->second.Sound != 0) - if (first->second.Sound->getName().getShortId() > maxShortId) - maxShortId = first->second.Sound->getName().getShortId(); - } - ++maxShortId; // inc for size = last idx + 1 - if (container.empty()) - { - nlwarning("NLSOUND: No sound sheets have been loaded, missing sound sheet directory or packed sound sheets file"); - } - else - { - nlassert(maxShortId < (container.size() * 8)); // ensure no ridiculous sheet id values - if (maxShortId > _Sounds.size()) - _Sounds.resize(maxShortId); - } - } - // add all the loaded sound in the sound banks + std::map::iterator first(Container.begin()), last(Container.end()); + for (; first != last; ++first) { - std::map::iterator first(container.begin()), last(container.end()); - for (; first != last; ++first) - { - if (first->second.Sound != 0) - addSound(first->second.Sound); - } + if (first->second.Sound != 0) + addSound(first->second.Sound); } - container.clear(); + Container.clear(); } /* * Unload all the sound samples in this bank. */ -void CSoundBank::unload() +void CSoundBank::unload() { nlassert(_Loaded); - for (TSoundTable::size_type i = 0; i < _Sounds.size(); ++i) + TSoundTable::iterator first(_Sounds.begin()), last(_Sounds.end()); + for (; first != last; ++first) { - delete _Sounds[i]; + delete first->second; } _Sounds.clear(); @@ -350,7 +324,7 @@ void CSoundBank::unload() /* * Returns true if the samples in this bank have been loaded. */ -bool CSoundBank::isLoaded() +bool CSoundBank::isLoaded() { return _Loaded; } @@ -358,38 +332,37 @@ bool CSoundBank::isLoaded() /* * Return a sound sample corresponding to a name. */ -CSound* CSoundBank::getSound(const NLMISC::CSheetId &sheetId) +CSound* CSoundBank::getSound(const NLMISC::TStringId &name) { - if (sheetId == NLMISC::CSheetId::Unknown) - return NULL; - - // nlassert(sheetId.getShortId() < _Sounds.size()); - if (sheetId.getShortId() >= _Sounds.size()) + // Find sound + TSoundTable::iterator iter = _Sounds.find(name); + if ( iter == _Sounds.end() ) { - std::string sheetName = sheetId.toString(); - nldebug("NLSOUND: Sound sheet id '%s' exceeds loaded sound sheets", sheetName.c_str()); - return NULL; + return 0; + } + else + { + return (*iter).second; } - - return _Sounds[sheetId.getShortId()]; } /** * Return the names of the sounds */ -void CSoundBank::getNames( std::vector &sheetIds ) +void CSoundBank::getNames( std::vector &names ) { - for (TSoundTable::size_type i = 0; i < _Sounds.size(); ++i) + TSoundTable::const_iterator iter; + for (iter = _Sounds.begin(); iter != _Sounds.end(); ++iter) { - if (_Sounds[i]) - sheetIds.push_back(_Sounds[i]->getName()); + names.push_back((*iter).first); + //nlwarning("getting sound %s", (*iter).first); } } /* * Return the number of buffers in this bank. */ -uint CSoundBank::countSounds() +uint CSoundBank::countSounds() { return (uint)_Sounds.size(); } diff --git a/code/nel/src/sound/stream_file_sound.cpp b/code/nel/src/sound/stream_file_sound.cpp index fbf0c91a1..83641cdf7 100644 --- a/code/nel/src/sound/stream_file_sound.cpp +++ b/code/nel/src/sound/stream_file_sound.cpp @@ -73,13 +73,11 @@ void CStreamFileSound::serial(NLMISC::IStream &s) void CStreamFileSound::setMusicFilePath(const std::string &filePath, bool async, bool loop) { -/*#if !FINAL_VERSION - //_Name = NLMISC::CStringMapper::map(std::string(""); - _Name = NLMISC::CSheetId(std::string(""); +#if !FINAL_VERSION + _Name = NLMISC::CStringMapper::map(std::string(""); #else - //_Name = NLMISC::CStringMapper::map(""); -#endif*/ - _Name = NLMISC::CSheetId("music_channel.sound"); + _Name = NLMISC::CStringMapper::map(""); +#endif _ConeInnerAngle = NLMISC::Pi * 2; _ConeOuterAngle = NLMISC::Pi * 2; _Looping = loop; diff --git a/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp b/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp index d74c1fdf8..78cac0980 100644 --- a/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp +++ b/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp @@ -159,7 +159,7 @@ END_MESSAGE_MAP() void CEditPSSound::OnBrowseSound() { // CPickSound::TNameVect names; - vector names; + vector names; NLSOUND::UAudioMixer *audioMixer = CSoundSystem::getAudioMixer(); @@ -172,7 +172,7 @@ void CEditPSSound::OnBrowseSound() if (ps.DoModal() == IDOK) { - m_SoundName = ps.getName().toString().c_str(); + m_SoundName = NLMISC::CStringMapper::unmap(ps.getName()).c_str(); _Sound->setSoundName(ps.getName()); updateModifiedFlag(); UpdateData(FALSE); @@ -184,7 +184,7 @@ BOOL CEditPSSound::OnInitDialog() CDialog::OnInitDialog(); nlassert(_Sound); - m_SoundName = _Sound->getSoundName().toString().c_str(); + m_SoundName = NLMISC::CStringMapper::unmap(_Sound->getSoundName()).c_str(); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control @@ -195,7 +195,7 @@ void CEditPSSound::OnChangeSoundName() { nlassert(_Sound); UpdateData(); - _Sound->setSoundName(NLMISC::CSheetId(NLMISC::tStrToUtf8(m_SoundName), "sound")); + _Sound->setSoundName(NLMISC::CStringMapper::map(NLMISC::tStrToUtf8(m_SoundName))); updateModifiedFlag(); } diff --git a/code/nel/tools/3d/object_viewer/object_viewer.cpp b/code/nel/tools/3d/object_viewer/object_viewer.cpp index be20979b6..5f1310299 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer/object_viewer.cpp @@ -606,7 +606,6 @@ bool CObjectViewer::initUI (HWND parent) { new NLMISC::CApplicationContext(); nldebug("NeL Object Viewer: initUI"); - NLMISC::CSheetId::initWithoutSheet(); } // The fonts manager diff --git a/code/nel/tools/3d/object_viewer/pick_sound.cpp b/code/nel/tools/3d/object_viewer/pick_sound.cpp index 0877564d2..181fec40d 100644 --- a/code/nel/tools/3d/object_viewer/pick_sound.cpp +++ b/code/nel/tools/3d/object_viewer/pick_sound.cpp @@ -74,7 +74,7 @@ BOOL CPickSound::OnInitDialog() for (TNameVect::iterator it = _Names.begin(); it != _Names.end(); ++it) { - m_NameList.AddString(nlUtf8ToTStr((*it).toString())); + m_NameList.AddString(nlUtf8ToTStr(NLMISC::CStringMapper::unmap(*it).c_str())); } _Timer = SetTimer (1, 100, NULL); @@ -111,7 +111,7 @@ void CPickSound::OnSelchange() nlassert(m_NameList.GetTextLen(m_NameList.GetCurSel()) < 1024); m_NameList.GetText(m_NameList.GetCurSel(), str); - _CurrName = NLMISC::CSheetId(NLMISC::tStrToUtf8(str), "sound"); + _CurrName = NLMISC::CStringMapper::map(NLMISC::tStrToUtf8(str)); } diff --git a/code/nel/tools/3d/object_viewer/pick_sound.h b/code/nel/tools/3d/object_viewer/pick_sound.h index 5331ab912..cbcf74601 100644 --- a/code/nel/tools/3d/object_viewer/pick_sound.h +++ b/code/nel/tools/3d/object_viewer/pick_sound.h @@ -23,7 +23,7 @@ #endif // _MSC_VER > 1000 // pick_sound.h : header file // -#include "nel/misc/sheet_id.h" +#include "nel/misc/string_mapper.h" #include #include @@ -40,11 +40,11 @@ class CPickSound : public CDialog { // Construction public: - typedef std::vector TNameVect; + typedef std::vector TNameVect; CPickSound(const TNameVect &names, CWnd* pParent = NULL); // standard constructor - const NLMISC::CSheetId &getName(void) const { return _CurrName; } + const NLMISC::TStringId &getName(void) const { return _CurrName; } // Dialog Data //{{AFX_DATA(CPickSound) @@ -63,7 +63,7 @@ public: // Implementation protected: TNameVect _Names; - NLMISC::CSheetId _CurrName; + NLMISC::TStringId _CurrName; UINT_PTR _Timer; diff --git a/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp b/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp index 80b0d8507..a212f84fa 100644 --- a/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp @@ -125,18 +125,18 @@ void CSoundAnimDlg::updateSounds() { if (_SelectedMarker != 0) { - vector sounds; + vector sounds; _SelectedMarker->getSounds(sounds); CListBox* list = (CListBox*) GetDlgItem(IDC_SOUND_ANIM_LIST); list->ResetContent(); - vector::iterator iter; + vector::iterator iter; for (iter = sounds.begin(); iter != sounds.end(); iter++) { - list->AddString(nlUtf8ToTStr((*iter).toString())); + list->AddString(nlUtf8ToTStr(CStringMapper::unmap(*iter).c_str())); } list->UpdateData(); @@ -150,7 +150,7 @@ void CSoundAnimDlg::OnAddSound() if (_SelectedMarker != 0) { // CPickSound::TNameVect names; - vector names; + vector names; NLSOUND::UAudioMixer *audioMixer = CSoundSystem::getAudioMixer(); @@ -181,7 +181,7 @@ void CSoundAnimDlg::OnRemoveSound() if (list->GetText(list->GetCurSel(), s) != LB_ERR) { - _SelectedMarker->removeSound(NLMISC::CSheetId(tStrToUtf8(s), "sound")); + _SelectedMarker->removeSound(CStringMapper::map(tStrToUtf8(s))); updateSounds(); } } diff --git a/code/nel/tools/3d/object_viewer/sound_system.cpp b/code/nel/tools/3d/object_viewer/sound_system.cpp index 5a79c3af3..d1c0072ba 100644 --- a/code/nel/tools/3d/object_viewer/sound_system.cpp +++ b/code/nel/tools/3d/object_viewer/sound_system.cpp @@ -168,7 +168,7 @@ void CSoundSystem::play(const string &soundName) { if (_AudioMixer) { - NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CSheetId(soundName, "sound"), true); + NLSOUND::USource *src = _AudioMixer->createSource(CStringMapper::map(soundName), true); if (src) { src->setLooping(false); @@ -187,7 +187,7 @@ USource *CSoundSystem::create(const std::string &soundName) { if (_AudioMixer) { - NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CSheetId(soundName, "sound"), false); + NLSOUND::USource *src = _AudioMixer->createSource(CStringMapper::map(soundName), false); if (src) { src->setLooping(false); diff --git a/code/nel/tools/3d/plugin_max/nel_export/DllEntry.cpp b/code/nel/tools/3d/plugin_max/nel_export/DllEntry.cpp index fcb2317fd..7378fc8ca 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/DllEntry.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/DllEntry.cpp @@ -20,7 +20,6 @@ #include "nel/misc/app_context.h" #include "../nel_3dsmax_shared/nel_3dsmax_shared.h" #include -#include "nel/misc/sheet_id.h" extern ClassDesc2* GetCNelExportDesc(); @@ -35,7 +34,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { new NLMISC::CLibraryContext(GetSharedNelContext()); nldebug("NeL Export: DllMain"); - NLMISC::CSheetId::initWithoutSheet(); } hInstance = hinstDLL; // Hang on to this DLL's instance handle. diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/DllEntry.cpp b/code/nel/tools/3d/plugin_max/nel_patch_converter/DllEntry.cpp index 715e35618..0fe5bc556 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/DllEntry.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/DllEntry.cpp @@ -21,7 +21,6 @@ #include "nel/misc/app_context.h" #include "../nel_3dsmax_shared/nel_3dsmax_shared.h" #include -#include "nel/misc/sheet_id.h" extern ClassDesc2* GetPO2RPODesc(); extern ClassDesc* GetRPODesc(); @@ -45,7 +44,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { new NLMISC::CLibraryContext(GetSharedNelContext()); nldebug("NeL Export: DllMain"); - NLMISC::CSheetId::initWithoutSheet(); } if(fdwReason == DLL_PROCESS_ATTACH) diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp index ec109d320..590bcbae7 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp @@ -18,7 +18,6 @@ #include "../nel_3dsmax_shared/nel_3dsmax_shared.h" #include -#include "nel/misc/sheet_id.h" HINSTANCE hInstance; int controlsInit = FALSE; @@ -33,7 +32,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { new NLMISC::CLibraryContext(GetSharedNelContext()); nldebug("NeL Patch Edit: DllMain"); - NLMISC::CSheetId::initWithoutSheet(); } if (fdwReason == DLL_PROCESS_ATTACH) diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp index a720a5911..3b2ed3bfc 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp @@ -4,7 +4,6 @@ #include "nel/misc/app_context.h" #include "../nel_3dsmax_shared/nel_3dsmax_shared.h" #include -#include "nel/misc/sheet_id.h" HINSTANCE hInstance; int controlsInit = FALSE; @@ -23,7 +22,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { new NLMISC::CLibraryContext(GetSharedNelContext()); nldebug("NeL Patch Paint: DllMain"); - NLMISC::CSheetId::initWithoutSheet(); } hInstance = hinstDLL; diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/dllmain.cpp b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/dllmain.cpp index ad5393cf5..0fdf6db75 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/dllmain.cpp +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/dllmain.cpp @@ -1,7 +1,6 @@ #include "vertex_tree_paint.h" #include "../nel_3dsmax_shared/nel_3dsmax_shared.h" #include -#include "nel/misc/sheet_id.h" HINSTANCE hInstance; @@ -13,7 +12,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { new NLMISC::CLibraryContext(GetSharedNelContext()); nldebug("NeL Vertex Tree Paint: DllMain"); - NLMISC::CSheetId::initWithoutSheet(); } hInstance = hinstDLL; // Hang on to this DLL's instance handle. diff --git a/code/nel/tools/3d/plugin_max/tile_utility/DllEntry.cpp b/code/nel/tools/3d/plugin_max/tile_utility/DllEntry.cpp index eb39f7cb0..fbd53ca37 100644 --- a/code/nel/tools/3d/plugin_max/tile_utility/DllEntry.cpp +++ b/code/nel/tools/3d/plugin_max/tile_utility/DllEntry.cpp @@ -21,7 +21,6 @@ #include "../nel_3dsmax_shared/nel_3dsmax_shared.h" #include #include -#include "nel/misc/sheet_id.h" extern ClassDesc2* GetTile_utilityDesc(); extern ClassDesc* GetRGBAddDesc(); @@ -42,7 +41,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { new NLMISC::CLibraryContext(GetSharedNelContext()); nldebug("NeL Tile Utility: DllMain"); - NLMISC::CSheetId::initWithoutSheet(); } hInstance = hinstDLL; // Hang on to this DLL's instance handle. diff --git a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp index b8a79d9cf..60abe4592 100644 --- a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp +++ b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp @@ -29,7 +29,6 @@ #include #include #include -#include // Project includes // ... @@ -76,9 +75,6 @@ int main(int nNbArg, char **ppArgs) // add search paths CPath::addSearchPath(leveldesignDir, true, false); CPath::addSearchPath(dfnDir, true, false); - - // init sheet_id.bin - NLMISC::CSheetId::initWithoutSheet(); // build the sound bank UAudioMixer::buildSoundBank(exportDir); diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 074079780..cd261b29b 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -5165,14 +5165,14 @@ NLMISC_COMMAND(reloadFogMaps, "Force to reload all the fog maps", "<>") NLMISC_COMMAND(dumpSounds, "Dump names of all loaded sound", "<>") { if (!args.empty()) return false; - std::vector sounds; + std::vector sounds; extern CSoundManager *SoundMngr; if (!SoundMngr) return false; if (!SoundMngr->getMixer()) return false; SoundMngr->getMixer()->getSoundNames(sounds); for(uint k = 0; k < sounds.size(); ++k) { - nlinfo(sounds[k].toString()/*NLMISC::CStringMapper::unmap(sounds[k])*/.c_str()); + nlinfo(NLMISC::CStringMapper::unmap(sounds[k]).c_str()); } return true; } diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index dd776b7fb..0b2ed1439 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -2017,7 +2017,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { string sName = getParam(Params, "name"); - CSheetId id = CSheetId(sName, "sound"); + TStringId id = CStringMapper::map(sName); if (SoundMngr != NULL) SoundMngr->spawnSource(id,CVector(0,0,0)); } diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index d80cfda00..abbf8b6b4 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -1534,19 +1534,6 @@ void postlogInit() // set the primitive context CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig; - { - H_AUTO(InitRZShIdI) - - nmsg = "Initializing sheets..."; - ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); - - // Initialize Sheet IDs. - CSheetId::init (ClientCfg.UpdatePackedSheet); - - initLast = initCurrent; - initCurrent = ryzomGetLocalTime(); - } - { H_AUTO(InitRZSound) @@ -1597,7 +1584,13 @@ void postlogInit() } { - H_AUTO(InitRZSheetL) + H_AUTO(InitRZShIdI) + + nmsg = "Initializing sheets..."; + ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); + + // Initialize Sheet IDs. + CSheetId::init (ClientCfg.UpdatePackedSheet); // load packed sheets nmsg = "Loading sheets..."; diff --git a/code/ryzom/client/src/sound_manager.cpp b/code/ryzom/client/src/sound_manager.cpp index 8a91c81ff..7cc6c3a6f 100644 --- a/code/ryzom/client/src/sound_manager.cpp +++ b/code/ryzom/client/src/sound_manager.cpp @@ -628,17 +628,17 @@ void CSoundManager::init(IProgressCallback *progressCallBack) // add a new source to the world, attached to the specified entity // return 0 if creation failed, sound id if creation was successful //----------------------------------------------- -CSoundManager::TSourceId CSoundManager::addSource( const NLMISC::CSheetId &soundName, const NLMISC::CVector &position, bool play, bool loop, const CEntityId &id) +CSoundManager::TSourceId CSoundManager::addSource(const NLMISC::TStringId &soundName, const NLMISC::CVector &position, bool play, bool loop, const CEntityId &id) { uint32 retValue = 0; // Create a source - USource *pSource = _AudioMixer->createSource( soundName ); + USource *pSource = _AudioMixer->createSource(soundName); // If the source is valid. if(pSource == 0) { - nlwarning("Sound '%s' not found !", /*CStringMapper::unmap(soundName).c_str()*/soundName.toString().c_str()); + nlwarning("Sound '%s' not found !", CStringMapper::unmap(soundName).c_str()); return retValue; } @@ -676,7 +676,7 @@ CSoundManager::TSourceId CSoundManager::addSource( const NLMISC::CSheetId &sound // spawn a new source to the world // return false if creation failed, true if creation was successful //----------------------------------------------- -bool CSoundManager::spawnSource(const NLMISC::CSheetId &soundName, CSoundContext &context) +bool CSoundManager::spawnSource(const NLMISC::TStringId &soundName, CSoundContext &context) { if (!_PlaySound) return false; @@ -687,7 +687,7 @@ bool CSoundManager::spawnSource(const NLMISC::CSheetId &soundName, CSoundContext // If the source is valid. if(pSource == 0) { - nlwarning("Sound '%s' not found !", soundName.toString().c_str()); + nlwarning("Sound '%s' not found !", soundName); return false; } @@ -706,7 +706,7 @@ bool CSoundManager::spawnSource(const NLMISC::CSheetId &soundName, CSoundContext // spawn a new source to the world // return false if creation failed, true if creation was successful //----------------------------------------------- -bool CSoundManager::spawnSource(const NLMISC::CSheetId &soundName, const NLMISC::CVector &position) +bool CSoundManager::spawnSource(const NLMISC::TStringId &soundName, const NLMISC::CVector &position) { if (!_PlaySound) return false; @@ -716,7 +716,7 @@ bool CSoundManager::spawnSource(const NLMISC::CSheetId &soundName, const NLMISC: // If the source is valid. if(pSource == 0) { - nlwarning("Sound '%s' not found !", /*CStringMapper::unmap(soundName).c_str ()*/soundName.toString().c_str()); + nlwarning("Sound '%s' not found !", CStringMapper::unmap(soundName).c_str ()); return false; } diff --git a/code/ryzom/client/src/sound_manager.h b/code/ryzom/client/src/sound_manager.h index e2131e880..1c03824e3 100644 --- a/code/ryzom/client/src/sound_manager.h +++ b/code/ryzom/client/src/sound_manager.h @@ -32,7 +32,6 @@ // sound #include "nel/sound/u_audio_mixer.h" #include "nel/sound/u_listener.h" -#include "nel/misc/sheet_id.h" extern class CSoundManager *SoundMngr; @@ -89,13 +88,13 @@ public: /// Return the audio mixer instance pointer. NLSOUND::UAudioMixer *getMixer(); - TSourceId addSource( const NLMISC::CSheetId &soundName, const NLMISC::CVector &position, bool play = true , bool loop = false, const NLMISC::CEntityId &id = NLMISC::CEntityId::Unknown ); + TSourceId addSource( const NLMISC::TStringId &soundName, const NLMISC::CVector &position, bool play = true , bool loop = false, const NLMISC::CEntityId &id = NLMISC::CEntityId::Unknown ); /// spawn a new source to the world but sound manager don't keep any link and the sound will be automatically deleted when finnished - bool spawnSource (const NLMISC::CSheetId &soundName, NLSOUND::CSoundContext &context); + bool spawnSource (const NLMISC::TStringId &soundName, NLSOUND::CSoundContext &context); /// spawn a new source to the world but sound manager don't keep any link and the sound will be automatically deleted when finnished - bool spawnSource( const NLMISC::CSheetId &soundName, const NLMISC::CVector &position ); + bool spawnSource( const NLMISC::TStringId &soundName, const NLMISC::CVector &position ); /** * remove a source diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp index 47c8ed239..3702c18e5 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp @@ -68,9 +68,6 @@ CSoundPlugin::CSoundPlugin(IEdit *globalInterface) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); - // Initialize without sheet id bin - NLMISC::CSheetId::initWithoutSheet(); - CVector dir; _GlobalInterface = globalInterface; @@ -340,7 +337,7 @@ void CSoundPlugin::setActiveDocument(IEditDocument *pdoc) _Dialog.setName(_Filename); // 1st, try to found the sound in the preloaded sound bank. - _Sound = _Mixer->getSoundId(CSheetId(_Filename, "sound")); + _Sound = _Mixer->getSoundId(CStringMapper::map(_Filename)); if (_Sound == NULL) { // not found, create a new one. @@ -540,7 +537,7 @@ void CSoundPlugin::play(std::string &filename) // point.Name = string("simulation-")+_Sound->getName()+"-000"; region.VPoints.push_back(point); - string name = string("simulation-")+NLMISC::CFile::getFilenameWithoutExtension(_Sound->getName().toString())+"-000"; + string name = string("simulation-")+CStringMapper::unmap(_Sound->getName())+"-000"; if (region.VPoints.back().checkProperty("name")) region.VPoints.back().removePropertyByName("name"); From c635a27722d8ca06173f06f30bebb202e9cf9c6b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 13 Nov 2019 11:55:54 +0800 Subject: [PATCH 07/10] Remove unused sheet init --- code/snowballs2/client/src/snowballs_client.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/code/snowballs2/client/src/snowballs_client.cpp b/code/snowballs2/client/src/snowballs_client.cpp index 28f957589..74f73c564 100644 --- a/code/snowballs2/client/src/snowballs_client.cpp +++ b/code/snowballs2/client/src/snowballs_client.cpp @@ -302,8 +302,6 @@ void initCore() LoadedCore = true; // Seed the randomizer srand(uint(time(0))); - // Sheet Id - CSheetId::initWithoutSheet(); // Temporary for sound // Load configuration file, set paths, extension remapping CConfiguration::init(); // Load language file @@ -524,8 +522,6 @@ void releaseCore() CInternationalization::release(); // Release the configuration CConfiguration::release(); - // Release sheet id - CSheetId::uninit(); // Temporary for sound } } From dd1043eaaec28399aa0013ddf5b5d7e0c32b1ce1 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 13 Nov 2019 13:38:07 +0800 Subject: [PATCH 08/10] Revert inappropriate changes from 29b38937a58ffd06ba64829a49f060ff7c9a2d0a --- code/nel/include/nel/sound/u_stream_source.h | 10 +++++++++- .../tools/sound/build_samplebank/build_samplebank.cpp | 10 +++++++++- code/nel/tools/sound/build_sound/build_sound.cpp | 10 +++++++++- .../tools/sound/build_soundbank/build_soundbank.cpp | 10 +++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/code/nel/include/nel/sound/u_stream_source.h b/code/nel/include/nel/sound/u_stream_source.h index 5a1a0db85..6b0448afb 100644 --- a/code/nel/include/nel/sound/u_stream_source.h +++ b/code/nel/include/nel/sound/u_stream_source.h @@ -1,5 +1,13 @@ +/** +* UStreamSource +* \file u_stream_source.h +* \brief UStreamSource +* \date 2010-01-28 12:58GMT +* \author Jan Boon (Kaetemi) +*/ + // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010 by authors // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/code/nel/tools/sound/build_samplebank/build_samplebank.cpp b/code/nel/tools/sound/build_samplebank/build_samplebank.cpp index 51a3617d5..ef3f7c3f5 100644 --- a/code/nel/tools/sound/build_samplebank/build_samplebank.cpp +++ b/code/nel/tools/sound/build_samplebank/build_samplebank.cpp @@ -1,5 +1,13 @@ +/** +* Build Samplebank +* \file build_samplebank.cpp +* \brief Build Samplebank +* \date 2010-03-06 21:36GMT +* \author Jan Boon (Kaetemi) +*/ + // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010 Jan Boon (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/code/nel/tools/sound/build_sound/build_sound.cpp b/code/nel/tools/sound/build_sound/build_sound.cpp index e5a7a0022..7762c1bf2 100644 --- a/code/nel/tools/sound/build_sound/build_sound.cpp +++ b/code/nel/tools/sound/build_sound/build_sound.cpp @@ -1,5 +1,13 @@ +/** +* Build Sound +* \file build_sound.cpp +* \brief Build Sound +* \date 2009-06-02 21:25GMT +* \author Jan Boon (Kaetemi) +*/ + // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2009 Jan Boon (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp index 60abe4592..f672592e2 100644 --- a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp +++ b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp @@ -1,5 +1,13 @@ +/** +* Build Soundbank +* \file build_soundbank.cpp +* \brief Build Soundbank +* \date 2010-03-06 21:43GMT +* \author Jan Boon (Kaetemi) +*/ + // NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010 Jan Boon (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as From 2faa1d7ab86aff1c11769512fa65ee7293d70b33 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 13 Nov 2019 13:50:03 +0800 Subject: [PATCH 09/10] Only add DFN to search path if not a subdir of the other path --- code/nel/tools/sound/build_sound/build_sound.cpp | 4 +++- code/nel/tools/sound/build_soundbank/build_soundbank.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/sound/build_sound/build_sound.cpp b/code/nel/tools/sound/build_sound/build_sound.cpp index 7762c1bf2..dbb47dd02 100644 --- a/code/nel/tools/sound/build_sound/build_sound.cpp +++ b/code/nel/tools/sound/build_sound/build_sound.cpp @@ -103,7 +103,9 @@ int main(int nNbArg, char **ppArgs) // add search paths CPath::addSearchPath(leveldesignDir, true, false); - CPath::addSearchPath(dfnDir, true, false); + std::string relativeDfnDir = dfnDir; // only add dfn if not a subdir of leveldesignDir + if (!CPath::makePathRelative(leveldesignDir, dfnDir) || relativeDfnDir.size() < 2 || (relativeDfnDir[0] == '.' && relativeDfnDir[1] == '.')) + CPath::addSearchPath(dfnDir, true, false); // create the audio mixer UAudioMixer *audioMixer = UAudioMixer::createAudioMixer(); diff --git a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp index f672592e2..082b08e90 100644 --- a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp +++ b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp @@ -82,7 +82,9 @@ int main(int nNbArg, char **ppArgs) // add search paths CPath::addSearchPath(leveldesignDir, true, false); - CPath::addSearchPath(dfnDir, true, false); + std::string relativeDfnDir = dfnDir; // only add dfn if not a subdir of leveldesignDir + if (!CPath::makePathRelative(leveldesignDir, dfnDir) || relativeDfnDir.size() < 2 || (relativeDfnDir[0] == '.' && relativeDfnDir[1] == '.')) + CPath::addSearchPath(dfnDir, true, false); // build the sound bank UAudioMixer::buildSoundBank(exportDir); From 9307cac83cfc25c43adf44937615c77911c960a6 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 13 Nov 2019 14:26:56 +0800 Subject: [PATCH 10/10] Add samplebank build process --- code/nel/src/sound/audio_mixer_user.cpp | 7 +++- code/nel/tools/build_gamedata/0_setup.py | 21 +++++++++++ .../build_gamedata/configuration/tools.py | 3 ++ .../{sound => samplebank}/0_setup.py | 14 +++---- .../{sound => samplebank}/1_export.py | 6 +-- .../{sound => samplebank}/2_build.py | 37 +++++++++++-------- .../{sound => samplebank}/3_install.py | 17 +++------ .../tools/sound/build_sound/build_sound.cpp | 4 ++ 8 files changed, 68 insertions(+), 41 deletions(-) rename code/nel/tools/build_gamedata/processes/{sound => samplebank}/0_setup.py (81%) mode change 100755 => 100644 rename code/nel/tools/build_gamedata/processes/{sound => samplebank}/1_export.py (94%) mode change 100755 => 100644 rename code/nel/tools/build_gamedata/processes/{sound => samplebank}/2_build.py (59%) mode change 100755 => 100644 rename code/nel/tools/build_gamedata/processes/{sound => samplebank}/3_install.py (70%) mode change 100755 => 100644 diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 23f72644c..fdc6f6e11 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -768,8 +768,11 @@ std::string UAudioMixer::buildSampleBank(const std::vector &sampleL } // Sample number MUST be even - nlassert(mono16Data.size() == (mono16Data.size() & 0xfffffffe)); - nlassert(adpcmData.size() == mono16Data.size() / 2); + // nlassert(mono16Data.size() == (mono16Data.size() & 0xfffffffe)); + if (mono16Data.size() & 1) + nlwarning("Uneven sample numbers, ADPCM will miss a sample. File: %s, Samples: %i, ADPCM Size: %i", + sampleList[j].c_str(), (int)mono16Data.size(), (int)adpcmData.size()); + nlassert(adpcmData.size() == (mono16Data.size() >> 1)); adpcmBuffers[j].swap(adpcmData); mono16Buffers[j].swap(mono16Data); diff --git a/code/nel/tools/build_gamedata/0_setup.py b/code/nel/tools/build_gamedata/0_setup.py index 8eff34131..479121428 100755 --- a/code/nel/tools/build_gamedata/0_setup.py +++ b/code/nel/tools/build_gamedata/0_setup.py @@ -83,6 +83,18 @@ if not args.noconf: DatabaseDirectory except NameError: DatabaseDirectory = "W:/database" + try: + SoundDirectory + except NameError: + SoundDirectory = "V:" + try: + SoundSheetsDirectory + except NameError: + SoundSheetsDirectory = "V:" + try: + SoundSheetsDfnDirectory + except NameError: + SoundSheetsDfnDirectory = "V:/DFN" try: ExportBuildDirectory except NameError: @@ -218,6 +230,9 @@ if not args.noconf: ScriptDirectory = askVar(log, "[IN] Script Directory", os.getcwd().replace("\\", "/")).replace("\\", "/") WorkspaceDirectory = askVar(log, "[IN] Workspace Directory", WorkspaceDirectory).replace("\\", "/") DatabaseDirectory = askVar(log, "[IN] Database Directory", DatabaseDirectory).replace("\\", "/") + SoundDirectory = askVar(log, "[IN] Sound Directory", SoundDirectory).replace("\\", "/") + SoundSheetsDirectory = askVar(log, "[IN] Sound Sheets Directory", SoundSheetsDirectory).replace("\\", "/") + SoundSheetsDfnDirectory = askVar(log, "[IN] Sound Sheets DFN Directory", SoundSheetsDfnDirectory).replace("\\", "/") ExportBuildDirectory = askVar(log, "[OUT] Export Build Directory", ExportBuildDirectory).replace("\\", "/") InstallDirectory = askVar(log, "[OUT] Install Directory", InstallDirectory).replace("\\", "/") ClientDevDirectory = askVar(log, "[OUT] Client Dev Directory", ClientDevDirectory).replace("\\", "/") @@ -301,6 +316,9 @@ if not args.noconf: sf.write("\n") sf.write("# Data build directories\n") sf.write("DatabaseDirectory = \"" + str(DatabaseDirectory) + "\"\n") + sf.write("SoundDirectory = \"" + str(SoundDirectory) + "\"\n") + sf.write("SoundSheetsDirectory = \"" + str(SoundSheetsDirectory) + "\"\n") + sf.write("SoundSheetsDfnDirectory = \"" + str(SoundSheetsDfnDirectory) + "\"\n") sf.write("ExportBuildDirectory = \"" + str(ExportBuildDirectory) + "\"\n") sf.write("\n") sf.write("# Install directories\n") @@ -415,6 +433,9 @@ if not args.noverify: findTool(log, ToolDirectories, MakeSheetIdTool, ToolSuffix) # findTool(log, ToolDirectories, BuildSheetsTool, ToolSuffix) # kaetemi stuff, ignore this # findTool(log, ToolDirectories, BuildSoundTool, ToolSuffix) # kaetemi stuff, ignore this + # findTool(log, ToolDirectories, BuildSoundTool, ToolSuffix) + findTool(log, ToolDirectories, BuildSoundbankTool, ToolSuffix) + findTool(log, ToolDirectories, BuildSamplebankTool, ToolSuffix) findTool(log, ToolDirectories, BuildCoarseMeshTool, ToolSuffix) findTool(log, ToolDirectories, LightmapOptimizerTool, ToolSuffix) findTool(log, ToolDirectories, BuildClodtexTool, ToolSuffix) diff --git a/code/nel/tools/build_gamedata/configuration/tools.py b/code/nel/tools/build_gamedata/configuration/tools.py index c0c962360..67cefdd5b 100755 --- a/code/nel/tools/build_gamedata/configuration/tools.py +++ b/code/nel/tools/build_gamedata/configuration/tools.py @@ -73,6 +73,9 @@ TileEditTool = "tile_edit" MakeSheetIdTool = "make_sheet_id" # BuildSheetsTool = "th_build_sheets" # kaetemi stuff, ignore this # BuildSoundTool = "th_build_sound" # kaetemi stuff, ignore this +# BuildSoundTool = "build_sound" +BuildSoundbankTool = "build_soundbank" +BuildSamplebankTool = "build_samplebank" BuildCoarseMeshTool = "build_coarse_mesh" LightmapOptimizerTool = "lightmap_optimizer" BuildClodtexTool = "build_clodtex" diff --git a/code/nel/tools/build_gamedata/processes/sound/0_setup.py b/code/nel/tools/build_gamedata/processes/samplebank/0_setup.py old mode 100755 new mode 100644 similarity index 81% rename from code/nel/tools/build_gamedata/processes/sound/0_setup.py rename to code/nel/tools/build_gamedata/processes/samplebank/0_setup.py index 178a810ae..0c9c6c856 --- a/code/nel/tools/build_gamedata/processes/sound/0_setup.py +++ b/code/nel/tools/build_gamedata/processes/samplebank/0_setup.py @@ -1,11 +1,11 @@ #!/usr/bin/python # # \file 0_setup.py -# \brief Setup sound +# \brief Setup samplebank # \date 2009-06-03 10:47GMT # \author Jan Boon (Kaetemi) # Python port of game data build pipeline. -# Setup sound +# Setup samplebank # # NeL - MMORPG Framework # Copyright (C) 2009-2014 by authors @@ -38,29 +38,25 @@ from directories import * printLog(log, "") printLog(log, "-------") -printLog(log, "--- Setup sound") +printLog(log, "--- Setup samplebank") printLog(log, "-------") printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time()))) printLog(log, "") # Setup source directories printLog(log, ">>> Setup source directories <<<") -mkPath(log, LeveldesignDirectory) -mkPath(log, LeveldesignDfnDirectory) -mkPath(log, DatabaseDirectory + "/" + SoundSamplebanksSourceDirectory) +mkPath(log, SoundDirectory + "/" + SoundSamplebanksSourceDirectory) # Setup export directories printLog(log, ">>> Setup export directories <<<") # Setup build directories printLog(log, ">>> Setup build directories <<<") -mkPath(log, ExportBuildDirectory + "/" + SoundSheetsBuildDirectory) mkPath(log, ExportBuildDirectory + "/" + SoundSamplebanksBuildDirectory) # Setup client directories printLog(log, ">>> Setup client directories <<<") -mkPath(log, InstallDirectory + "/" + SoundSheetsInstallDirectory) -mkPath(log, InstallDirectory + "/" + SoundSamplebanksInstallDirectory) +mkPath(log, InstallDirectory + "/" + SoundInstallDirectory) log.close() diff --git a/code/nel/tools/build_gamedata/processes/sound/1_export.py b/code/nel/tools/build_gamedata/processes/samplebank/1_export.py old mode 100755 new mode 100644 similarity index 94% rename from code/nel/tools/build_gamedata/processes/sound/1_export.py rename to code/nel/tools/build_gamedata/processes/samplebank/1_export.py index 4fd98abb4..9760458b9 --- a/code/nel/tools/build_gamedata/processes/sound/1_export.py +++ b/code/nel/tools/build_gamedata/processes/samplebank/1_export.py @@ -1,11 +1,11 @@ #!/usr/bin/python # # \file 1_export.py -# \brief Export sound +# \brief Export samplebank # \date 2009-06-03 10:47GMT # \author Jan Boon (Kaetemi) # Python port of game data build pipeline. -# Export sound +# Export samplebank # # NeL - MMORPG Framework # Copyright (C) 2009-2014 by authors @@ -38,7 +38,7 @@ from directories import * printLog(log, "") printLog(log, "-------") -printLog(log, "--- Export sound") +printLog(log, "--- Export samplebank") printLog(log, "-------") printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time()))) printLog(log, "") diff --git a/code/nel/tools/build_gamedata/processes/sound/2_build.py b/code/nel/tools/build_gamedata/processes/samplebank/2_build.py old mode 100755 new mode 100644 similarity index 59% rename from code/nel/tools/build_gamedata/processes/sound/2_build.py rename to code/nel/tools/build_gamedata/processes/samplebank/2_build.py index 56abeedd7..447edd468 --- a/code/nel/tools/build_gamedata/processes/sound/2_build.py +++ b/code/nel/tools/build_gamedata/processes/samplebank/2_build.py @@ -1,11 +1,11 @@ #!/usr/bin/python # # \file 2_build.py -# \brief Build sound +# \brief Build samplebank # \date 2009-06-03 10:47GMT # \author Jan Boon (Kaetemi) # Python port of game data build pipeline. -# Build sound +# Build samplebank # # NeL - MMORPG Framework # Copyright (C) 2009-2014 by authors @@ -38,28 +38,33 @@ from directories import * printLog(log, "") printLog(log, "-------") -printLog(log, "--- Build sound") +printLog(log, "--- Build samplebank") printLog(log, "-------") printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time()))) printLog(log, "") # Find tools -BuildSound = findTool(log, ToolDirectories, BuildSoundTool, ToolSuffix) +BuildSamplebank = findTool(log, ToolDirectories, BuildSamplebankTool, ToolSuffix) printLog(log, "") -# For each sound directory -printLog(log, ">>> Build sound <<<") -if BuildSound == "": - toolLogFail(log, BuildSoundTool, ToolSuffix) +# For each samplebank directory +printLog(log, ">>> Build samplebank <<<") +if BuildSamplebank == "": + toolLogFail(log, BuildSamplebankTool, ToolSuffix) else: - mkPath(log, LeveldesignDirectory) - mkPath(log, LeveldesignDfnDirectory) - mkPath(log, DatabaseDirectory + "/" + SoundSamplebanksSourceDirectory) - mkPath(log, ExportBuildDirectory + "/" + SoundSheetsBuildDirectory) - mkPath(log, ExportBuildDirectory + "/" + SoundSamplebanksBuildDirectory) - subprocess.call([ BuildSound, LeveldesignDirectory, LeveldesignDfnDirectory, DatabaseDirectory + "/" + SoundSamplebanksSourceDirectory, ExportBuildDirectory + "/" + SoundSheetsBuildDirectory ]) - moveFilesExtNoTree(log, DatabaseDirectory + "/" + SoundSamplebanksSourceDirectory, ExportBuildDirectory + "/" + SoundSamplebanksBuildDirectory, ".sample_bank") -printLog(log, "") + sourcePath = SoundDirectory + "/" + SoundSamplebanksSourceDirectory + buildPath = ExportBuildDirectory + "/" + SoundSamplebanksBuildDirectory + mkPath(log, sourcePath) + mkPath(log, buildPath) + for dir in os.listdir(sourcePath): + dirPath = sourcePath + "/" + dir + if (os.path.isdir(dirPath)) and dir != ".svn" and dir != "*.*": + samplebankPath = buildPath + "/" + dir + ".sample_bank" + if needUpdateDirNoSubdirFile(log, dirPath, samplebankPath): + # build_samplebank + subprocess.call([ BuildSamplebank, dirPath, buildPath, dir ]) + else: + printLog(log, "SKIP " + samplebankPath) log.close() diff --git a/code/nel/tools/build_gamedata/processes/sound/3_install.py b/code/nel/tools/build_gamedata/processes/samplebank/3_install.py old mode 100755 new mode 100644 similarity index 70% rename from code/nel/tools/build_gamedata/processes/sound/3_install.py rename to code/nel/tools/build_gamedata/processes/samplebank/3_install.py index dc32c30e1..104f76681 --- a/code/nel/tools/build_gamedata/processes/sound/3_install.py +++ b/code/nel/tools/build_gamedata/processes/samplebank/3_install.py @@ -1,11 +1,11 @@ #!/usr/bin/python # # \file 3_install.py -# \brief Install sound +# \brief Install samplebank # \date 2009-06-03 10:47GMT # \author Jan Boon (Kaetemi) # Python port of game data build pipeline. -# Install sound +# Install samplebank # # NeL - MMORPG Framework # Copyright (C) 2009-2014 by authors @@ -38,20 +38,15 @@ from directories import * printLog(log, "") printLog(log, "-------") -printLog(log, "--- Install sound") +printLog(log, "--- Install samplebank") printLog(log, "-------") printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time()))) printLog(log, "") -printLog(log, ">>> Install sound packed_sheets <<<") -mkPath(log, ExportBuildDirectory + "/" + SoundSheetsBuildDirectory) -mkPath(log, InstallDirectory + "/" + SoundSheetsInstallDirectory) -copyFilesExtNoTreeIfNeeded(log, ExportBuildDirectory + "/" + SoundSheetsBuildDirectory, InstallDirectory + "/" + SoundSheetsInstallDirectory, ".packed_sheets") - -printLog(log, ">>> Install sound samplebanks <<<") +printLog(log, ">>> Install samplebank <<<") mkPath(log, ExportBuildDirectory + "/" + SoundSamplebanksBuildDirectory) -mkPath(log, InstallDirectory + "/" + SoundSamplebanksInstallDirectory) -copyFilesExtNoTreeIfNeeded(log, ExportBuildDirectory + "/" + SoundSamplebanksBuildDirectory, InstallDirectory + "/" + SoundSamplebanksInstallDirectory, ".sample_bank") +mkPath(log, InstallDirectory + "/" + SoundInstallDirectory) +copyFilesExtNoTreeIfNeeded(log, ExportBuildDirectory + "/" + SoundSamplebanksBuildDirectory, InstallDirectory + "/" + SoundInstallDirectory, ".sample_bank") printLog(log, "") log.close() diff --git a/code/nel/tools/sound/build_sound/build_sound.cpp b/code/nel/tools/sound/build_sound/build_sound.cpp index dbb47dd02..bacdf7664 100644 --- a/code/nel/tools/sound/build_sound/build_sound.cpp +++ b/code/nel/tools/sound/build_sound/build_sound.cpp @@ -56,6 +56,10 @@ namespace { // your build script system. // //////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////// +// this tool is deprecated by build_samplebank and build_soundbank // +///////////////////////////////////////////////////////////////////// + int main(int nNbArg, char **ppArgs) { // create debug stuff