From 1fc473e7a21a6fd3fcda235cf4f86eebb6e3d8b2 Mon Sep 17 00:00:00 2001 From: James Berry Date: Mon, 21 Aug 2023 17:27:34 +0100 Subject: [PATCH 1/6] Don't override GMO tth with an encounter tth --- decoder/pokemon.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/decoder/pokemon.go b/decoder/pokemon.go index c5fabcbc..c34d6dda 100644 --- a/decoder/pokemon.go +++ b/decoder/pokemon.go @@ -644,6 +644,13 @@ func (pokemon *Pokemon) updateSpawnpointInfo(ctx context.Context, db db.DbDetail panic(err) } + if timestampMs == 0 && pokemon.ExpireTimestamp.Valid { + // Unknown server timestamp (eg from an encounter), only proceed if we don't have a valid timestamp + return + } else { + timestampMs = time.Now().UnixMilli() // Use current timestamp, accepting that this may be inaccurate + } + pokemon.SpawnId = null.IntFrom(spawnId) pokemon.ExpireTimestampVerified = false @@ -913,8 +920,7 @@ func (pokemon *Pokemon) addEncounterPokemon(ctx context.Context, db db.DbDetails func (pokemon *Pokemon) updatePokemonFromEncounterProto(ctx context.Context, db db.DbDetails, encounterData *pogo.EncounterOutProto, username string) { pokemon.IsEvent = 0 - // TODO is there a better way to get this from the proto? This is how RDM does it - pokemon.addWildPokemon(ctx, db, encounterData.Pokemon, time.Now().Unix()*1000) + pokemon.addWildPokemon(ctx, db, encounterData.Pokemon, 0) pokemon.addEncounterPokemon(ctx, db, encounterData.Pokemon.Pokemon) if pokemon.CellId.Valid == false { From d86edc6b35c4692faea45fc1df6b5bcfe7598387 Mon Sep 17 00:00:00 2001 From: James Berry Date: Mon, 21 Aug 2023 19:44:24 +0100 Subject: [PATCH 2/6] Stupid --- decoder/pokemon.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/decoder/pokemon.go b/decoder/pokemon.go index c34d6dda..a0395bfb 100644 --- a/decoder/pokemon.go +++ b/decoder/pokemon.go @@ -644,11 +644,13 @@ func (pokemon *Pokemon) updateSpawnpointInfo(ctx context.Context, db db.DbDetail panic(err) } - if timestampMs == 0 && pokemon.ExpireTimestamp.Valid { - // Unknown server timestamp (eg from an encounter), only proceed if we don't have a valid timestamp - return - } else { - timestampMs = time.Now().UnixMilli() // Use current timestamp, accepting that this may be inaccurate + if timestampMs == 0 { + if pokemon.ExpireTimestamp.Valid { + // Unknown server timestamp (eg from an encounter), only proceed if we don't have a valid timestamp + return + } else { + timestampMs = time.Now().UnixMilli() // Use current timestamp, accepting that this may be inaccurate + } } pokemon.SpawnId = null.IntFrom(spawnId) From f89cb088600838dfa90e00092cdf3852364bf1ed Mon Sep 17 00:00:00 2001 From: James Berry Date: Wed, 23 Aug 2023 09:08:07 +0100 Subject: [PATCH 3/6] Add logging --- decoder/pokemon.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/decoder/pokemon.go b/decoder/pokemon.go index a0395bfb..ff68f46d 100644 --- a/decoder/pokemon.go +++ b/decoder/pokemon.go @@ -644,9 +644,13 @@ func (pokemon *Pokemon) updateSpawnpointInfo(ctx context.Context, db db.DbDetail panic(err) } + log.Infof("Encounter [START] %s: Spawnpoint %d Timestamp %d ExpireTimestampVerified: %t ExpireTimestamp: %v", pokemon.Id, spawnId, timestampMs, pokemon.ExpireTimestampVerified, pokemon.ExpireTimestamp) + if timestampMs == 0 { if pokemon.ExpireTimestamp.Valid { // Unknown server timestamp (eg from an encounter), only proceed if we don't have a valid timestamp + log.Infof("Encounter [END] %s: Spawnpoint %d Timestamp %d ExpireTimestampVerified: %t ExpireTimestamp: %v", pokemon.Id, spawnId, timestampMs, pokemon.ExpireTimestampVerified, pokemon.ExpireTimestamp) + return } else { timestampMs = time.Now().UnixMilli() // Use current timestamp, accepting that this may be inaccurate @@ -672,6 +676,8 @@ func (pokemon *Pokemon) updateSpawnpointInfo(ctx context.Context, db db.DbDetail } else { pokemon.setUnknownTimestamp() } + + log.Infof("Encounter [END] %s: Spawnpoint %d Timestamp %d ExpireTimestampVerified: %t ExpireTimestamp: %v", pokemon.Id, spawnId, timestampMs, pokemon.ExpireTimestampVerified, pokemon.ExpireTimestamp) } func (pokemon *Pokemon) setUnknownTimestamp() { From 3c1e13b6ecf1d33523649f58fe6faa0f5820555f Mon Sep 17 00:00:00 2001 From: James Berry Date: Wed, 23 Aug 2023 09:15:59 +0100 Subject: [PATCH 4/6] Increase log level of under level data --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 0ea8909e..0ad329d4 100644 --- a/main.go +++ b/main.go @@ -234,7 +234,7 @@ func main() { func decode(ctx context.Context, method int, protoData *ProtoData) { if method != int(pogo.ClientAction_CLIENT_ACTION_PROXY_SOCIAL_ACTION) && protoData.Level < 30 { - log.Debugf("Insufficient Level %d Did not process hook type %s", protoData.Level, pogo.Method(method)) + log.Warnf("Insufficient Level %d Did not process hook type %s", protoData.Level, pogo.Method(method)) return } From a38981332f1bd325300d9369bfa158782e407ba0 Mon Sep 17 00:00:00 2001 From: James Berry Date: Wed, 23 Aug 2023 09:25:38 +0100 Subject: [PATCH 5/6] Increase logging --- decoder/pokemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder/pokemon.go b/decoder/pokemon.go index ff68f46d..c3ff96dd 100644 --- a/decoder/pokemon.go +++ b/decoder/pokemon.go @@ -677,7 +677,7 @@ func (pokemon *Pokemon) updateSpawnpointInfo(ctx context.Context, db db.DbDetail pokemon.setUnknownTimestamp() } - log.Infof("Encounter [END] %s: Spawnpoint %d Timestamp %d ExpireTimestampVerified: %t ExpireTimestamp: %v", pokemon.Id, spawnId, timestampMs, pokemon.ExpireTimestampVerified, pokemon.ExpireTimestamp) + log.Infof("Encounter [END] %s: Spawnpoint %d Timestamp %d ExpireTimestampVerified: %t ExpireTimestamp: %v Spawnpoint data: %+v", pokemon.Id, spawnId, timestampMs, pokemon.ExpireTimestampVerified, pokemon.ExpireTimestamp, spawnPoint) } func (pokemon *Pokemon) setUnknownTimestamp() { From 03798c38d607c0b28a26bbaaa1879c6b3c6e38b5 Mon Sep 17 00:00:00 2001 From: James Berry Date: Sun, 7 Jan 2024 11:19:36 +0000 Subject: [PATCH 6/6] Correctly update to 0 --- decoder/pokemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder/pokemon.go b/decoder/pokemon.go index 384af90b..44d5647a 100644 --- a/decoder/pokemon.go +++ b/decoder/pokemon.go @@ -942,7 +942,7 @@ func (pokemon *Pokemon) addEncounterPokemon(ctx context.Context, db db.DbDetails func (pokemon *Pokemon) updatePokemonFromEncounterProto(ctx context.Context, db db.DbDetails, encounterData *pogo.EncounterOutProto, username string) { pokemon.IsEvent = 0 // TODO is there a better way to get this from the proto? This is how RDM does it - pokemon.addWildPokemon(ctx, db, encounterData.Pokemon, time.Now().Unix()*1000) + pokemon.addWildPokemon(ctx, db, encounterData.Pokemon, 0) pokemon.addEncounterPokemon(ctx, db, encounterData.Pokemon.Pokemon, username) if pokemon.CellId.Valid == false {