mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-17 20:10:23 +03:00
* Improve the level sending mechanism in the game.
Instead of sending a request for each chunk one by one, and in sequence, send all the level data in one block. I know this is not the best solution since we are working with UDP here, but it's way faster than loading the level chunk by chunk. In a blink of an eye, the level has already loaded.
This commit is contained in:
@@ -373,6 +373,11 @@ uint8_t* ZlibInflateToMemory(uint8_t* pInput, size_t compressedSize, size_t deco
|
||||
}
|
||||
|
||||
uint8_t* ZlibDeflateToMemory(uint8_t* pInput, size_t sizeBytes, size_t* compressedSizeOut)
|
||||
{
|
||||
return ZlibDeflateToMemoryLvl(pInput, sizeBytes, compressedSizeOut, Z_DEFAULT_COMPRESSION);
|
||||
}
|
||||
|
||||
uint8_t* ZlibDeflateToMemoryLvl(uint8_t* pInput, size_t sizeBytes, size_t* compressedSizeOut, int level)
|
||||
{
|
||||
z_stream strm;
|
||||
memset(&strm, 0, sizeof strm);
|
||||
@@ -384,7 +389,7 @@ uint8_t* ZlibDeflateToMemory(uint8_t* pInput, size_t sizeBytes, size_t* compress
|
||||
strm.opaque = Z_NULL;
|
||||
|
||||
// initialize deflation state machine
|
||||
ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
|
||||
ret = deflateInit(&strm, level);
|
||||
if (ret != Z_OK)
|
||||
return nullptr;
|
||||
|
||||
@@ -394,7 +399,7 @@ uint8_t* ZlibDeflateToMemory(uint8_t* pInput, size_t sizeBytes, size_t* compress
|
||||
uint8_t* pOut = new uint8_t[sizeBytes + ZLIB_PADDING_BYTES];
|
||||
strm.avail_in = sizeBytes;
|
||||
strm.next_in = pInput;
|
||||
strm.avail_in = sizeBytes + ZLIB_PADDING_BYTES;
|
||||
strm.avail_out = sizeBytes + ZLIB_PADDING_BYTES;
|
||||
strm.next_out = pOut;
|
||||
|
||||
ret = deflate(&strm, Z_FINISH);
|
||||
|
||||
@@ -567,6 +567,7 @@ bool DeleteDirectory(const std::string& name, bool unused);
|
||||
// compress and decompress stuff with zlib: ( you must SAFE_DELETE_ARRAY what it returns )
|
||||
uint8_t* ZlibInflateToMemory(uint8_t* pInput, size_t compressedSize, size_t decompressedSize);
|
||||
uint8_t* ZlibDeflateToMemory(uint8_t* pInput, size_t sizeBytes, size_t *compressedSizeOut);
|
||||
uint8_t* ZlibDeflateToMemoryLvl(uint8_t* pInput, size_t sizeBytes, size_t* compressedSizeOut, int level);
|
||||
|
||||
// things that we added:
|
||||
#ifndef ORIGINAL_CODE
|
||||
|
||||
Reference in New Issue
Block a user