mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 01:06:19 +00:00
Changed: Reserve sheet id with short id 0 for unknown sheet for new sheet types
This commit is contained in:
parent
72fc210dd0
commit
08e3f3c180
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>());
|
||||
typeId = _FileExtensions.size() - 1;
|
||||
_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
|
||||
{
|
||||
typeId = tit->second;
|
||||
_Id.IdInfos.Type = typeId;
|
||||
}
|
||||
_DevSheetIdToName[typeId].push_back(sheetName);
|
||||
_Id.IdInfos.Type = typeId;
|
||||
_DevSheetIdToName[typeId].push_back(sheetNameLc);
|
||||
_Id.IdInfos.Id = _DevSheetIdToName[typeId].size() - 1;
|
||||
// nldebug("SHEETID: Type %i, id %i, sheetid %i", _Id.IdInfos.Type, _Id.IdInfos.Id, _Id.Id);
|
||||
_DevSheetNameToId[sheetNameLc] = _Id.Id;
|
||||
|
@ -381,9 +386,16 @@ void CSheetId::init(bool removeUnknownSheet)
|
|||
if (typeFromFileExtension("sound") == std::numeric_limits<uint32>::max())
|
||||
{
|
||||
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));
|
||||
_FileExtensions[((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)] == "sound";
|
||||
_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;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -336,15 +336,26 @@ void addId( string fileName )
|
|||
if( firstFreeFileTypeId == -1 )
|
||||
{
|
||||
nlwarning("MORE THAN 256 FILE TYPES!!!!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileTypeToId.insert( make_pair(fileType,(uint8)firstFreeFileTypeId) );
|
||||
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.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);
|
||||
NbTypesAdded++;
|
||||
|
|
Loading…
Reference in a new issue