From 59d1285d6cfc05b85c8ff3bd74f1e2d5692f7835 Mon Sep 17 00:00:00 2001 From: Gobot1234 Date: Sat, 21 Sep 2024 23:05:08 +0100 Subject: [PATCH] Fix sprays in inventory erroring closes #483 --- steam/ext/csgo/backpack.py | 2 +- steam/ext/csgo/state.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/steam/ext/csgo/backpack.py b/steam/ext/csgo/backpack.py index f881350a..485c3a56 100644 --- a/steam/ext/csgo/backpack.py +++ b/steam/ext/csgo/backpack.py @@ -44,7 +44,7 @@ @dataclass(slots=True) class Sticker: - slot: Literal[0, 1, 2, 3, 4, 5] + slot: Literal[0, 1, 2, 3, 4, 5] | None """The sticker's slot.""" id: int """The sticker's ID.""" diff --git a/steam/ext/csgo/state.py b/steam/ext/csgo/state.py index 9a8e8bc8..68e5786a 100644 --- a/steam/ext/csgo/state.py +++ b/steam/ext/csgo/state.py @@ -169,8 +169,12 @@ async def update_backpack(self, *gc_items: base.Item, is_cache_subscribe: bool = self.set("stickers", stickers) for i in range(6): if sticker_id := utils.get(gc_item.attribute, def_index=113 + i): + slot_id = utils.get(gc_item.attribute, def_index=290 + i) + slot = READ_U32(slot_id.value_bytes) if slot_id else None + assert slot in (1, 2, 3, 4, 5, None) + sticker = Sticker( - slot=READ_U32(utils.get(gc_item.attribute, def_index=290 + i)), # type: ignore + slot=slot, id=READ_U32(sticker_id.value_bytes), )