WildPokemon getTimeTillHiddenMs() returns large negative numbers
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)
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.
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.
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?
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.
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?
Closed because of discussion in #372