diff options
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/compression.cpp | 9 | ||||
-rw-r--r-- | core/io/compression.h | 5 | ||||
-rw-r--r-- | core/io/packet_peer.cpp | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 8c8f0b3655..b0f5448b6c 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -61,7 +61,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, strm.zalloc = zipio_alloc; strm.zfree = zipio_free; strm.opaque = Z_NULL; - int level = p_mode == MODE_DEFLATE ? GLOBAL_GET("compression/zlib/compression_level") : GLOBAL_GET("compression/gzip/compression_level"); + int level = p_mode == MODE_DEFLATE ? zlib_level : gzip_level; int err = deflateInit2(&strm, level, Z_DEFLATED, window_bits, 8, Z_DEFAULT_STRATEGY); if (err != Z_OK) return -1; @@ -80,8 +80,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, case MODE_ZSTD: { int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD); - int level = GLOBAL_GET("compression/zstd/compression_level"); - return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, level); + return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, zstd_level); } break; } @@ -173,3 +172,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p ERR_FAIL_V(-1); } + +int Compression::zlib_level = Z_DEFAULT_COMPRESSION; +int Compression::gzip_level = Z_DEFAULT_COMPRESSION; +int Compression::zstd_level = 3; diff --git a/core/io/compression.h b/core/io/compression.h index bc39fc4185..5eb7806d7b 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -33,7 +33,12 @@ #include "typedefs.h" class Compression { + public: + static int zlib_level; + static int gzip_level; + static int zstd_level; + enum Mode { MODE_FASTLZ, MODE_DEFLATE, diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index ac68d5240c..93682e6b8a 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -254,7 +254,7 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) { PacketPeerStream::PacketPeerStream() { - int rbsize = GLOBAL_GET("network/packets/packet_stream_peer_max_buffer_po2"); + int rbsize = GLOBAL_GET("network/limits/packet_peer_stream/max_buffer_po2"); ring_buffer.resize(rbsize); temp_buffer.resize(1 << rbsize); |