diff options
Diffstat (limited to 'packets')
21 files changed, 211 insertions, 62 deletions
diff --git a/packets/block_character_packet.gd b/packets/block_character_packet.gd new file mode 100644 index 0000000..96e38d8 --- /dev/null +++ b/packets/block_character_packet.gd @@ -0,0 +1,28 @@ +# TODO: check chclif_block_character in rAthena +class_name BlockCharacterPacket +extends Packet + + +const HEADER := 0x020d +const BYTE_LENGTH := 0 + + +## Byte Type: u16 +## Byte Length: 2 +var packet_length: int + +## Byte Type: u32 +## Byte Length: 4 +var page_to_load: int + +## Byte Type: u16 +## Byte Length: 2 +var character_slot_count: int + + +static func from_bytes(bytes: PackedByteArray): + var packet = BlockCharacterPacket.new() + + packet.packet_length = bytes.decode_u16(2) + + return packet diff --git a/packets/character_information.gd b/packets/character_information.gd index 20e40cd..a2ac0ab 100644 --- a/packets/character_information.gd +++ b/packets/character_information.gd @@ -2,6 +2,9 @@ class_name CharacterInformation extends PacketChunk +const BYTE_LENGTH := 175 + + ## Byte Type: u32 ## Byte Length: 4 var character_id: int @@ -179,10 +182,6 @@ var character_name_change: int var gender: Constants.Gender -func _init() -> void: - byte_length = 175 - - static func from_bytes(bytes: PackedByteArray): var info = CharacterInformation.new() @@ -234,8 +233,8 @@ static func from_bytes(bytes: PackedByteArray): return info -static func array_from_bytes(bytes: PackedByteArray) -> Array: - var array = [] +static func array_from_bytes(bytes: PackedByteArray) -> Array[CharacterInformation]: + var array: Array[CharacterInformation] = [] var offset = 0 while offset < bytes.size(): diff --git a/packets/character_list_size_packet.gd b/packets/character_list_size_packet.gd new file mode 100644 index 0000000..9491e1d --- /dev/null +++ b/packets/character_list_size_packet.gd @@ -0,0 +1,25 @@ +# TODO: really correct? chclif_charlist_notify in rAthena +class_name CharacterListSizePacket +extends Packet + + +const HEADER := 0x09a0 +const BYTE_LENGTH := 6 + + +## Byte Type: u32 +## Byte Length: 4 +var page_to_load: int + +## Byte Type: u16 +## Byte Length: 2 +var character_slot_count: int + + +static func from_bytes(bytes: PackedByteArray): + var packet = CharacterListSizePacket.new() + + packet.page_to_load = bytes.decode_u32(2) + packet.character_slot_count = bytes.decode_u16(4) + + return packet diff --git a/packets/character_selection_success_packet.gd b/packets/character_selection_success_packet.gd index b43b4b5..b188d42 100644 --- a/packets/character_selection_success_packet.gd +++ b/packets/character_selection_success_packet.gd @@ -3,7 +3,7 @@ extends Packet const HEADER := 0x0ac5 -const BYTE_LENGTH := 0 +const BYTE_LENGTH := 156 ## Byte Type: u32 diff --git a/packets/character_server_information.gd b/packets/character_server_information.gd index f67b065..19f22c1 100644 --- a/packets/character_server_information.gd +++ b/packets/character_server_information.gd @@ -2,6 +2,9 @@ class_name CharacterServerInformation extends PacketChunk +const BYTE_LENGTH := 160 + + ## Byte Type: u32 ## Byte Length: 4 var server_ip: PackedByteArray @@ -31,10 +34,6 @@ var display_new: int var unknown: PackedByteArray -func _init() -> void: - byte_length = 160 - - func get_server_ip(): return "%s.%s.%s.%s" % [ server_ip.decode_u8(0), @@ -58,8 +57,8 @@ static func from_bytes(bytes: PackedByteArray): return info -static func array_from_bytes(bytes: PackedByteArray) -> Array: - var array = [] +static func array_from_bytes(bytes: PackedByteArray) -> Array[CharacterServerInformation]: + var array: Array[CharacterServerInformation] = [] var offset = 0 while offset < bytes.size(): diff --git a/packets/character_server_login_packet.gd b/packets/character_server_login_packet.gd index a2d4f7d..fb8a7ea 100644 --- a/packets/character_server_login_packet.gd +++ b/packets/character_server_login_packet.gd @@ -3,7 +3,7 @@ extends Packet const HEADER := 0x0065 -const BYTE_LENGTH := 0 +const BYTE_LENGTH := 17 ## Byte Type: u32 diff --git a/packets/character_server_login_success_character_list_packet.gd b/packets/character_server_login_success_character_list_packet.gd new file mode 100644 index 0000000..e3a649b --- /dev/null +++ b/packets/character_server_login_success_character_list_packet.gd @@ -0,0 +1,42 @@ +class_name CharacterServerLoginSuccessCharacterListPacket +extends Packet + + +const HEADER := 0x006b +const BYTE_LENGTH := 0 + + +## Byte Type: u16 +## Byte Length: 2 +var packet_length: int + +## Byte Type: u8 +## Byte Length: 1 +var maximum_slot_count: int + +## Byte Type: u8 +## Byte Length: 1 +var available_slot_count: int + +## Byte Type: u8 +## Byte Length: 1 +var vip_slot_count: int + +## Byte Type: u8 +## Byte Length: 20 +var unknown: PackedByteArray + +var character_information: Array[CharacterInformation] + + +static func from_bytes(bytes: PackedByteArray): + var packet = CharacterServerLoginSuccessCharacterListPacket.new() + + packet.packet_length = bytes.decode_u16(2) + packet.maximum_slot_count = bytes.decode_u8(4) + packet.maximum_slot_count = bytes.decode_u8(5) + packet.maximum_slot_count = bytes.decode_u8(6) + packet.unknown = bytes.slice(7, 7 + 20) + packet.character_information = CharacterInformation.array_from_bytes(bytes.slice(27)) + + return packet diff --git a/packets/character_server_login_success_packet.gd b/packets/character_server_login_success_packet.gd index bfe6c45..f3da048 100644 --- a/packets/character_server_login_success_packet.gd +++ b/packets/character_server_login_success_packet.gd @@ -3,7 +3,7 @@ extends Packet const HEADER := 0x082d -const BYTE_LENGTH := 0 +const BYTE_LENGTH := 29 ## Byte Length: 2 @@ -31,12 +31,12 @@ var unused: PackedByteArray static func from_bytes(bytes: PackedByteArray): var packet = CharacterServerLoginSuccessPacket.new() - 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) + packet.unknown = bytes.decode_u16(2) + packet.normal_slot_count = bytes.decode_u8(4) + packet.vip_slot_count = bytes.decode_u8(5) + packet.billing_slot_count = bytes.decode_u8(6) + packet.producible_slot_count = bytes.decode_u8(7) + packet.valid_slot = bytes.decode_u8(8) + packet.unused = bytes.slice(9, 9 + 20) return packet diff --git a/packets/login_server_login_packet.gd b/packets/login_server_login_packet.gd index f7217fe..0fa117d 100644 --- a/packets/login_server_login_packet.gd +++ b/packets/login_server_login_packet.gd @@ -3,7 +3,7 @@ extends Packet const HEADER := 0x064 -const BYTE_LENGTH := 0 +const BYTE_LENGTH := 55 ## Byte Type: u32 diff --git a/packets/login_server_login_success_packet.gd b/packets/login_server_login_success_packet.gd index 1f95bae..ce6a058 100644 --- a/packets/login_server_login_success_packet.gd +++ b/packets/login_server_login_success_packet.gd @@ -40,7 +40,7 @@ var gender: Constants.Gender ## Byte Length: 17 var auth_token: String -var character_server_information: Array +var character_server_information: Array[CharacterServerInformation] static func from_bytes(bytes: PackedByteArray): diff --git a/packets/map_server_login_packet.gd b/packets/map_server_login_packet.gd index 726cdff..2138d11 100644 --- a/packets/map_server_login_packet.gd +++ b/packets/map_server_login_packet.gd @@ -3,7 +3,7 @@ extends Packet const HEADER := 0x0436 -const BYTE_LENGTH := 0 +const BYTE_LENGTH := 23 ## Byte Type: u32 diff --git a/packets/map_server_login_success_packet.gd b/packets/map_server_login_success_packet.gd index 1791a85..a6cbdae 100644 --- a/packets/map_server_login_success_packet.gd +++ b/packets/map_server_login_success_packet.gd @@ -1,9 +1,12 @@ +## rAthena References: +## - PACKET_ZC_ACCEPT_ENTER +## - clif_authok class_name MapServerLoginSuccessPacket extends Packet const HEADER := 0x02eb -const BYTE_LENGTH := 0 +const BYTE_LENGTH := 14 ## Byte Type: u32 @@ -23,6 +26,11 @@ var ignored: PackedByteArray ## Byte Length: 2 var font: int +## Byte Type: u8 +## Byte Length: 1 +## Depends on packet version +var gender: Constants.Gender + func get_position(): return Vector2( @@ -37,6 +45,7 @@ static func from_bytes(bytes: PackedByteArray): 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) + packet.font = bytes.decode_u16(11) + packet.gender = bytes.decode_u8(13) return packet diff --git a/packets/packet.gd b/packets/packet.gd index 33db0b1..b1e72ed 100644 --- a/packets/packet.gd +++ b/packets/packet.gd @@ -1,14 +1,16 @@ class_name Packet -#static var header: int = 0 +# set to 0 if variable length +#const BYTE_LENGTH := 0 -var byte_length: int = 0 +var byte_length: int = 0: + get = get_byte_length -## Override if packet has variable length +## Override if packet has variable length. func get_byte_length() -> int: - return byte_length + return self.BYTE_LENGTH ## Get header to prepend to the packet. [br] diff --git a/packets/packet_chunk.gd b/packets/packet_chunk.gd index 2bd8bc6..52981e6 100644 --- a/packets/packet_chunk.gd +++ b/packets/packet_chunk.gd @@ -1,10 +1,13 @@ class_name PacketChunk -var byte_length: int: +# set to 0 if variable length +#const BYTE_LENGTH := 0 + +var byte_length: int = 0: get = get_byte_length -## to be overriden +## Override if packet has variable length. func get_byte_length() -> int: - return byte_length + return self.BYTE_LENGTH diff --git a/packets/pin_code_state_packet.gd b/packets/pin_code_state_packet.gd new file mode 100644 index 0000000..ab75618 --- /dev/null +++ b/packets/pin_code_state_packet.gd @@ -0,0 +1,36 @@ +## rAthena References: +## - chclif_pincode_sendstate +class_name PinCodeStatePacket +extends Packet + + +const HEADER := 0x08b9 +const BYTE_LENGTH := 12 + + +## Byte Type: u32 +## Byte Length: 4 +var pin_code_seed: int + +## Byte Type: u32 +## Byte Length: 4 +var account_id: int + +## Byte Type: u8 +## Byte Length: 1 +var pin_code_state: Constants.PinCodeState + +## Byte Type: u8 +## Byte Length: 1 +var unused: PackedByteArray + + +static func from_bytes(bytes: PackedByteArray): + var packet = PinCodeStatePacket.new() + + packet.pin_code_seed = bytes.decode_u32(2) + packet.account_id = bytes.decode_u32(6) + packet.pin_code_state = bytes.decode_u8(10) + packet.unused = bytes.slice(11) + + return packet 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(): diff --git a/packets/quest_list_packet.gd b/packets/quest_list_packet.gd index bf78f08..fb148c3 100644 --- a/packets/quest_list_packet.gd +++ b/packets/quest_list_packet.gd @@ -14,7 +14,7 @@ var packet_length: int ## Byte Length: 4 var quest_count: int -var quests: Array +var quests: Array[Quest] static func from_bytes(bytes: PackedByteArray): @@ -22,5 +22,6 @@ static func from_bytes(bytes: PackedByteArray): packet.packet_length = bytes.decode_u16(2) packet.quest_count = bytes.decode_u32(4) + packet.quests = Quest.array_from_bytes(bytes.slice(8)) return packet diff --git a/packets/quest_details.gd b/packets/quest_objective_details.gd index eaf8d2e..4fe3a8e 100644 --- a/packets/quest_details.gd +++ b/packets/quest_objective_details.gd @@ -1,7 +1,10 @@ -class_name QuestDetails +class_name QuestObjectiveDetails extends PacketChunk +const BYTE_LENGTH := 44 + + ## Byte Type: u32 ## Byte Length: 4 var hunt_identification: int @@ -35,26 +38,23 @@ var total_count: int var mob_name: String -func get_byte_length(): - return 44 - - static func from_bytes(bytes: PackedByteArray): - var details = QuestDetails.new() + var details = QuestObjectiveDetails.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) + details.hunt_identification = bytes.decode_u32(0) + details.objective_type = bytes.decode_u32(4) + details.mob_id = bytes.decode_u32(8) + details.minimum_level = bytes.decode_u16(12) + details.maximum_level = bytes.decode_u16(14) + details.kill_count = bytes.decode_u16(16) + details.total_count = bytes.decode_u16(18) + details.mob_name = bytes.slice(20, 20 + 24).get_string_from_utf8() return details -static func array_from_bytes(bytes: PackedByteArray) -> Array: - var array = [] +static func array_from_bytes(bytes: PackedByteArray) -> Array[QuestObjectiveDetails]: + var array: Array[QuestObjectiveDetails] = [] var offset = 0 while offset < bytes.size(): diff --git a/packets/request_character_list_packet.gd b/packets/request_character_list_packet.gd index e2c761d..2f43a05 100644 --- a/packets/request_character_list_packet.gd +++ b/packets/request_character_list_packet.gd @@ -3,7 +3,7 @@ extends Packet const HEADER := 0x09a1 -const BYTE_LENGTH := 0 +const BYTE_LENGTH := 2 func to_bytes(): diff --git a/packets/request_character_list_success_packet.gd b/packets/request_character_list_success_packet.gd index f85decc..342bccb 100644 --- a/packets/request_character_list_success_packet.gd +++ b/packets/request_character_list_success_packet.gd @@ -10,7 +10,7 @@ const BYTE_LENGTH := 0 ## Byte Length: 2 var packet_length: int -var character_information: Array +var character_information: Array[CharacterInformation] static func from_bytes(bytes: PackedByteArray): diff --git a/packets/select_character_packet.gd b/packets/select_character_packet.gd index 692183f..56ba1fa 100644 --- a/packets/select_character_packet.gd +++ b/packets/select_character_packet.gd @@ -3,7 +3,7 @@ extends Packet const HEADER := 0x0066 -const BYTE_LENGTH := 0 +const BYTE_LENGTH := 3 ## Byte Type: u8 |