-
Notifications
You must be signed in to change notification settings - Fork 2
/
ZoneChange.go
68 lines (54 loc) · 1.3 KB
/
ZoneChange.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
64
65
66
67
68
package eqStruct
import (
"github.com/nomoresecretz/ghoeq-common/proto/eqstruct"
"google.golang.org/protobuf/proto"
)
type ZoneChange struct {
CharName string // MAX64
ZoneID uint16
ZoneReason uint16
Success int8
Error [3]uint8
bPointer int
}
func (p *ZoneChange) EQType() EQType { return EQT_ZoneChange }
func (p *ZoneChange) bp() *int { return &p.bPointer }
func (p *ZoneChange) Unmarshal(b []byte) (int, error) {
p.bPointer = 0
if err := EQRead(b, p, &p.CharName, 64); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.ZoneID, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.ZoneReason, 0); err != nil {
return 0, err
}
p.bPointer = 72
if err := EQRead(b, p, &p.Success, 0); err != nil {
return 0, err
}
p.Error = [3]uint8{}
for i := range p.Error {
if err := EQRead(b, p, &p.Error[i], 0); err != nil {
return 0, err
}
}
return p.bPointer, nil
}
func (p *ZoneChange) Proto() *eqstruct.ZoneChange {
err := make([]uint32, len(p.Error))
for i, v := range p.Error {
err[i] = uint32(v)
}
return &eqstruct.ZoneChange{
CharName: p.CharName,
ZoneId: uint32(p.ZoneID),
ZoneReason: uint32(p.ZoneReason),
Success: uint32(p.Success),
Error: err,
}
}
func (p *ZoneChange) ProtoMess() proto.Message {
return p.Proto()
}