Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't override GMO tth with an encounter tth #149

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion decoder/pokemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,19 @@ 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 {
Fabio1988 marked this conversation as resolved.
Show resolved Hide resolved
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
}
}

pokemon.SpawnId = null.IntFrom(spawnId)
pokemon.ExpireTimestampVerified = false
Fabio1988 marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -686,6 +699,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 Spawnpoint data: %+v", pokemon.Id, spawnId, timestampMs, pokemon.ExpireTimestampVerified, pokemon.ExpireTimestamp, spawnPoint)
}

func (pokemon *Pokemon) setUnknownTimestamp() {
Expand Down Expand Up @@ -939,7 +954,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 {
Expand Down
Loading