--- HLLib/SGAFile.cpp.orig 2021-05-29 21:01:07 UTC +++ HLLib/SGAFile.cpp @@ -301,37 +301,37 @@ CSGAFile::CSGADirectory hlBool CSGAFile::CSGADirectory::MapDataStructures() { - if(!this->File.pMapping->Map(this->pHeaderDirectoryView, sizeof(SGAHeader), static_cast(this->File.pHeader)->uiHeaderLength)) + if(!this->File.pMapping->Map(this->pHeaderDirectoryView, sizeof(TSGAHeader), static_cast(this->File.pHeader)->uiHeaderLength)) { return hlFalse; } - this->pDirectoryHeader = static_cast(this->pHeaderDirectoryView->GetView()); + this->pDirectoryHeader = static_cast(this->pHeaderDirectoryView->GetView()); - if(this->pDirectoryHeader->uiSectionCount > 0 && this->pDirectoryHeader->uiSectionOffset + sizeof(SGASection) * this->pDirectoryHeader->uiSectionCount > static_cast(this->File.pHeader)->uiHeaderLength) + if(this->pDirectoryHeader->uiSectionCount > 0 && this->pDirectoryHeader->uiSectionOffset + sizeof(TSGASection) * this->pDirectoryHeader->uiSectionCount > static_cast(this->File.pHeader)->uiHeaderLength) { LastError.SetErrorMessage("Invalid file: the file map is too small for section data."); return hlFalse; } - if(this->pDirectoryHeader->uiFolderCount > 0 && this->pDirectoryHeader->uiFolderOffset + sizeof(SGAFolder) * this->pDirectoryHeader->uiFolderCount > static_cast(this->File.pHeader)->uiHeaderLength) + if(this->pDirectoryHeader->uiFolderCount > 0 && this->pDirectoryHeader->uiFolderOffset + sizeof(TSGAFolder) * this->pDirectoryHeader->uiFolderCount > static_cast(this->File.pHeader)->uiHeaderLength) { LastError.SetErrorMessage("Invalid file: the file map is too small for folder data."); return hlFalse; } - if(this->pDirectoryHeader->uiFileCount > 0 && this->pDirectoryHeader->uiFileOffset + sizeof(SGAFile) * this->pDirectoryHeader->uiFileCount > static_cast(this->File.pHeader)->uiHeaderLength) + if(this->pDirectoryHeader->uiFileCount > 0 && this->pDirectoryHeader->uiFileOffset + sizeof(TSGAFile) * this->pDirectoryHeader->uiFileCount > static_cast(this->File.pHeader)->uiHeaderLength) { LastError.SetErrorMessage("Invalid file: the file map is too small for file data."); return hlFalse; } - if(this->pDirectoryHeader->uiStringTableOffset > static_cast(this->File.pHeader)->uiHeaderLength) + if(this->pDirectoryHeader->uiStringTableOffset > static_cast(this->File.pHeader)->uiHeaderLength) { LastError.SetErrorMessage("Invalid file: the file map is too small for string table data."); return hlFalse; } - this->lpSections = reinterpret_cast(reinterpret_cast(this->pDirectoryHeader) + this->pDirectoryHeader->uiSectionOffset); - this->lpFolders = reinterpret_cast(reinterpret_cast(this->pDirectoryHeader) + this->pDirectoryHeader->uiFolderOffset); - this->lpFiles = reinterpret_cast(reinterpret_cast(this->pDirectoryHeader) + this->pDirectoryHeader->uiFileOffset); + this->lpSections = reinterpret_cast(reinterpret_cast(this->pDirectoryHeader) + this->pDirectoryHeader->uiSectionOffset); + this->lpFolders = reinterpret_cast(reinterpret_cast(this->pDirectoryHeader) + this->pDirectoryHeader->uiFolderOffset); + this->lpFiles = reinterpret_cast(reinterpret_cast(this->pDirectoryHeader) + this->pDirectoryHeader->uiFileOffset); this->lpStringTable = reinterpret_cast(reinterpret_cast(this->pDirectoryHeader) + this->pDirectoryHeader->uiStringTableOffset); return hlTrue; @@ -352,7 +352,7 @@ hlVoid CSGAFile::CSGADirectory CDirectoryFolder *CSGAFile::CSGADirectory::CreateRoot() { - CDirectoryFolder *pRoot = new CDirectoryFolder(&File); + CDirectoryFolder *pRoot = new CDirectoryFolder(&this->File); for(hlUInt i = 0; i < this->pDirectoryHeader->uiSectionCount; i++) { @@ -558,7 +558,7 @@ hlBool CSGAFile::CSGADirectory(pItem); - const SGAFile &File = this->lpFiles[pFile->GetID()]; + const TSGAFile &File = this->lpFiles[pFile->GetID()]; switch(eAttribute) { case HL_SGA_ITEM_SECTION_ALIAS: @@ -613,7 +613,7 @@ template::GetFileExtractableInternal(const CDirectoryFile *pFile, hlBool &bExtractable) const { #if !USE_ZLIB - const SGAFile &File = this->lpFiles[pFile->GetID()]; + const TSGAFile &File = this->lpFiles[pFile->GetID()]; bExtractable = File.uiType == 0; #else @@ -831,7 +831,7 @@ hlBool CSGAFile::CSGASpecializedDirectory hlBool CSGAFile::CSGADirectory::GetFileSizeInternal(const CDirectoryFile *pFile, hlUInt &uiSize) const { - const SGAFile &File = this->lpFiles[pFile->GetID()]; + const TSGAFile &File = this->lpFiles[pFile->GetID()]; uiSize = File.uiSize; @@ -841,7 +841,7 @@ hlBool CSGAFile::CSGADirectory hlBool CSGAFile::CSGADirectory::GetFileSizeOnDiskInternal(const CDirectoryFile *pFile, hlUInt &uiSize) const { - const SGAFile &File = this->lpFiles[pFile->GetID()]; + const TSGAFile &File = this->lpFiles[pFile->GetID()]; uiSize = File.uiSizeOnDisk; @@ -851,18 +851,18 @@ hlBool CSGAFile::CSGADirectory hlBool CSGAFile::CSGADirectory::CreateStreamInternal(const CDirectoryFile *pFile, Streams::IStream *&pStream) const { - const SGAFile &File = this->lpFiles[pFile->GetID()]; + const TSGAFile &File = this->lpFiles[pFile->GetID()]; if(File.uiType == 0) { - pStream = new Streams::CMappingStream(*this->File.pMapping, static_cast(this->File.pHeader)->uiFileDataOffset + File.uiOffset, File.uiSizeOnDisk); + pStream = new Streams::CMappingStream(*this->File.pMapping, static_cast(this->File.pHeader)->uiFileDataOffset + File.uiOffset, File.uiSizeOnDisk); return hlTrue; } else { #if USE_ZLIB Mapping::CView *pFileDataView = 0; - if(this->File.pMapping->Map(pFileDataView, static_cast(this->File.pHeader)->uiFileDataOffset + File.uiOffset, File.uiSizeOnDisk)) + if(this->File.pMapping->Map(pFileDataView, static_cast(this->File.pHeader)->uiFileDataOffset + File.uiOffset, File.uiSizeOnDisk)) { hlBool bResult = hlFalse; hlByte *lpInflateBuffer = new hlByte[File.uiSize]; @@ -905,4 +905,4 @@ hlVoid CSGAFile::CSGADirectory(static_cast(Stream).GetBuffer()); } -} \ No newline at end of file +}