Tools/Extractors: Use FileDataID whenever possible

This commit is contained in:
Shauren
2019-06-08 17:10:10 +02:00
parent e7bce901da
commit 25819ea926
15 changed files with 369 additions and 153 deletions
+27
View File
@@ -61,6 +61,33 @@ bool ChunkedFile::loadFile(CASC::StorageHandle const& mpq, std::string const& fi
return false;
}
bool ChunkedFile::loadFile(CASC::StorageHandle const& mpq, uint32 fileDataId, std::string const& description, bool log)
{
free();
CASC::FileHandle file = CASC::OpenFile(mpq, fileDataId, CASC_LOCALE_ALL, log);
if (!file)
return false;
DWORD fileSize = CASC::GetFileSize(file, nullptr);
if (fileSize == CASC_INVALID_SIZE)
return false;
data_size = fileSize;
data = new uint8[data_size];
DWORD bytesRead = 0;
if (!CASC::ReadFile(file, data, data_size, &bytesRead) || bytesRead != data_size)
return false;
parseChunks();
if (prepareLoadedData())
return true;
printf("Error loading %s\n", description.c_str());
free();
return false;
}
bool ChunkedFile::prepareLoadedData()
{
FileChunk* chunk = GetChunk("MVER");