From 25f2f85b008c06a0dbbefd2bc0271fda784ce2de Mon Sep 17 00:00:00 2001 From: Lekuru Date: Fri, 31 May 2024 19:01:32 +0200 Subject: [PATCH] Fix packet processing logic --- osu/tcp/bancho.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/osu/tcp/bancho.py b/osu/tcp/bancho.py index 5d6cea4..6ef2d33 100644 --- a/osu/tcp/bancho.py +++ b/osu/tcp/bancho.py @@ -82,24 +82,23 @@ def connect(self): def process_packets(self) -> None: """Process incoming packets from the server""" - while True: - packet_header = StreamIn(self.socket.recv(7)) + packet_header = StreamIn(self.socket.recv(7)) - if packet_header.eof(): - return + if packet_header.eof(): + return - packet_id = packet_header.u16() - compression = packet_header.bool() - packet_size = packet_header.u32() - packet_data = self.socket.recv(packet_size) + packet_id = packet_header.u16() + compression = packet_header.bool() + packet_size = packet_header.u32() + packet_data = self.socket.recv(packet_size) - if compression: - packet_data = gzip.decompress(packet_data) + if compression: + packet_data = gzip.decompress(packet_data) - packet, stream = ServerPackets(packet_id), StreamIn(packet_data) + packet, stream = ServerPackets(packet_id), StreamIn(packet_data) - self.logger.debug(f'Received packet {packet.name} -> "{stream.get()}"') - self.game.packets.packet_received(packet, stream, self.game) + self.logger.debug(f'Received packet {packet.name} -> "{stream.get()}"') + self.game.packets.packet_received(packet, stream, self.game) def enqueue( self, packet: ClientPackets, data: bytes = b"", dequeue: bool = False