Skip to content

Commit 0e4d59e

Browse files
committed
fix: when deserializing specialize for received proto
1 parent f5ae50b commit 0e4d59e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/aiocraft/packet.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ def deserialize(cls, proto:int, buffer:io.BytesIO):
5656
fallback_proto -= 1
5757
for k, t in cls._definitions[fallback_proto]:
5858
setattr(ctx, k, t.read(buffer, ctx=ctx))
59-
return cls(**ctx.serialize())
60-
# return cls(proto, **{ name : t.read(buffer) for (name, t) in cls._definitions[proto] })
59+
packet = cls(**ctx.serialize())
60+
packet.for_proto(fallback_proto)
61+
return packet
6162

6263
def serialize(self, proto:int) -> io.BytesIO:
6364
self.for_proto(proto) # this sets both id and definitions but mypy doesn't know...

0 commit comments

Comments
 (0)