Fix an issue in rebuilding stash data for socketed items
This commit is contained in:
@@ -176,6 +176,14 @@ class Item:
|
||||
case _ as unreachable:
|
||||
assert_never(unreachable)
|
||||
|
||||
def raw(self):
|
||||
parts = [self.raw_data]
|
||||
if self.sockets:
|
||||
for item in self.sockets:
|
||||
if item:
|
||||
parts.append(item.raw_data)
|
||||
return b"".join(parts)
|
||||
|
||||
def print(self, indent=5, with_raw=False):
|
||||
properties = []
|
||||
base_name = lookup_basetype(self.code)["name"]
|
||||
|
||||
@@ -44,7 +44,7 @@ class StashTab:
|
||||
|
||||
def raw(self) -> bytes:
|
||||
"""Get the computed raw representation of the stash"""
|
||||
item_raw = b"".join(item.raw_data for item in self.items)
|
||||
item_raw = b"".join(item.raw() for item in self.items)
|
||||
raw_length = len(item_raw) + 0x44
|
||||
return (
|
||||
STASH_TAB_MAGIC
|
||||
|
||||
@@ -84,3 +84,18 @@ class StashTest(unittest.TestCase):
|
||||
self.assertEqual(len(new_stash.tabs[0].items), 3)
|
||||
self.assertEqual(len(new_stash.tabs[1].items), 1)
|
||||
self.assertEqual(len(new_stash.tabs[2].items), 25)
|
||||
|
||||
def test_gemmed_raw(self):
|
||||
data = bytes.fromhex(
|
||||
"55aa55aa0100000063000000a40100006200000000000000000000000000"
|
||||
"000000000000000000000000000000000000000000000000000000000000"
|
||||
"000000004a4d010010088000050094a459a496629918020a484890ff1000"
|
||||
"a0003500e07c6f0355aa55aa0100000063000000391b0000440000000000"
|
||||
"000000000000000000000000000000000000000000000000000000000000"
|
||||
"0000000000000000000000004a4d000055aa55aa01000000630000003905"
|
||||
"000044000000000000000000000000000000000000000000000000000000"
|
||||
"00000000000000000000000000000000000000004a4d0000"
|
||||
)
|
||||
stash = parse_stash(data)
|
||||
rebuilt = stash.raw()
|
||||
self.assertEqual(data, rebuilt)
|
||||
|
||||
Reference in New Issue
Block a user