summaryrefslogtreecommitdiff
path: root/packets/login_server_login_success_packet.gd
blob: fd7dbf15045ce1d3e01513c0d519ef17af3d87dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class_name LoginServerLoginSuccessPacket
extends Packet


static var header := 0x0ac4


## Byte Type: u32
## Byte Length: 4
var login_id1: int

## Byte Type: u32
## Byte Length: 4
var account_id: int

## Byte Type: u32
## Byte Length: 4
var login_id2: int

## Deprecated and always 0 on rAthena
## Byte Type: u32
## Byte Length: 4
var ip_address: PackedByteArray

## Deprecated and always 0 on rAthena
## Byte Type: u8
## Byte Length: 26
var last_login: PackedByteArray

## Byte Type: u8
## Byte Length: 1
var gender: Constants.Gender

## Byte Type: u8
## 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.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))
	
	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])