summaryrefslogtreecommitdiff
path: root/packets/item_option.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-15 14:23:25 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-15 14:23:25 +0100
commita14e88ff4d0d87841a44254e2bff1784da6e8b48 (patch)
tree0507cb8117da7943805a6479aef4526edb2db4dd /packets/item_option.gd
parentca4d1945598863d0ce297f4272317e5dd5797f88 (diff)
next commit
Diffstat (limited to 'packets/item_option.gd')
-rw-r--r--packets/item_option.gd16
1 files changed, 7 insertions, 9 deletions
diff --git a/packets/item_option.gd b/packets/item_option.gd
index 8f59166..9a226db 100644
--- a/packets/item_option.gd
+++ b/packets/item_option.gd
@@ -18,23 +18,21 @@ var value: int
var parameter: int
-static func from_bytes(bytes: PackedByteArray):
+static func from_bytes(bytes: ByteStream):
var option = ItemOption.new()
- option.index = bytes.decode_u16(0)
- option.value = bytes.decode_u16(2)
- option.parameter = bytes.decode_u8(3)
+ option.index = bytes.decode_u16()
+ option.value = bytes.decode_u16()
+ option.parameter = bytes.decode_u8()
return option
-static func array_from_bytes(bytes: PackedByteArray) -> Array[ItemOption]:
+static func array_from_bytes(bytes: ByteStream) -> Array[ItemOption]:
var array: Array[ItemOption] = []
- 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