diff options
Diffstat (limited to 'packets')
-rw-r--r-- | packets/character_server_login_packet.gd | 32 | ||||
-rw-r--r-- | packets/character_server_login_success_packet.gd | 44 | ||||
-rw-r--r-- | packets/login_server_login_packet.gd | 34 | ||||
-rw-r--r-- | packets/login_server_login_success_packet.gd | 54 | ||||
-rw-r--r-- | packets/map_server_login_packet.gd | 36 | ||||
-rw-r--r-- | packets/packet.gd | 1 | ||||
-rw-r--r-- | packets/request_character_list_packet.gd | 8 | ||||
-rw-r--r-- | packets/request_character_list_success_packet.gd | 19 |
8 files changed, 228 insertions, 0 deletions
diff --git a/packets/character_server_login_packet.gd b/packets/character_server_login_packet.gd new file mode 100644 index 0000000..e6ba07b --- /dev/null +++ b/packets/character_server_login_packet.gd @@ -0,0 +1,32 @@ +class_name CharacterServerLoginPacket +extends Packet + + +## Byte Length: 4 +var account_id: int + +## Byte Length: 4 +var login_id1: int + +## Byte Length: 4 +var login_id2: int + +## Byte Length: 2 +var unknown: int + +## Byte Length: 1 +var gender: Constants.Gender + + +func to_bytes(): + var header = PackedByteArray([101, 0]) + + var payload = PackedByteArray([]) + payload.resize(15) + payload.encode_u32(0, account_id) + payload.encode_u32(4, login_id1) + payload.encode_u32(8, login_id2) + payload.encode_u16(12, unknown) + payload.encode_u8(14, gender) + + return header + payload diff --git a/packets/character_server_login_success_packet.gd b/packets/character_server_login_success_packet.gd new file mode 100644 index 0000000..800e218 --- /dev/null +++ b/packets/character_server_login_success_packet.gd @@ -0,0 +1,44 @@ +class_name CharacterServerLoginSuccessPacket +extends Packet + + +## Byte Length: 2 +var unknown: int + +## Byte Length: 1 +var normal_slot_count: int + +## Byte Length: 1 +var vip_slot_count: int + +## Byte Length: 1 +var billing_slot_count: int + +## Byte Length: 1 +var producible_slot_count: int + +## Byte Length: 1 +var valid_slot: int + +## Byte Length: 20 +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) + + 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/login_server_login_packet.gd b/packets/login_server_login_packet.gd new file mode 100644 index 0000000..29f23cd --- /dev/null +++ b/packets/login_server_login_packet.gd @@ -0,0 +1,34 @@ +class_name LoginServerLoginPacket +extends Packet + + +## Byte Length: 4 +var version: int = 0 + +## Byte Length: 24 +var username: String + +## Byte Length: 24 +var password: String + +## Byte Length: 1 +var client_type: int = 0 + + +func to_bytes(): + var header = PackedByteArray([100, 0]) + + var username_bytes = username.to_utf8_buffer() + username_bytes.resize(24) + + var password_bytes = password.to_utf8_buffer() + password_bytes.resize(24) + + var payload = PackedByteArray([]) + payload.resize(4) + payload.encode_u32(0, version) + payload.append_array(username_bytes) + payload.append_array(password_bytes) + payload.append(client_type) + + return header + payload diff --git a/packets/login_server_login_success_packet.gd b/packets/login_server_login_success_packet.gd new file mode 100644 index 0000000..3d74289 --- /dev/null +++ b/packets/login_server_login_success_packet.gd @@ -0,0 +1,54 @@ +class_name LoginServerLoginSuccessPacket +extends Packet + + +## Byte Length: 4 +var login_id1: int + +## Byte Length: 4 +var account_id: int + +## Byte Length: 4 +var login_id2: int + +## Deprecated and always 0 on rAthena +## Byte Length: 4 +var ip_address: PackedByteArray + +## Deprecated and always 0 on rAthena +## Byte Length: 24 +var name: String + +## Always 0 on rAthena +## Byte Length: 2 +var unknown: int + +## Byte Length: 1 +var gender: Constants.Gender + +## Byte Length: 17 +var auth_token: String + +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.name = bytes.slice(16, 16 + 24).get_string_from_utf8() + packet.unknown = bytes.decode_u16(40) + packet.gender = bytes[42] + packet.auth_token = bytes.slice(43, 43 + 17 - 1).get_string_from_utf8() + packet.character_server_information = CharacterServerInformation.array_from_bytes(bytes.slice(60)) + + return packet + +static func from_bytes_via_peer(peer: StreamPeer): + var _header = peer.get_data(4) + 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 new file mode 100644 index 0000000..62af086 --- /dev/null +++ b/packets/map_server_login_packet.gd @@ -0,0 +1,36 @@ +class_name MapServerLoginPacket +extends Packet + + +## Byte Length: 4 +var account_id: int + +## Byte Length: 4 +var character_id: int + +## Byte Length: 4 +var login_id1: int + +## Byte Length: 4 +var client_tick: int = 100 + +## Byte Length: 1 +var gender: Constants.Gender + +## Byte Length: 4 +var unknown: int = 0 + + +func to_bytes(): + var header = PackedByteArray([54, 4]) + + var payload = PackedByteArray([]) + payload.resize(21) + payload.encode_u32(0, account_id) + payload.encode_u32(4, character_id) + payload.encode_u32(8, login_id1) + payload.encode_u32(12, client_tick) + payload.encode_u8(16, gender) + payload.encode_u32(17, unknown) + + return header + payload diff --git a/packets/packet.gd b/packets/packet.gd new file mode 100644 index 0000000..ea1621c --- /dev/null +++ b/packets/packet.gd @@ -0,0 +1 @@ +class_name Packet diff --git a/packets/request_character_list_packet.gd b/packets/request_character_list_packet.gd new file mode 100644 index 0000000..eca61ad --- /dev/null +++ b/packets/request_character_list_packet.gd @@ -0,0 +1,8 @@ +class_name RequestCharacterListPacket +extends Packet + + +func to_bytes(): + var header = PackedByteArray([161, 9]) + + return header diff --git a/packets/request_character_list_success_packet.gd b/packets/request_character_list_success_packet.gd new file mode 100644 index 0000000..0b6cea8 --- /dev/null +++ b/packets/request_character_list_success_packet.gd @@ -0,0 +1,19 @@ +class_name RequestCharacterListSuccessPacket +extends Packet + + +var character_information: Array + + +static func from_bytes(bytes: PackedByteArray): + var packet = RequestCharacterListSuccessPacket.new() + + packet.character_information = CharacterInformation.array_from_bytes(bytes) + + return packet + +static func from_bytes_via_peer(peer: StreamPeer): + var _header = peer.get_data(4) + var remaining_bytes = peer.get_data(peer.get_available_bytes()) + + return from_bytes(remaining_bytes[1]) |