summaryrefslogtreecommitdiff
path: root/packets
diff options
context:
space:
mode:
Diffstat (limited to 'packets')
-rw-r--r--packets/character_selection_success_packet.gd19
-rw-r--r--packets/character_server_login_packet.gd3
-rw-r--r--packets/character_server_login_success_packet.gd24
-rw-r--r--packets/couple_status_packet.gd29
-rw-r--r--packets/login_server_login_packet.gd3
-rw-r--r--packets/login_server_login_success_packet.gd30
-rw-r--r--packets/map_server_login_packet.gd3
-rw-r--r--packets/map_server_login_success_packet.gd18
-rw-r--r--packets/new_mail_status_packet.gd19
-rw-r--r--packets/packet.gd2
-rw-r--r--packets/parameter_change_packet.gd24
-rw-r--r--packets/quest.gd54
-rw-r--r--packets/quest_details.gd65
-rw-r--r--packets/quest_list_packet.gd26
-rw-r--r--packets/request_character_list_packet.gd3
-rw-r--r--packets/request_character_list_success_packet.gd18
-rw-r--r--packets/select_character_packet.gd3
-rw-r--r--packets/update_attack_range_packet.gd19
18 files changed, 296 insertions, 66 deletions
diff --git a/packets/character_selection_success_packet.gd b/packets/character_selection_success_packet.gd
index f483d9e..b43b4b5 100644
--- a/packets/character_selection_success_packet.gd
+++ b/packets/character_selection_success_packet.gd
@@ -2,7 +2,8 @@ class_name CharacterSelectionSuccessPacket
extends Packet
-static var header := 0x0ac5
+const HEADER := 0x0ac5
+const BYTE_LENGTH := 0
## Byte Type: u32
@@ -38,16 +39,10 @@ func get_map_server_ip():
static func from_bytes(bytes: PackedByteArray):
var packet = CharacterSelectionSuccessPacket.new()
- packet.character_id = bytes.decode_u32(0)
- packet.map_name = bytes.slice(4, 4 + 16).get_string_from_utf8()
- packet.map_server_ip = bytes.slice(20, 20 + 4)
- packet.map_server_port = bytes.decode_u16(24)
- packet.unknown = bytes.slice(26)
+ packet.character_id = bytes.decode_u32(2)
+ packet.map_name = bytes.slice(6, 6 + 16).get_string_from_utf8()
+ packet.map_server_ip = bytes.slice(22, 22 + 4)
+ packet.map_server_port = bytes.decode_u16(26)
+ packet.unknown = bytes.slice(28)
return packet
-
-static func from_bytes_via_peer(peer: StreamPeer):
- var _header = peer.get_data(2)
- var remaining_bytes = peer.get_data(peer.get_available_bytes())
-
- return from_bytes(remaining_bytes[1])
diff --git a/packets/character_server_login_packet.gd b/packets/character_server_login_packet.gd
index 0e3116f..a2d4f7d 100644
--- a/packets/character_server_login_packet.gd
+++ b/packets/character_server_login_packet.gd
@@ -2,7 +2,8 @@ class_name CharacterServerLoginPacket
extends Packet
-static var header := 0x0065
+const HEADER := 0x0065
+const BYTE_LENGTH := 0
## Byte Type: u32
diff --git a/packets/character_server_login_success_packet.gd b/packets/character_server_login_success_packet.gd
index 800e218..bfe6c45 100644
--- a/packets/character_server_login_success_packet.gd
+++ b/packets/character_server_login_success_packet.gd
@@ -2,6 +2,10 @@ class_name CharacterServerLoginSuccessPacket
extends Packet
+const HEADER := 0x082d
+const BYTE_LENGTH := 0
+
+
## Byte Length: 2
var unknown: int
@@ -27,18 +31,12 @@ var unused: PackedByteArray
static func from_bytes(bytes: PackedByteArray):
var packet = CharacterServerLoginSuccessPacket.new()
- packet.unknown = bytes.decode_u16(0)
- packet.normal_slot_count = bytes.decode_u8(2)
- packet.vip_slot_count = bytes.decode_u8(3)
- packet.billing_slot_count = bytes.decode_u8(4)
- packet.producible_slot_count = bytes.decode_u8(5)
- packet.valid_slot = bytes.decode_u8(6)
- packet.unused = bytes.slice(7, 7 + 20)
+ packet.unknown = bytes.decode_u16(6)
+ packet.normal_slot_count = bytes.decode_u8(8)
+ packet.vip_slot_count = bytes.decode_u8(9)
+ packet.billing_slot_count = bytes.decode_u8(10)
+ packet.producible_slot_count = bytes.decode_u8(11)
+ packet.valid_slot = bytes.decode_u8(12)
+ packet.unused = bytes.slice(13, 13 + 20)
return packet
-
-static func from_bytes_via_peer(peer: StreamPeer):
- var _header = peer.get_data(6)
- var remaining_bytes = peer.get_data(peer.get_available_bytes())
-
- return from_bytes(remaining_bytes[1])
diff --git a/packets/couple_status_packet.gd b/packets/couple_status_packet.gd
new file mode 100644
index 0000000..9f41174
--- /dev/null
+++ b/packets/couple_status_packet.gd
@@ -0,0 +1,29 @@
+class_name CoupleStatusPacket
+extends Packet
+
+
+const HEADER := 0x0141
+const BYTE_LENGTH := 14
+
+
+## Byte Type: u32
+## Byte Length: 4
+var status_type: int
+
+## Byte Type: i32
+## Byte Length: 4
+var default_status: int
+
+## Byte Type: i32
+## Byte Length: 4
+var plus_status: int
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var packet = CoupleStatusPacket.new()
+
+ packet.status_type = bytes.decode_u32(2)
+ packet.default_status = bytes.decode_s32(6)
+ packet.plus_status = bytes.decode_s32(10)
+
+ return packet
diff --git a/packets/login_server_login_packet.gd b/packets/login_server_login_packet.gd
index 5b4c1f3..f7217fe 100644
--- a/packets/login_server_login_packet.gd
+++ b/packets/login_server_login_packet.gd
@@ -2,7 +2,8 @@ class_name LoginServerLoginPacket
extends Packet
-static var header := 0x064
+const HEADER := 0x064
+const BYTE_LENGTH := 0
## Byte Type: u32
diff --git a/packets/login_server_login_success_packet.gd b/packets/login_server_login_success_packet.gd
index fd7dbf1..1f95bae 100644
--- a/packets/login_server_login_success_packet.gd
+++ b/packets/login_server_login_success_packet.gd
@@ -2,9 +2,14 @@ class_name LoginServerLoginSuccessPacket
extends Packet
-static var header := 0x0ac4
+const HEADER := 0x0ac4
+const BYTE_LENGTH := 0
+## Byte Type: u16
+## Byte Length: 2
+var packet_length: int
+
## Byte Type: u32
## Byte Length: 4
var login_id1: int
@@ -41,19 +46,14 @@ var character_server_information: Array
static func from_bytes(bytes: PackedByteArray):
var packet = LoginServerLoginSuccessPacket.new()
- packet.login_id1 = bytes.decode_u32(0)
- packet.account_id = bytes.decode_u32(4)
- packet.login_id2 = bytes.decode_u32(8)
- packet.ip_address = bytes.slice(12, 16)
- packet.last_login = bytes.slice(16, 16 + 26)
- packet.gender = bytes[42]
- packet.auth_token = bytes.slice(43, 43 + 17).get_string_from_utf8()
- packet.character_server_information = CharacterServerInformation.array_from_bytes(bytes.slice(60))
+ packet.packet_length = bytes.decode_u16(2)
+ packet.login_id1 = bytes.decode_u32(4)
+ packet.account_id = bytes.decode_u32(8)
+ packet.login_id2 = bytes.decode_u32(12)
+ packet.ip_address = bytes.slice(16, 20)
+ packet.last_login = bytes.slice(20, 20 + 26)
+ packet.gender = bytes[46]
+ packet.auth_token = bytes.slice(47, 47 + 17).get_string_from_utf8()
+ packet.character_server_information = CharacterServerInformation.array_from_bytes(bytes.slice(64))
return packet
-
-static func from_bytes_via_peer(peer: StreamPeer):
- var _header = peer.get_data(4) # 2 = header, 2 = packet_size
- var remaining_bytes = peer.get_data(peer.get_available_bytes())
-
- return from_bytes(remaining_bytes[1])
diff --git a/packets/map_server_login_packet.gd b/packets/map_server_login_packet.gd
index 89d0108..726cdff 100644
--- a/packets/map_server_login_packet.gd
+++ b/packets/map_server_login_packet.gd
@@ -2,7 +2,8 @@ class_name MapServerLoginPacket
extends Packet
-static var header := 0x0436
+const HEADER := 0x0436
+const BYTE_LENGTH := 0
## Byte Type: u32
diff --git a/packets/map_server_login_success_packet.gd b/packets/map_server_login_success_packet.gd
index 9eecc65..1791a85 100644
--- a/packets/map_server_login_success_packet.gd
+++ b/packets/map_server_login_success_packet.gd
@@ -2,7 +2,8 @@ class_name MapServerLoginSuccessPacket
extends Packet
-static var header := 0x02eb
+const HEADER := 0x02eb
+const BYTE_LENGTH := 0
## Byte Type: u32
@@ -33,16 +34,9 @@ func get_position():
static func from_bytes(bytes: PackedByteArray):
var packet = MapServerLoginSuccessPacket.new()
- packet.client_tick = bytes.decode_u32(0)
- packet.position = bytes.slice(4, 4 + 3)
- packet.ignored = bytes.slice(7, 7 + 2)
- packet.font = bytes.decode_u32(9)
+ packet.client_tick = bytes.decode_u32(2)
+ packet.position = bytes.slice(6, 6 + 3)
+ packet.ignored = bytes.slice(9, 9 + 2)
+ packet.font = bytes.decode_u32(11)
return packet
-
-
-static func from_bytes_via_peer(peer: StreamPeer):
- var _header = peer.get_data(2)
- var remaining_bytes = peer.get_data(peer.get_available_bytes())
-
- return from_bytes(remaining_bytes[1])
diff --git a/packets/new_mail_status_packet.gd b/packets/new_mail_status_packet.gd
new file mode 100644
index 0000000..4e87ed5
--- /dev/null
+++ b/packets/new_mail_status_packet.gd
@@ -0,0 +1,19 @@
+class_name NewMailStatusPacket
+extends Packet
+
+
+const HEADER := 0x09e7
+const BYTE_LENGTH := 3
+
+
+## Byte Type: u8
+## Byte Length: 1
+var new_available: int
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var packet = NewMailStatusPacket.new()
+
+ packet.new_available = bytes.decode_u8(2)
+
+ return packet
diff --git a/packets/packet.gd b/packets/packet.gd
index 9f82782..33db0b1 100644
--- a/packets/packet.gd
+++ b/packets/packet.gd
@@ -15,7 +15,7 @@ func get_byte_length() -> int:
## [param packet_length] is only needed when the packet has a variable length.
func get_header(packet_length: int = 0) -> PackedByteArray:
var bytes = PackedByteArray([0,0])
- bytes.encode_u16(0, self.header)
+ bytes.encode_u16(0, self.HEADER)
if packet_length > 0:
bytes.resize(4)
diff --git a/packets/parameter_change_packet.gd b/packets/parameter_change_packet.gd
new file mode 100644
index 0000000..138b4f5
--- /dev/null
+++ b/packets/parameter_change_packet.gd
@@ -0,0 +1,24 @@
+class_name ParameterChangePacket
+extends Packet
+
+
+const HEADER := 0x00b0
+const BYTE_LENGTH := 8
+
+
+## Byte Type: u16
+## Byte Length: 2
+var parameter_id: int
+
+## Byte Type: i32
+## Byte Length: 4
+var count: int
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var packet = ParameterChangePacket.new()
+
+ packet.parameter_id = bytes.decode_u16(2)
+ packet.count = bytes.decode_s32(4)
+
+ return packet
diff --git a/packets/quest.gd b/packets/quest.gd
new file mode 100644
index 0000000..347f5d1
--- /dev/null
+++ b/packets/quest.gd
@@ -0,0 +1,54 @@
+class_name Quest
+extends PacketChunk
+
+
+## Byte Type: u32
+## Byte Length: 4
+var quest_id: int
+
+## Byte Type: u8
+## Byte Length: 1
+var active: int
+
+## Byte Type: u32
+## Byte Length: 4
+var remaining_time: int
+
+## Byte Type: u32
+## Byte Length: 4
+var expire_time: int
+
+## Byte Type: u16
+## Byte Length: 2
+var objective_count: int
+
+var objective_details: Array
+
+
+func get_byte_length():
+ return "??"
+
+
+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)
+
+ return quest
+
+
+static func array_from_bytes(bytes: PackedByteArray) -> Array:
+ var array = []
+
+ var offset = 0
+ while offset < bytes.size():
+ var chunk = from_bytes(bytes.slice(offset))
+ array.append(chunk)
+ offset += chunk.byte_length
+
+ return array
diff --git a/packets/quest_details.gd b/packets/quest_details.gd
new file mode 100644
index 0000000..eaf8d2e
--- /dev/null
+++ b/packets/quest_details.gd
@@ -0,0 +1,65 @@
+class_name QuestDetails
+extends PacketChunk
+
+
+## Byte Type: u32
+## Byte Length: 4
+var hunt_identification: int
+
+## Byte Type: u32
+## Byte Length: 4
+var objective_type: int
+
+## Byte Type: u32
+## Byte Length: 4
+var mob_id: int
+
+## Byte Type: u16
+## Byte Length: 2
+var minimum_level: int
+
+## Byte Type: u16
+## Byte Length: 2
+var maximum_level: int
+
+## Byte Type: u16
+## Byte Length: 2
+var kill_count: int
+
+## Byte Type: u16
+## Byte Length: 2
+var total_count: int
+
+## Byte Type: u8
+## Byte Length: 24
+var mob_name: String
+
+
+func get_byte_length():
+ return 44
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var details = QuestDetails.new()
+
+ details.server_ip = bytes.slice(0, 4)
+ details.server_port = bytes.decode_u16(4)
+ details.server_name = bytes.slice(6, 6 + 20).get_string_from_utf8()
+ details.user_count = bytes.decode_u16(26)
+ details.server_type = bytes.decode_u16(28)
+ details.display_new = bytes.decode_u16(30)
+ details.unknown = bytes.slice(32)
+
+ return details
+
+
+static func array_from_bytes(bytes: PackedByteArray) -> Array:
+ var array = []
+
+ var offset = 0
+ while offset < bytes.size():
+ var chunk = from_bytes(bytes.slice(offset))
+ array.append(chunk)
+ offset += chunk.byte_length
+
+ return array
diff --git a/packets/quest_list_packet.gd b/packets/quest_list_packet.gd
new file mode 100644
index 0000000..bf78f08
--- /dev/null
+++ b/packets/quest_list_packet.gd
@@ -0,0 +1,26 @@
+class_name QuestListPacket
+extends Packet
+
+
+const HEADER := 0x09f8
+const BYTE_LENGTH := 0
+
+
+## Byte Type: u16
+## Byte Length: 2
+var packet_length: int
+
+## Byte Type: u32
+## Byte Length: 4
+var quest_count: int
+
+var quests: Array
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var packet = QuestListPacket.new()
+
+ packet.packet_length = bytes.decode_u16(2)
+ packet.quest_count = bytes.decode_u32(4)
+
+ return packet
diff --git a/packets/request_character_list_packet.gd b/packets/request_character_list_packet.gd
index e347abd..e2c761d 100644
--- a/packets/request_character_list_packet.gd
+++ b/packets/request_character_list_packet.gd
@@ -2,7 +2,8 @@ class_name RequestCharacterListPacket
extends Packet
-static var header := 0x09a1
+const HEADER := 0x09a1
+const BYTE_LENGTH := 0
func to_bytes():
diff --git a/packets/request_character_list_success_packet.gd b/packets/request_character_list_success_packet.gd
index 431e8ca..f85decc 100644
--- a/packets/request_character_list_success_packet.gd
+++ b/packets/request_character_list_success_packet.gd
@@ -2,19 +2,21 @@ class_name RequestCharacterListSuccessPacket
extends Packet
+const HEADER := 0x0b72
+const BYTE_LENGTH := 0
+
+
+## Byte Type: u16
+## Byte Length: 2
+var packet_length: int
+
var character_information: Array
static func from_bytes(bytes: PackedByteArray):
var packet = RequestCharacterListSuccessPacket.new()
- packet.character_information = CharacterInformation.array_from_bytes(bytes)
+ packet.packet_length = bytes.decode_u16(2)
+ packet.character_information = CharacterInformation.array_from_bytes(bytes.slice(4))
return packet
-
-
-static func from_bytes_via_peer(peer: StreamPeer):
- var _header = peer.get_data(4) # 2 = header, 2 = length
- var remaining_bytes = peer.get_data(peer.get_available_bytes())
-
- return from_bytes(remaining_bytes[1])
diff --git a/packets/select_character_packet.gd b/packets/select_character_packet.gd
index 18843cc..692183f 100644
--- a/packets/select_character_packet.gd
+++ b/packets/select_character_packet.gd
@@ -2,7 +2,8 @@ class_name SelectCharacterPacket
extends Packet
-static var header := 0x0066
+const HEADER := 0x0066
+const BYTE_LENGTH := 0
## Byte Type: u8
diff --git a/packets/update_attack_range_packet.gd b/packets/update_attack_range_packet.gd
new file mode 100644
index 0000000..1ace166
--- /dev/null
+++ b/packets/update_attack_range_packet.gd
@@ -0,0 +1,19 @@
+class_name UpdateAttackRangePacket
+extends Packet
+
+
+const HEADER := 0x013a
+const BYTE_LENGTH := 4
+
+
+## Byte Type: i16
+## Byte Length: 2
+var current_attack_range: int
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var packet = UpdateAttackRangePacket.new()
+
+ packet.current_attack_range = bytes.decode_s16(2)
+
+ return packet