This repository has been archived by the owner on Jun 24, 2023. It is now read-only.
forked from broderickhyman/albiondata-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
operation_join.go
53 lines (43 loc) · 1.4 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
53
package client
import (
"strconv"
"strings"
"github.com/kantraksel/albiondata/lib"
"github.com/kantraksel/albiondata/log"
)
type operationJoinResponse struct {
CharacterID lib.CharacterID `mapstructure:"1"`
CharacterName string `mapstructure:"2"`
Location string `mapstructure:"8"`
GuildID lib.CharacterID `mapstructure:"47"`
GuildName string `mapstructure:"51"`
}
type messageJoin struct {
CharacterID string
LocationString string
}
//CharacterPartsJSON string `mapstructure:"6"`
//Edition string `mapstructure:"38"`
func (op operationJoinResponse) Process(state *albionState) {
log.Debugf("Got JoinResponse operation...")
loc, err := strconv.Atoi(strings.SplitN(op.Location, "-", 2)[0])
if err != nil {
log.Debugf("Unable to convert zoneID to int. Probably an instance.")
state.LocationId = -2
} else {
state.LocationId = loc
checkLocation(loc)
}
state.LocationString = op.Location
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*/
msg := messageJoin{ConfigGlobal.LocalId, op.Location}
sendMsgToUploader(msg, "", state)
}