Skip to content

Commit 3fd5158

Browse files
committed
check datapackage for valid ID's to scout, instead of missing locations.
1 parent 8545f66 commit 3fd5158

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77

88
archivesBaseName = "Archipelago.MultiClient.Java"
99
group = 'gg.archipelago.APClient'
10-
version = '1.11'
10+
version = '1.12'
1111

1212
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
1313

src/main/java/gg/archipelago/client/ArchipelagoClient.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
import java.io.*;
1414
import java.net.URI;
1515
import java.net.URISyntaxException;
16-
import java.util.ArrayList;
17-
import java.util.Collection;
18-
import java.util.HashSet;
19-
import java.util.Set;
16+
import java.util.*;
2017
import java.util.logging.Level;
2118
import java.util.logging.Logger;
2219

@@ -243,7 +240,8 @@ public boolean checkLocations(Collection<Long> locationIDs) {
243240
}
244241

245242
public void scoutLocations(ArrayList<Long> locationIDs) {
246-
locationIDs.removeIf( location -> !locationManager.getMissingLocations().contains(location));
243+
HashMap<Long, String> locations = dataPackage.getLocationsForGame(game);
244+
locationIDs.removeIf( location -> !locations.containsKey(location));
247245
archipelagoWebSocket.scoutLocation(locationIDs);
248246
}
249247

src/main/java/gg/archipelago/client/LocationManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ public LocationManager(ArchipelagoClient archipelagoClient) {
1818
}
1919

2020
public boolean checkLocation(long id) {
21-
return checkLocations(Collections.singletonList(id));
21+
return checkLocations(new ArrayList<Long>(1) {{add(id);}});
2222
}
2323

2424
public boolean checkLocations(Collection<Long> ids) {
2525
ids.removeIf( location -> !missingLocations.contains(location));
2626
checkedLocations.addAll(ids);
27+
missingLocations.removeAll(ids);
2728
LocationChecks packet = new LocationChecks();
2829
packet.locations.addAll(ids);
2930
if(webSocket == null)

src/main/java/gg/archipelago/client/parts/DataPackage.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,39 @@ public HashMap<Long, String> getItems() {
6767
return itemIdToName;
6868
}
6969

70+
public HashMap<Long, String> getItemsForGame(String game) {
71+
HashMap<Long, String> ret = new HashMap<>();
72+
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
73+
if(!gameEntry.getKey().equals(game)) continue;
74+
for (Map.Entry<String, Long> items : gameEntry.getValue().itemNameToId.entrySet()) {
75+
ret.put(items.getValue(), items.getKey());
76+
}
77+
}
78+
return ret;
79+
}
80+
7081
public HashMap<Long, String> getLocations() {
7182
if(locationIdToName.isEmpty()) {
7283
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
73-
for (Map.Entry<String, Long> items : gameEntry.getValue().locationNameToId.entrySet()) {
74-
itemIdToName.put(items.getValue(), items.getKey());
84+
for (Map.Entry<String, Long> locations : gameEntry.getValue().locationNameToId.entrySet()) {
85+
itemIdToName.put(locations.getValue(), locations.getKey());
7586
}
7687
}
7788
}
7889
return itemIdToName;
7990
}
8091

92+
public HashMap<Long, String> getLocationsForGame(String game) {
93+
HashMap<Long, String> ret = new HashMap<>();
94+
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
95+
if(!gameEntry.getKey().equals(game)) continue;
96+
for (Map.Entry<String, Long> locations : gameEntry.getValue().locationNameToId.entrySet()) {
97+
ret.put(locations.getValue(), locations.getKey());
98+
}
99+
}
100+
return ret;
101+
}
102+
81103
public int getVersion() {
82104
return version;
83105
}

src/main/java/gg/archipelago/client/parts/Game.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
public class Game implements Serializable {
99

1010
@SerializedName("version")
11-
int version;
11+
public int version;
12+
13+
@SerializedName("hash")
14+
public String hash;
1215

1316
@SerializedName("item_name_to_id")
14-
HashMap<String,Long> itemNameToId = new HashMap<>();
17+
public HashMap<String,Long> itemNameToId = new HashMap<>();
1518

1619
@SerializedName("location_name_to_id")
17-
HashMap<String,Long> locationNameToId = new HashMap<>();
20+
public HashMap<String,Long> locationNameToId = new HashMap<>();
1821
}

0 commit comments

Comments
 (0)