Fixed offset caching read/write

This commit is contained in:
Scott Stamp 2018-10-14 21:08:10 -02:30
parent eae2f2bedc
commit 9321c9c830

View File

@ -4,6 +4,7 @@ import gearth.misc.Cacher;
import gearth.protocol.HConnection; import gearth.protocol.HConnection;
import gearth.protocol.HMessage; import gearth.protocol.HMessage;
import gearth.protocol.memory.habboclient.HabboClient; import gearth.protocol.memory.habboclient.HabboClient;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -60,7 +61,12 @@ public class WindowsHabboClient extends HabboClient {
} }
assert revisionList != null; assert revisionList != null;
List<Object> cachedOffsets = revisionList.getJSONArray(production).toList(); JSONArray cachedOffsets;
if (revisionList.has(production))
cachedOffsets = (JSONArray) revisionList.get(production);
else
cachedOffsets = null;
StringJoiner joiner = new StringJoiner(" "); StringJoiner joiner = new StringJoiner(" ");
if (useCache) { if (useCache) {
@ -86,7 +92,7 @@ public class WindowsHabboClient extends HabboClient {
ArrayList<String> possibleData = new ArrayList<>(); ArrayList<String> possibleData = new ArrayList<>();
if (cachedOffsets == null) { if (cachedOffsets == null) {
cachedOffsets = new ArrayList<>(); cachedOffsets = new JSONArray();
} }
@ -94,8 +100,8 @@ public class WindowsHabboClient extends HabboClient {
while((line = reader.readLine()) != null) { while((line = reader.readLine()) != null) {
if (line.length() > 1) { if (line.length() > 1) {
if (!useCache && (count++ % 2 == 0)) { if (!useCache && (count++ % 2 == 0)) {
if (!cachedOffsets.contains(line)) { if (!cachedOffsets.toList().contains(line)) {
cachedOffsets.add(line); cachedOffsets.put(line);
} }
} }
else else