Skip to content

Commit 5bb2c4f

Browse files
authored
Updated request id generation (#935)
1 parent e68097c commit 5bb2c4f

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

library/src/main/java/com/pokegoapi/main/RequestHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class RequestHandler implements Runnable {
6767

6868
private boolean active = true;
6969

70-
private RequestIdGenerator requestIdGenerator = new RequestIdGenerator(16807);
70+
private RequestIdGenerator requestIdGenerator = new RequestIdGenerator();
7171

7272
/**
7373
* Instantiates a new Request handler.

library/src/main/java/com/pokegoapi/main/RequestIdGenerator.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,18 @@
1616
package com.pokegoapi.main;
1717

1818
public class RequestIdGenerator {
19-
private static final int MULTIPLIER = 16807;
20-
private static final int MODULUS = 0x7FFFFFFF;
21-
private static final int MQ = (int) Math.floor(MODULUS / MULTIPLIER);
22-
private static final int MR = MODULUS % MULTIPLIER;
23-
private int seed;
24-
private int count = 2;
19+
private static final long MULTIPLIER = 16807;
20+
private static final long MODULUS = 0x7FFFFFFF;
2521

26-
/**
27-
* Creates request id generator with an inital seed
28-
* @param seed the initial seed
29-
*/
30-
public RequestIdGenerator(int seed) {
31-
this.seed = seed;
32-
}
22+
private long rpcIdHigh = 1;
23+
private long rpcId = 2;
3324

3425
/**
3526
* Generates next request id and increments count
3627
* @return the next request id
3728
*/
3829
public long next() {
39-
int temp = MULTIPLIER * (this.seed % MQ) - (MR * (int) Math.floor(this.seed / MQ));
40-
if (temp > 0) {
41-
this.seed = temp;
42-
} else {
43-
this.seed = temp + MODULUS;
44-
}
45-
return this.count++ | (long) this.seed << 32;
30+
rpcIdHigh = MULTIPLIER * rpcIdHigh % MODULUS;
31+
return rpcId++ | (rpcIdHigh << 32);
4632
}
4733
}

library/src/main/java/com/pokegoapi/util/Signature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static void setSignature(PokemonGo api, RequestEnvelope.Builder builder)
121121

122122
if (usePtr8) {
123123
ByteString ptr8 = UnknownPtr8RequestOuterClass.UnknownPtr8Request.newBuilder()
124-
.setMessage("90f6a704505bccac73cec99b07794993e6fd5a12")
124+
.setMessage("15c79df0558009a4242518d2ab65de2a59e09499")
125125
.build()
126126
.toByteString();
127127
builder.addPlatformRequests(RequestEnvelope.PlatformRequest.newBuilder()

0 commit comments

Comments
 (0)