summaryrefslogtreecommitdiff
path: root/packets/equippable_item_information.gd
diff options
context:
space:
mode:
Diffstat (limited to 'packets/equippable_item_information.gd')
-rw-r--r--packets/equippable_item_information.gd47
1 files changed, 22 insertions, 25 deletions
diff --git a/packets/equippable_item_information.gd b/packets/equippable_item_information.gd
index 8ba0629..32c04e1 100644
--- a/packets/equippable_item_information.gd
+++ b/packets/equippable_item_information.gd
@@ -29,8 +29,8 @@ var equip_position: 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
@@ -65,37 +65,34 @@ var enchantment_level: int
var flags: int
-static func from_bytes(bytes: PackedByteArray):
+static func from_bytes(bytes: ByteStream):
var info = EquippableItemInformation.new()
- info.index = bytes.decode_u16(0)
- info.item_id = bytes.decode_u32(2)
- info.item_type = bytes.decode_u8(6)
- info.equipped_position = bytes.decode_u32(7)
- info.equipped_position = bytes.decode_u32(11)
- info.slot = bytes.decode_u32(15)
- info.hire_expiration_date = bytes.decode_u32(19)
- info.bind_on_equip_type = bytes.decode_u16(23)
- info.w_item_sprite_number = bytes.decode_u16(25)
- info.option_count = bytes.decode_u8(27)
-
- var option_data_end = 28 + (5 * ItemOption.BYTE_LENGTH)
- info.option_data = ItemOption.array_from_bytes(bytes.slice(28, option_data_end))
-
- info.refinement_level = bytes.decode_u8(option_data_end)
- info.enchantment_level = bytes.decode_u8(option_data_end + 1)
- info.flags = bytes.decode_u8(option_data_end + 2)
+ info.index = bytes.decode_u16()
+ info.item_id = bytes.decode_u32()
+ info.item_type = bytes.decode_u8()
+ info.equipped_position = bytes.decode_u32()
+ info.equipped_position = bytes.decode_u32()
+ info.slot = bytes.get_buffer(4 * 4).bytes
+ info.hire_expiration_date = bytes.decode_u32()
+ info.bind_on_equip_type = bytes.decode_u16()
+ info.w_item_sprite_number = bytes.decode_u16()
+ info.option_count = bytes.decode_u8()
+ info.option_data = ItemOption.array_from_bytes(
+ bytes.get_buffer(5 * ItemOption.BYTE_LENGTH)
+ )
+ info.refinement_level = bytes.decode_u8()
+ info.enchantment_level = bytes.decode_u8()
+ info.flags = bytes.decode_u8()
return info
-static func array_from_bytes(bytes: PackedByteArray) -> Array[EquippableItemInformation]:
+static func array_from_bytes(bytes: ByteStream) -> Array[EquippableItemInformation]:
var array: Array[EquippableItemInformation] = []
- 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