mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-14 11:19:03 +00:00
Changed: Reserve sheet id with short id 0 for unknown sheet for new sheet types
This commit is contained in:
parent
2a56fa9750
commit
eb6050795e
2 changed files with 27 additions and 4 deletions
|
@ -157,13 +157,18 @@ bool CSheetId::buildSheetId(const std::string& sheetName)
|
||||||
_DevSheetIdToName.push_back(std::vector<std::string>());
|
_DevSheetIdToName.push_back(std::vector<std::string>());
|
||||||
typeId = _FileExtensions.size() - 1;
|
typeId = _FileExtensions.size() - 1;
|
||||||
_DevTypeNameToId[sheetType] = typeId;
|
_DevTypeNameToId[sheetType] = typeId;
|
||||||
|
std::string unknownNewType = std::string("unknown." + sheetType);
|
||||||
|
_DevSheetIdToName[typeId].push_back(unknownNewType);
|
||||||
|
_Id.IdInfos.Type = typeId;
|
||||||
|
_Id.IdInfos.Id = _DevSheetIdToName[typeId].size() - 1;
|
||||||
|
_DevSheetNameToId[unknownNewType] = _Id.Id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
typeId = tit->second;
|
typeId = tit->second;
|
||||||
|
_Id.IdInfos.Type = typeId;
|
||||||
}
|
}
|
||||||
_DevSheetIdToName[typeId].push_back(sheetName);
|
_DevSheetIdToName[typeId].push_back(sheetNameLc);
|
||||||
_Id.IdInfos.Type = typeId;
|
|
||||||
_Id.IdInfos.Id = _DevSheetIdToName[typeId].size() - 1;
|
_Id.IdInfos.Id = _DevSheetIdToName[typeId].size() - 1;
|
||||||
// nldebug("SHEETID: Type %i, id %i, sheetid %i", _Id.IdInfos.Type, _Id.IdInfos.Id, _Id.Id);
|
// nldebug("SHEETID: Type %i, id %i, sheetid %i", _Id.IdInfos.Type, _Id.IdInfos.Id, _Id.Id);
|
||||||
_DevSheetNameToId[sheetNameLc] = _Id.Id;
|
_DevSheetNameToId[sheetNameLc] = _Id.Id;
|
||||||
|
@ -381,9 +386,16 @@ void CSheetId::init(bool removeUnknownSheet)
|
||||||
if (typeFromFileExtension("sound") == std::numeric_limits<uint32>::max())
|
if (typeFromFileExtension("sound") == std::numeric_limits<uint32>::max())
|
||||||
{
|
{
|
||||||
nlwarning("SHEETID: Loading without known sound sheet id, please update sheet_id.bin with .sound sheets");
|
nlwarning("SHEETID: Loading without known sound sheet id, please update sheet_id.bin with .sound sheets");
|
||||||
|
uint32 typeId = ((1 << (NL_SHEET_ID_TYPE_BITS)) - 1);
|
||||||
nlassert(_FileExtensions.size() == 1 << (NL_SHEET_ID_TYPE_BITS));
|
nlassert(_FileExtensions.size() == 1 << (NL_SHEET_ID_TYPE_BITS));
|
||||||
_FileExtensions[((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)] == "sound";
|
_FileExtensions[((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)] == "sound";
|
||||||
_DevSheetIdToName.push_back(std::vector<std::string>());
|
_DevSheetIdToName.push_back(std::vector<std::string>());
|
||||||
|
_DevSheetIdToName[0].push_back("unknown.sound");
|
||||||
|
TSheetId id;
|
||||||
|
id.IdInfos.Type = typeId;
|
||||||
|
id.IdInfos.Id = _DevSheetIdToName[0].size() - 1;
|
||||||
|
nlassert(id.IdInfos.Id == 0);
|
||||||
|
_DevSheetNameToId["unknown.sound"] = id.Id;
|
||||||
a_NoSoundSheetId = true;
|
a_NoSoundSheetId = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -336,15 +336,26 @@ void addId( string fileName )
|
||||||
if( firstFreeFileTypeId == -1 )
|
if( firstFreeFileTypeId == -1 )
|
||||||
{
|
{
|
||||||
nlwarning("MORE THAN 256 FILE TYPES!!!!");
|
nlwarning("MORE THAN 256 FILE TYPES!!!!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FileTypeToId.insert( make_pair(fileType,(uint8)firstFreeFileTypeId) );
|
FileTypeToId.insert( make_pair(fileType,(uint8)firstFreeFileTypeId) );
|
||||||
IdToFileType.insert( make_pair((uint8)firstFreeFileTypeId,fileType) );
|
IdToFileType.insert( make_pair((uint8)firstFreeFileTypeId,fileType) );
|
||||||
TypeToLastId.insert( make_pair((uint8)firstFreeFileTypeId,0) );
|
|
||||||
|
|
||||||
|
// Reserve id 0 for unknown.newtype.
|
||||||
|
// User may supply a sheet called unknown.newtype
|
||||||
|
// that can safely be used as a fallback when a
|
||||||
|
// requested sheet does not exist.
|
||||||
|
// Only for newly added sheet types.
|
||||||
fid.FormIDInfos.Type = (uint8)firstFreeFileTypeId;
|
fid.FormIDInfos.Type = (uint8)firstFreeFileTypeId;
|
||||||
fid.FormIDInfos.Id = 0;
|
fid.FormIDInfos.Id = 0;
|
||||||
|
std::string unknownNewType = std::string("unknown." + fileType);
|
||||||
|
FormToId.insert(make_pair(unknownNewType, fid));
|
||||||
|
IdToForm.insert(make_pair(fid, unknownNewType));
|
||||||
|
|
||||||
|
TypeToLastId.insert( make_pair((uint8)firstFreeFileTypeId,1) );
|
||||||
|
fid.FormIDInfos.Id = 1;
|
||||||
|
|
||||||
nlinfo("Adding file type '%s' with id %d", fileType.c_str(), firstFreeFileTypeId);
|
nlinfo("Adding file type '%s' with id %d", fileType.c_str(), firstFreeFileTypeId);
|
||||||
NbTypesAdded++;
|
NbTypesAdded++;
|
||||||
|
|
Loading…
Reference in a new issue