mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-25 16:26:18 +00:00
Added: Temporary workaround for using sound sheet id without updated sheet id bin
This commit is contained in:
parent
7b6e88dff9
commit
bc26f93893
1 changed files with 45 additions and 1 deletions
|
@ -44,6 +44,12 @@ std::map<std::string, uint32> CSheetId::_DevTypeNameToId;
|
|||
std::vector<std::vector<std::string> > CSheetId::_DevSheetIdToName;
|
||||
std::map<std::string, uint32> 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<std::string, uint32>::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<std::string, uint32>::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<uint32>::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<std::string>());
|
||||
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("<CSheetId::toString> 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue