summaryrefslogtreecommitdiff
path: root/packets/quest.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-30 12:46:08 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-30 12:46:08 +0100
commitd560f77811d4fc6f29bf477356a6d2e58dda0be1 (patch)
tree3ac2c4267b5c88e40849416115977574e9f09a83 /packets/quest.gd
parent313afffce7a823c30acf4853b083f9ca5132e879 (diff)
next commit
Diffstat (limited to 'packets/quest.gd')
-rw-r--r--packets/quest.gd23
1 files changed, 14 insertions, 9 deletions
diff --git a/packets/quest.gd b/packets/quest.gd
index 347f5d1..6b2473e 100644
--- a/packets/quest.gd
+++ b/packets/quest.gd
@@ -2,6 +2,9 @@ class_name Quest
extends PacketChunk
+const BYTE_LENGTH := 0
+
+
## Byte Type: u32
## Byte Length: 4
var quest_id: int
@@ -26,24 +29,26 @@ var objective_details: Array
func get_byte_length():
- return "??"
+ return 15 + objective_count * QuestObjectiveDetails.BYTE_LENGTH
static func from_bytes(bytes: PackedByteArray):
var quest = Quest.new()
- quest.quest_id = bytes.slice(0, 4)
- quest.active = bytes.decode_u16(4)
- quest.remaining_time = bytes.slice(6, 6 + 20).get_string_from_utf8()
- quest.expire_time = bytes.decode_u16(26)
- quest.objective_count = bytes.decode_u16(28)
- quest.objective_details = bytes.slice(32)
+ quest.quest_id = bytes.decode_u32(0)
+ quest.active = bytes.decode_u8(4)
+ quest.remaining_time = bytes.decode_u32(5)
+ quest.expire_time = bytes.decode_u32(9)
+ quest.objective_count = bytes.decode_u16(13)
+ quest.objective_details = QuestObjectiveDetails.array_from_bytes(
+ bytes.slice(15, 15 + quest.byte_length)
+ )
return quest
-static func array_from_bytes(bytes: PackedByteArray) -> Array:
- var array = []
+static func array_from_bytes(bytes: PackedByteArray) -> Array[Quest]:
+ var array: Array[Quest] = []
var offset = 0
while offset < bytes.size():