mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-22 10:15:55 +01:00
Handle compression thresholds of -1 properly
This commit is contained in:
parent
ee4319dbb4
commit
1b4a0955c3
@ -60,7 +60,7 @@ class Packet(object):
|
||||
value = data_type.read(file_object)
|
||||
setattr(self, var_name, value)
|
||||
|
||||
def write(self, socket, compression_threshold=-1):
|
||||
def write(self, socket, compression_threshold=None):
|
||||
# buffer the data since we need to know the length of each packet's payload
|
||||
packet_buffer = PacketBuffer()
|
||||
# write packet's id right off the bat in the header
|
||||
@ -71,8 +71,8 @@ class Packet(object):
|
||||
data = getattr(self, var_name)
|
||||
data_type.send(data, packet_buffer)
|
||||
|
||||
# compression_threshold of -1 means compression is disabled
|
||||
if compression_threshold != -1:
|
||||
# compression_threshold of None means compression is disabled
|
||||
if compression_threshold is not None:
|
||||
if len(packet_buffer.get_writable()) > compression_threshold:
|
||||
# compress the current payload
|
||||
compressed_data = compress(packet_buffer.get_writable())
|
||||
|
Loading…
Reference in New Issue
Block a user