From 497ae4d09baf9f2a3407fcc93ca698f2adf9a27e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 3 Jun 2012 15:57:57 +0200 Subject: [PATCH] Added: Temporary workaround for using sound sheet id without updated sheet id bin --HG-- branch : sound_dev --- code/nel/src/misc/sheet_id.cpp | 46 +++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index b9811c201..72549de42 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -44,6 +44,12 @@ std::map CSheetId::_DevTypeNameToId; 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; } +#endif + const CSheetId CSheetId::Unknown(0); void CSheetId::cbFileChange (const std::string &filename) @@ -135,7 +141,7 @@ bool CSheetId::buildSheetId(const std::string& sheetName) if (it == _DevSheetNameToId.end()) { // Create a new dynamic sheet ID. - nldebug("SHEETID: Creating a new dynamic sheet id for '%s'", sheetName.c_str()); + nldebug("SHEETID: Creating a dynamic sheet id for '%s'", sheetName.c_str()); std::string sheetType = CFile::getExtension(sheetNameLc); std::string sheetName = CFile::getFilenameWithoutExtension(sheetNameLc); std::map::iterator tit = _DevTypeNameToId.find(sheetType); @@ -192,6 +198,27 @@ bool CSheetId::buildSheetId(const std::string& sheetName) 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()) + { + uint32 typeId = typeFromFileExtension("sound"); + nldebug("SHEETID: Creating a temporary sheet id for '%s'", sheetName.c_str()); + _DevSheetIdToName[0].push_back(sheetName); + _Id.IdInfos.Type = typeId; + _Id.IdInfos.Id = _DevSheetIdToName[0].size() - 1; + _DevSheetNameToId[sheetNameLc] = _Id.Id; + return true; + } + _Id.Id = it->second; + return true; + } +#endif + return false; } @@ -345,6 +372,15 @@ void CSheetId::init(bool 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"); + _FileExtensions.push_back("sound"); + _DevSheetIdToName.push_back(std::vector()); + a_NoSoundSheetId = true; + } +#endif } // init // @@ -501,6 +537,12 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const } else { +#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID + if (a_NoSoundSheetId && _FileExtensions[_Id.IdInfos.Type] == "sound") + { + 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); @@ -543,6 +585,8 @@ void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) } else { + // if this assert fails, you may be using an outdated id bin + nlassert(*this != CSheetId::Unknown); std::string sheetName = toString(); f.serial(sheetName); }