mirror of
				https://github.com/Laupetin/OpenAssetTools.git
				synced 2025-10-30 18:17:15 +00:00 
			
		
		
		
	Address review comments.
This commit is contained in:
		| @@ -29,13 +29,12 @@ bool AssetLoaderRawFile::CanLoadFromRaw() const | ||||
| bool AssetLoaderRawFile::LoadAnimtree( | ||||
|     const SearchPathOpenFile& file, const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager) | ||||
| { | ||||
|     const auto uncompressedBuffer = std::make_unique<char[]>(static_cast<size_t>(file.m_length + 1)); | ||||
|     const auto uncompressedBuffer = std::make_unique<char[]>(static_cast<size_t>(file.m_length)); | ||||
|     file.m_stream->read(uncompressedBuffer.get(), file.m_length); | ||||
|     if (file.m_stream->gcount() != file.m_length) | ||||
|         return false; | ||||
|     uncompressedBuffer[static_cast<size_t>(file.m_length)] = '\0'; | ||||
|  | ||||
|     const auto compressionBufferSize = static_cast<size_t>(file.m_length + 1 + sizeof(uint32_t) + COMPRESSED_BUFFER_SIZE_PADDING); | ||||
|     const auto compressionBufferSize = static_cast<size_t>(file.m_length + sizeof(uint32_t) + COMPRESSED_BUFFER_SIZE_PADDING); | ||||
|     auto* compressedBuffer = static_cast<char*>(memory->Alloc(compressionBufferSize)); | ||||
|  | ||||
|     z_stream_s zs{}; | ||||
| @@ -43,7 +42,7 @@ bool AssetLoaderRawFile::LoadAnimtree( | ||||
|     zs.zalloc = Z_NULL; | ||||
|     zs.zfree = Z_NULL; | ||||
|     zs.opaque = Z_NULL; | ||||
|     zs.avail_in = static_cast<uInt>(file.m_length + 1); | ||||
|     zs.avail_in = static_cast<uInt>(file.m_length); | ||||
|     zs.avail_out = compressionBufferSize; | ||||
|     zs.next_in = reinterpret_cast<const Bytef*>(uncompressedBuffer.get()); | ||||
|     zs.next_out = reinterpret_cast<Bytef*>(&compressedBuffer[sizeof(uint32_t)]); | ||||
| @@ -59,14 +58,14 @@ bool AssetLoaderRawFile::LoadAnimtree( | ||||
|  | ||||
|     if (ret != Z_STREAM_END) | ||||
|     { | ||||
|         std::cout << "Deflate failed for loading animtree file \"" << assetName << "\"" << std::endl; | ||||
|         std::cerr << "Deflate failed for loading animtree file \"" << assetName << "\"" << std::endl; | ||||
|         deflateEnd(&zs); | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     const auto compressedSize = compressionBufferSize + sizeof(uint32_t) - zs.avail_out; | ||||
|  | ||||
|     reinterpret_cast<uint32_t*>(compressedBuffer)[0] = static_cast<uint32_t>(file.m_length + 1); // outLen | ||||
|     reinterpret_cast<uint32_t*>(compressedBuffer)[0] = static_cast<uint32_t>(file.m_length); // outLen | ||||
|  | ||||
|     auto* rawFile = memory->Create<RawFile>(); | ||||
|     rawFile->name = memory->Dup(assetName.c_str()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user