forked from broderickhyman/albiondata-client
/
operation_join.go
52 lines (42 loc) · 1.46 KB
/
operation_join.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
package client
import (
"strconv"
"strings"
"github.com/ao-data/albiondata-client/lib"
"github.com/ao-data/albiondata-client/log"
)
type operationJoinResponse struct {
CharacterID lib.CharacterID `mapstructure:"1"`
CharacterName string `mapstructure:"2"`
Location string `mapstructure:"8"`
GuildID lib.CharacterID `mapstructure:"53"`
GuildName string `mapstructure:"57"`
}
//CharacterPartsJSON string `mapstructure:"6"`
//Edition string `mapstructure:"38"`
func (op operationJoinResponse) Process(state *albionState) {
log.Debugf("Got JoinResponse operation...")
// Reset the AODataServerID here. This leads to a fresh execution
// of SetServerID() incase the player switched servers
state.AODataServerID = 0
// Hack for second caerleon marketplace
if strings.HasSuffix(op.Location, "-Auction2") {
op.Location = strings.Replace(op.Location, "-Auction2", "", -1)
}
loc, err := strconv.Atoi(op.Location)
if err != nil {
log.Debugf("Unable to convert zoneID to int. Probably an instance.")
state.LocationId = -2
} else {
state.LocationId = loc
}
log.Infof("Updating player location to %v.", op.Location)
if state.CharacterId != op.CharacterID {
log.Infof("Updating player ID to %v.", op.CharacterID)
}
state.CharacterId = op.CharacterID
if state.CharacterName != op.CharacterName {
log.Infof("Updating player to %v.", op.CharacterName)
}
state.CharacterName = op.CharacterName
}