diff options
author | Ferenc Arn <tagcup@yahoo.com> | 2017-06-08 20:43:56 -0500 |
---|---|---|
committer | Ferenc Arn <tagcup@yahoo.com> | 2017-06-08 23:48:14 -0500 |
commit | f177c1534757973063f244450df063def879d7db (patch) | |
tree | f92cf1c822d71acfe5e56ea42b80018abe0e0117 /modules/enet | |
parent | 01ed55987c4c044191e50ecc94c277b97962ffc7 (diff) |
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.
Diffstat (limited to 'modules/enet')
-rw-r--r-- | modules/enet/networked_multiplayer_enet.cpp | 11 | ||||
-rw-r--r-- | modules/enet/networked_multiplayer_enet.h | 3 |
2 files changed, 12 insertions, 2 deletions
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: |