From f177c1534757973063f244450df063def879d7db Mon Sep 17 00:00:00 2001 From: Ferenc Arn Date: Thu, 8 Jun 2017 20:43:56 -0500 Subject: Add zstd compression support. zstd has much better compression speed and ratio, and better decompression speed than currently available methods. Also set zstd as the default compression method for Compression as well as FileAccessCompressed functions. --- modules/enet/networked_multiplayer_enet.cpp | 11 ++++++++++- modules/enet/networked_multiplayer_enet.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index c05c86d9ae..738bd27ed3 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -575,6 +575,9 @@ size_t NetworkedMultiplayerENet::enet_compress(void *context, const ENetBuffer * case COMPRESS_ZLIB: { mode = Compression::MODE_DEFLATE; } break; + case COMPRESS_ZSTD: { + mode = Compression::MODE_ZSTD; + } break; default: { ERR_FAIL_V(0); } } @@ -608,6 +611,10 @@ size_t NetworkedMultiplayerENet::enet_decompress(void *context, const enet_uint8 ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_DEFLATE); } break; + case COMPRESS_ZSTD: { + + ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_ZSTD); + } break; default: {} } if (ret < 0) { @@ -629,7 +636,8 @@ void NetworkedMultiplayerENet::_setup_compressor() { enet_host_compress_with_range_coder(host); } break; case COMPRESS_FASTLZ: - case COMPRESS_ZLIB: { + case COMPRESS_ZLIB: + case COMPRESS_ZSTD: { enet_host_compress(host, &enet_compressor); } break; @@ -654,6 +662,7 @@ void NetworkedMultiplayerENet::_bind_methods() { BIND_CONSTANT(COMPRESS_RANGE_CODER); BIND_CONSTANT(COMPRESS_FASTLZ); BIND_CONSTANT(COMPRESS_ZLIB); + BIND_CONSTANT(COMPRESS_ZSTD); } NetworkedMultiplayerENet::NetworkedMultiplayerENet() { diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h index c20c1af68e..8b971adf55 100644 --- a/modules/enet/networked_multiplayer_enet.h +++ b/modules/enet/networked_multiplayer_enet.h @@ -43,7 +43,8 @@ public: COMPRESS_NONE, COMPRESS_RANGE_CODER, COMPRESS_FASTLZ, - COMPRESS_ZLIB + COMPRESS_ZLIB, + COMPRESS_ZSTD }; private: -- cgit v1.2.3