Skip to content

Commit

Permalink
check datapackage for valid ID's to scout, instead of missing locations.
Browse files Browse the repository at this point in the history
  • Loading branch information
KonoTyran committed Aug 1, 2023
1 parent 8545f66 commit 3fd5158
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

archivesBaseName = "Archipelago.MultiClient.Java"
group = 'gg.archipelago.APClient'
version = '1.11'
version = '1.12'

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

Expand Down
8 changes: 3 additions & 5 deletions src/main/java/gg/archipelago/client/ArchipelagoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

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

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

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gg/archipelago/client/LocationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ public LocationManager(ArchipelagoClient archipelagoClient) {
}

public boolean checkLocation(long id) {
return checkLocations(Collections.singletonList(id));
return checkLocations(new ArrayList<Long>(1) {{add(id);}});
}

public boolean checkLocations(Collection<Long> ids) {
ids.removeIf( location -> !missingLocations.contains(location));
checkedLocations.addAll(ids);
missingLocations.removeAll(ids);
LocationChecks packet = new LocationChecks();
packet.locations.addAll(ids);
if(webSocket == null)
Expand Down
26 changes: 24 additions & 2 deletions src/main/java/gg/archipelago/client/parts/DataPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,39 @@ public HashMap<Long, String> getItems() {
return itemIdToName;
}

public HashMap<Long, String> getItemsForGame(String game) {
HashMap<Long, String> ret = new HashMap<>();
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
if(!gameEntry.getKey().equals(game)) continue;
for (Map.Entry<String, Long> items : gameEntry.getValue().itemNameToId.entrySet()) {
ret.put(items.getValue(), items.getKey());
}
}
return ret;
}

public HashMap<Long, String> getLocations() {
if(locationIdToName.isEmpty()) {
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
for (Map.Entry<String, Long> items : gameEntry.getValue().locationNameToId.entrySet()) {
itemIdToName.put(items.getValue(), items.getKey());
for (Map.Entry<String, Long> locations : gameEntry.getValue().locationNameToId.entrySet()) {
itemIdToName.put(locations.getValue(), locations.getKey());
}
}
}
return itemIdToName;
}

public HashMap<Long, String> getLocationsForGame(String game) {
HashMap<Long, String> ret = new HashMap<>();
for (Map.Entry<String, Game> gameEntry : games.entrySet()) {
if(!gameEntry.getKey().equals(game)) continue;
for (Map.Entry<String, Long> locations : gameEntry.getValue().locationNameToId.entrySet()) {
ret.put(locations.getValue(), locations.getKey());
}
}
return ret;
}

public int getVersion() {
return version;
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/gg/archipelago/client/parts/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
public class Game implements Serializable {

@SerializedName("version")
int version;
public int version;

@SerializedName("hash")
public String hash;

@SerializedName("item_name_to_id")
HashMap<String,Long> itemNameToId = new HashMap<>();
public HashMap<String,Long> itemNameToId = new HashMap<>();

@SerializedName("location_name_to_id")
HashMap<String,Long> locationNameToId = new HashMap<>();
public HashMap<String,Long> locationNameToId = new HashMap<>();
}

0 comments on commit 3fd5158

Please sign in to comment.