PokeGOAPI-Java icon indicating copy to clipboard operation
PokeGOAPI-Java copied to clipboard

WildPokemon getTimeTillHiddenMs() returns large negative numbers

Open MrPat opened this issue 10 years ago • 26 comments

Description: Sometimes the getTimeTillHiddenMs() method returns a feasible number, but a lot of times it returns a huge negative number which obviously isn't correct. Could this be just an overflow of the int32 that holds it? If so is there a way to infer the actual value based on MAX_INT?

Example of a WildPokemon toString() encounter_id: 17736830237155595229 last_modified_timestamp_ms: 1469509425575 latitude: xx.15776268002814 longitude: -xx.74958767808612 spawn_point_id: "xxxxxa87fef" pokemon_data { pokemon_id: CATERPIE } time_till_hidden_ms: -630610344

(x's are just to obfuscate my actual location)

MrPat avatar Jul 26 '16 15:07 MrPat

i routed the api through a proxy to see the raw data, the negative numbers are actually very large longs: 11: 18446744072919745186

and i have no idea why they are so large or what they signify in game.

Grover-c13 avatar Jul 28 '16 01:07 Grover-c13

That seems to be the same type of number I was coming up with when I was using the BigInteger conversion. No clue what it is supposed to be but it did seem to be some measurement of time when I was testing with it.

MrPat avatar Jul 28 '16 05:07 MrPat

sigi_cz at the Pokemon GO Dev subreddit suggested the following fix for the negative values:

time_till_hidden_ms = 841345181 + time_till_hidden_ms

When I do that with the time in my OP I get

-630610344 + 841345181 = 210734837

The fix may not be right but he does suggest an explanation for the negative values at https://www.reddit.com/r/pokemongodev/comments/4v1src/negative_time_till_hidden_ms_and_30_minute_long/

He mentions something about 30 minute long spawns. I thought the max time a Pokemon could be up was 15 mins?

MrPat avatar Jul 28 '16 18:07 MrPat

The negative arent truly real, its just that :

  • We are using fixed64 -> unsigned long
  • Java dont support support printing unsigned long (you can make operation with it but you cant print it without going overflow)

So if you want to print them, you should either :

  • use java 8 : Long.toUnsignedLong(var) or Long.parseUnsignedString(str)
  • use a lib that could handle this for you (dont know if it exist)
  • write your own functions to do it.

vmarchaud avatar Jul 28 '16 18:07 vmarchaud

Alright but when we convert to unsigned long the number is still something like 18446744072919745186, which can't be time till hidden ms. Maybe it's some sort of expiration timestamp like CatchablePokemon have?

MrPat avatar Jul 28 '16 18:07 MrPat

Closed because of discussion in #372

FabianTerhorst avatar Aug 15 '16 20:08 FabianTerhorst