summaryrefslogtreecommitdiff
path: root/packets/item_option.gd
diff options
context:
space:
mode:
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