/
AuthLogonProof_S.go
63 lines (50 loc) · 1.16 KB
/
AuthLogonProof_S.go
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
60
61
62
63
package auth
import (
"github.com/Gophercraft/core/vsn"
"github.com/superp00t/etc"
)
type AuthLogonProof_S struct {
Error ErrorType
M2 []byte
AccountFlags uint32
SurveyID uint32
Unk3 uint16
}
func (proof *AuthLogonProof_S) Type() AuthType {
return LogonProof
}
func (proof *AuthLogonProof_S) Send(build vsn.Build, conn *Connection) error {
buf := etc.NewBuffer()
buf.WriteByte(uint8(proof.Error))
if proof.Error != GruntSuccess {
if build >= vsn.V2_0_1 {
buf.WriteUint16(0)
}
return conn.SendBuffer(buf)
}
buf.Write(proof.M2)
buf.WriteUint32(proof.AccountFlags)
if build.AddedIn(vsn.V2_0_1) {
buf.WriteUint32(proof.SurveyID)
buf.WriteUint16(proof.Unk3)
}
return conn.SendBuffer(buf)
}
func (proof *AuthLogonProof_S) Recv(build vsn.Build, conn *Connection) error {
sizeIn := 1 + 20 + 4
if build >= vsn.V2_0_1 {
sizeIn += 6
}
in, err := conn.RecvBuffer(sizeIn)
if err != nil {
return err
}
proof.Error = ErrorType(in.ReadByte())
proof.M2 = in.ReadBytes(20)
proof.AccountFlags = in.ReadUint32()
if build >= vsn.V2_0_1 {
proof.SurveyID = in.ReadUint32()
proof.Unk3 = in.ReadUint16()
}
return nil
}