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

EncounterId are not long but strings

Open Paul776 opened this issue 10 years ago • 2 comments

taken from one of the dump this is an encounterID: 14356348954446861389 this is to big to be a long (CatchablePokemon uses long) it makes the encouterID become negative

Paul776 avatar Aug 24 '16 12:08 Paul776

It's a fixed64 in the protobuf which is generally used for large unsigned 64 bit values (greater than 2^56). Unfortunately Java doesn't have unsigned types. Numbers greater than 2^63-1 will overflow and be negative in Java.

If you for some reason really dislike negative numbers you could use BigInteger and some bit twiddling to get the unsigned long representation.

Edit: In fact, all you have to do is steal the code from the protocol buffers pretty printing which generated that unsigned long in the dump you were looking at (if it was generated with Java): https://github.com/google/protobuf/blob/master/java/core/src/main/java/com/google/protobuf/TextFormat.java#L512

broach avatar Aug 24 '16 14:08 broach

Thanks didn't know it was fixed64

Paul776 avatar Aug 24 '16 20:08 Paul776