From 0e4d59ec515a5ad42d7681243385a5b71a91804e Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 17 Jan 2024 02:09:51 +0100 Subject: [PATCH] fix: when deserializing specialize for received proto --- src/aiocraft/packet.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/aiocraft/packet.py b/src/aiocraft/packet.py index 82144ab..ae0a427 100644 --- a/src/aiocraft/packet.py +++ b/src/aiocraft/packet.py @@ -56,8 +56,9 @@ class Packet: fallback_proto -= 1 for k, t in cls._definitions[fallback_proto]: setattr(ctx, k, t.read(buffer, ctx=ctx)) - return cls(**ctx.serialize()) - # return cls(proto, **{ name : t.read(buffer) for (name, t) in cls._definitions[proto] }) + packet = cls(**ctx.serialize()) + packet.for_proto(fallback_proto) + return packet def serialize(self, proto:int) -> io.BytesIO: self.for_proto(proto) # this sets both id and definitions but mypy doesn't know...