Core/DataStores: Allow loading encrypted sections when key is known when reading from casc storage

Closes #24456
This commit is contained in:
Shauren
2020-05-10 15:29:47 +02:00
parent 16761e1d7c
commit d889228259
6 changed files with 43 additions and 9 deletions
@@ -21,6 +21,7 @@
DB2CascFileSource::DB2CascFileSource(std::shared_ptr<CASC::Storage const> storage, uint32 fileDataId, bool printErrors /*= true*/)
{
_storageHandle = storage;
_fileHandle.reset(storage->OpenFile(fileDataId, CASC_LOCALE_NONE, printErrors, true));
_fileName = Trinity::StringFormat("FileDataId: %u", fileDataId);
}
@@ -60,3 +61,11 @@ char const* DB2CascFileSource::GetFileName() const
{
return _fileName.c_str();
}
DB2EncryptedSectionHandling DB2CascFileSource::HandleEncryptedSection(DB2SectionHeader const& sectionHeader) const
{
if (std::shared_ptr<CASC::Storage const> storage = _storageHandle.lock())
return storage->HasTactKey(sectionHeader.TactId) ? DB2EncryptedSectionHandling::Process : DB2EncryptedSectionHandling::Skip;
return DB2EncryptedSectionHandling::Skip;
}