summaryrefslogtreecommitdiff
path: root/packets/login_server_login_success_packet.gd
blob: 3d742892537063271434d20678ef0abc5b43d8dd (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
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])