MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / Decompress

Function Decompress

TombEngine/Specific/level.cpp:1401–1429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1399}
1400
1401bool Decompress(char* dest, char* compressedRegion, unsigned int totalUncompressedSize)
1402{
1403 char* regionPtr = compressedRegion;
1404
1405 unsigned int numChunks = *(unsigned int*)regionPtr;
1406 regionPtr += sizeof(unsigned int);
1407
1408 char* destPtr = dest;
1409 unsigned int totalDecompressed = 0;
1410
1411 for (unsigned int i = 0; i < numChunks; i++)
1412 {
1413 unsigned int chunkUncompressed = *(unsigned int*)regionPtr;
1414 regionPtr += sizeof(unsigned int);
1415 unsigned int chunkCompressed = *(unsigned int*)regionPtr;
1416 regionPtr += sizeof(unsigned int);
1417
1418 int result = LZ4_decompress_safe(regionPtr, destPtr, chunkCompressed, chunkUncompressed);
1419
1420 if (result != (int)chunkUncompressed)
1421 return false;
1422
1423 regionPtr += chunkCompressed;
1424 destPtr += chunkUncompressed;
1425 totalDecompressed += chunkUncompressed;
1426 }
1427
1428 return totalDecompressed == totalUncompressedSize;
1429}
1430
1431#ifdef _WIN64
1432long long GetRemainingSize(FILE* filePtr)

Callers 1

ReadCompressedBlockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected