Skip to content

Commit

Permalink
Merge pull request #210 from UnownHash/newprotos
Browse files Browse the repository at this point in the history
Update protos to 0.299
  • Loading branch information
Fabio1988 authored Feb 20, 2024
2 parents 7fbda8b + 11f4e23 commit 164c40d
Show file tree
Hide file tree
Showing 5 changed files with 232,202 additions and 182,119 deletions.
2 changes: 1 addition & 1 deletion decoder/gym.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (gym *Gym) updateGymFromFort(fortData *pogo.PokemonFortProto, cellId uint64
gym.RaidPokemonEvolution = null.IntFrom(0)
}

gym.RaidIsExclusive = null.IntFrom(util.BoolToInt[int64](fortData.RaidInfo.IsExclusive))
gym.RaidIsExclusive = null.IntFrom(0) //null.IntFrom(util.BoolToInt[int64](fortData.RaidInfo.IsExclusive))
}

gym.CellId = null.IntFrom(int64(cellId))
Expand Down
7 changes: 4 additions & 3 deletions decoder/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package decoder

import (
"database/sql"
"golbat/db"
"golbat/pogo"
"reflect"
"strconv"
"time"

"golbat/db"
"golbat/pogo"

"github.com/jellydator/ttlcache/v3"
log "github.com/sirupsen/logrus"
"gopkg.in/guregu/null.v4"
Expand Down Expand Up @@ -510,7 +511,7 @@ func (player *Player) updateFromPublicProfile(publicProfile *pogo.PlayerPublicPr
}
}

func UpdatePlayerRecordWithPlayerSummary(db db.DbDetails, playerSummary *pogo.PlayerSummaryProto, publicProfile *pogo.PlayerPublicProfileProto, friendCode string, friendshipId string) error {
func UpdatePlayerRecordWithPlayerSummary(db db.DbDetails, playerSummary *pogo.InternalPlayerSummaryProto, publicProfile *pogo.PlayerPublicProfileProto, friendCode string, friendshipId string) error {
player, err := getPlayerRecord(db, playerSummary.GetCodename(), friendshipId, friendCode)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions decoder/pokestop.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,11 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con
if focussedPokemonType == nil {
stop.ShowcasePokemonType = null.IntFromPtr(nil)
} else {
stop.ShowcasePokemonType = null.IntFrom(int64(focussedPokemonType.GetType().GetPokemonType_1()))
stop.ShowcasePokemonType = null.IntFrom(int64(focussedPokemonType.GetType().GetPokemonType1()))
}
}

func (stop *Pokestop) updatePokestopFromGetPokemonSizeContestEntryOutProto(contestData *pogo.GetPokemonSizeContestEntryOutProto) {
func (stop *Pokestop) updatePokestopFromGetPokemonSizeContestEntryOutProto(contestData *pogo.GetPokemonSizeLeaderboardEntryOutProto) {
type contestEntry struct {
Rank int `json:"rank"`
Score float64 `json:"score"`
Expand Down Expand Up @@ -1014,7 +1014,7 @@ func getFortIdFromContest(id string) string {
return strings.Split(id, "-")[0]
}

func UpdatePokestopWithPokemonSizeContestEntry(ctx context.Context, db db.DbDetails, request *pogo.GetPokemonSizeContestEntryProto, contestData *pogo.GetPokemonSizeContestEntryOutProto) string {
func UpdatePokestopWithPokemonSizeContestEntry(ctx context.Context, db db.DbDetails, request *pogo.GetPokemonSizeLeaderboardEntryProto, contestData *pogo.GetPokemonSizeLeaderboardEntryOutProto) string {
fortId := getFortIdFromContest(request.GetContestId())

pokestopMutex, _ := pokestopStripedMutex.GetLock(fortId)
Expand Down
42 changes: 21 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func decode(ctx context.Context, method int, protoData *ProtoData) {
return fmt.Sprintf("#%d", method)
}

if method != int(pogo.ClientAction_CLIENT_ACTION_PROXY_SOCIAL_ACTION) && protoData.Level < 30 {
if method != int(pogo.InternalPlatformClientAction_INTERNAL_PROXY_SOCIAL_ACTION) && protoData.Level < 30 {
statsCollector.IncDecodeMethods("error", "low_level", getMethodName(method, true))
log.Debugf("Insufficient Level %d Did not process hook type %s", protoData.Level, pogo.Method(method))
return
Expand Down Expand Up @@ -385,7 +385,7 @@ func decode(ctx context.Context, method int, protoData *ProtoData) {
case pogo.Method_METHOD_CREATE_COMBAT_CHALLENGE:
ignore = true
break
case pogo.Method(pogo.ClientAction_CLIENT_ACTION_PROXY_SOCIAL_ACTION):
case pogo.Method(pogo.InternalPlatformClientAction_INTERNAL_PROXY_SOCIAL_ACTION):
if protoData.Request != nil {
result = decodeSocialActionWithRequest(protoData.Request, protoData.Data)
processed = true
Expand Down Expand Up @@ -475,22 +475,22 @@ func decodeSocialActionWithRequest(request []byte, payload []byte) string {
return fmt.Sprintf("unsuccessful proxyResponseProto response %d %s", int(proxyResponseProto.Status), proxyResponseProto.Status)
}

switch pogo.SocialAction(proxyRequestProto.GetAction()) {
case pogo.SocialAction_SOCIAL_ACTION_LIST_FRIEND_STATUS:
switch pogo.InternalSocialAction(proxyRequestProto.GetAction()) {
case pogo.InternalSocialAction_SOCIAL_ACTION_LIST_FRIEND_STATUS:
statsCollector.IncDecodeSocialActionWithRequest("ok", "list_friend_status")
return decodeGetFriendDetails(proxyResponseProto.Payload)
case pogo.SocialAction_SOCIAL_ACTION_SEARCH_PLAYER:
case pogo.InternalSocialAction_SOCIAL_ACTION_SEARCH_PLAYER:
statsCollector.IncDecodeSocialActionWithRequest("ok", "search_player")
return decodeSearchPlayer(proxyRequestProto, proxyResponseProto.Payload)
return decodeSearchPlayer(&proxyRequestProto, proxyResponseProto.Payload)

}

statsCollector.IncDecodeSocialActionWithRequest("ok", "unknown")
return fmt.Sprintf("Did not process %s", pogo.SocialAction(proxyRequestProto.GetAction()).String())
return fmt.Sprintf("Did not process %s", pogo.InternalSocialAction(proxyRequestProto.GetAction()).String())
}

func decodeGetFriendDetails(payload []byte) string {
var getFriendDetailsOutProto pogo.GetFriendDetailsOutProto
var getFriendDetailsOutProto pogo.InternalGetFriendDetailsOutProto
getFriendDetailsError := proto.Unmarshal(payload, &getFriendDetailsOutProto)

if getFriendDetailsError != nil {
Expand All @@ -499,7 +499,7 @@ func decodeGetFriendDetails(payload []byte) string {
return fmt.Sprintf("Failed to parse %s", getFriendDetailsError)
}

if getFriendDetailsOutProto.GetResult() != pogo.GetFriendDetailsOutProto_SUCCESS || getFriendDetailsOutProto.GetFriend() == nil {
if getFriendDetailsOutProto.GetResult() != pogo.InternalGetFriendDetailsOutProto_SUCCESS || getFriendDetailsOutProto.GetFriend() == nil {
statsCollector.IncDecodeGetFriendDetails("error", "non_success")
return fmt.Sprintf("unsuccessful get friends details")
}
Expand All @@ -519,8 +519,8 @@ func decodeGetFriendDetails(payload []byte) string {
return fmt.Sprintf("%d players decoded on %d", len(getFriendDetailsOutProto.GetFriend())-failures, len(getFriendDetailsOutProto.GetFriend()))
}

func decodeSearchPlayer(proxyRequestProto pogo.ProxyRequestProto, payload []byte) string {
var searchPlayerOutProto pogo.SearchPlayerOutProto
func decodeSearchPlayer(proxyRequestProto *pogo.ProxyRequestProto, payload []byte) string {
var searchPlayerOutProto pogo.InternalSearchPlayerOutProto
searchPlayerOutError := proto.Unmarshal(payload, &searchPlayerOutProto)

if searchPlayerOutError != nil {
Expand All @@ -529,12 +529,12 @@ func decodeSearchPlayer(proxyRequestProto pogo.ProxyRequestProto, payload []byte
return fmt.Sprintf("Failed to parse %s", searchPlayerOutError)
}

if searchPlayerOutProto.GetResult() != pogo.SearchPlayerOutProto_SUCCESS || searchPlayerOutProto.GetPlayer() == nil {
if searchPlayerOutProto.GetResult() != pogo.InternalSearchPlayerOutProto_SUCCESS || searchPlayerOutProto.GetPlayer() == nil {
statsCollector.IncDecodeSearchPlayer("error", "non_success")
return fmt.Sprintf("unsuccessful search player response")
}

var searchPlayerProto pogo.SearchPlayerProto
var searchPlayerProto pogo.InternalSearchPlayerProto
searchPlayerError := proto.Unmarshal(proxyRequestProto.GetPayload(), &searchPlayerProto)

if searchPlayerError != nil || searchPlayerProto.GetFriendCode() == "" {
Expand Down Expand Up @@ -865,21 +865,21 @@ func decodeGetContestData(ctx context.Context, request []byte, data []byte) stri
}

func decodeGetPokemonSizeContestEntry(ctx context.Context, request []byte, data []byte) string {
var decodedPokemonSizeContestEntry pogo.GetPokemonSizeContestEntryOutProto
var decodedPokemonSizeContestEntry pogo.GetPokemonSizeLeaderboardEntryOutProto
if err := proto.Unmarshal(data, &decodedPokemonSizeContestEntry); err != nil {
log.Errorf("Failed to parse GetPokemonSizeContestEntryOutProto %s", err)
return fmt.Sprintf("Failed to parse GetPokemonSizeContestEntryOutProto %s", err)
log.Errorf("Failed to parse GetPokemonSizeLeaderboardEntryOutProto %s", err)
return fmt.Sprintf("Failed to parse GetPokemonSizeLeaderboardEntryOutProto %s", err)
}

if decodedPokemonSizeContestEntry.Status != pogo.GetPokemonSizeContestEntryOutProto_SUCCESS {
return fmt.Sprintf("Ignored GetPokemonSizeContestEntryOutProto non-success status %s", decodedPokemonSizeContestEntry.Status)
if decodedPokemonSizeContestEntry.Status != pogo.GetPokemonSizeLeaderboardEntryOutProto_SUCCESS {
return fmt.Sprintf("Ignored GetPokemonSizeLeaderboardEntryOutProto non-success status %s", decodedPokemonSizeContestEntry.Status)
}

var decodedPokemonSizeContestEntryRequest pogo.GetPokemonSizeContestEntryProto
var decodedPokemonSizeContestEntryRequest pogo.GetPokemonSizeLeaderboardEntryProto
if request != nil {
if err := proto.Unmarshal(request, &decodedPokemonSizeContestEntryRequest); err != nil {
log.Errorf("Failed to parse GetPokemonSizeContestEntryProto %s", err)
return fmt.Sprintf("Failed to parse GetPokemonSizeContestEntryProto %s", err)
log.Errorf("Failed to parse GetPokemonSizeLeaderboardEntryOutProto %s", err)
return fmt.Sprintf("Failed to parse GetPokemonSizeLeaderboardEntryOutProto %s", err)
}
}

Expand Down
Loading

0 comments on commit 164c40d

Please sign in to comment.