summaryrefslogtreecommitdiff
path: root/packets/regular_item_information.gd
diff options
context:
space:
mode:
Diffstat (limited to 'packets/regular_item_information.gd')
-rw-r--r--packets/regular_item_information.gd30
1 files changed, 14 insertions, 16 deletions
diff --git a/packets/regular_item_information.gd b/packets/regular_item_information.gd
index 212b341..1c12a58 100644
--- a/packets/regular_item_information.gd
+++ b/packets/regular_item_information.gd
@@ -26,8 +26,8 @@ var amount: int
var equipped_position: int
## Byte Type: u32
-## Byte Length: 4
-var slot: int
+## Byte Length: 4 * 4
+var slot: PackedByteArray
## Byte Type: u32
## Byte Length: 4
@@ -38,28 +38,26 @@ var hire_expiration_date: int
var flags: int
-static func from_bytes(bytes: PackedByteArray):
+static func from_bytes(bytes: ByteStream):
var info = RegularItemInformation.new()
- info.index = bytes.decode_u16(0)
- info.item_id = bytes.decode_u32(2)
- info.item_type = bytes.decode_u8(6)
- info.amount = bytes.decode_u16(7)
- info.equipped_position = bytes.decode_u32(9)
- info.slot = bytes.decode_u32(13)
- info.hire_expiration_date = bytes.decode_u32(17)
- info.flags = bytes.decode_u8(21)
+ info.index = bytes.decode_u16()
+ info.item_id = bytes.decode_u32()
+ info.item_type = bytes.decode_u8()
+ info.amount = bytes.decode_u16()
+ info.equipped_position = bytes.decode_u32()
+ info.slot = bytes.get_buffer(4 * 4).bytes
+ info.hire_expiration_date = bytes.decode_u32()
+ info.flags = bytes.decode_u8()
return info
-static func array_from_bytes(bytes: PackedByteArray) -> Array[RegularItemInformation]:
+static func array_from_bytes(bytes: ByteStream) -> Array[RegularItemInformation]:
var array: Array[RegularItemInformation] = []
- var offset = 0
- while offset < bytes.size():
- var chunk = from_bytes(bytes.slice(offset))
+ while bytes.available():
+ var chunk = from_bytes(bytes)
array.append(chunk)
- offset += chunk.byte_length
return array