From a14e88ff4d0d87841a44254e2bff1784da6e8b48 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 15 Dec 2024 14:23:25 +0100 Subject: next commit --- packets/item_option.gd | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'packets/item_option.gd') 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 -- cgit v1.2.3