Skip to content

Commit

Permalink
Fix lookup cache for app id's not present on vauff.com & bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Vauff committed Mar 24, 2023
1 parent 26dc7f4 commit bbac11c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@
<version>4.9.0</version>
</dependency>
</dependencies>
<version>r53</version>
<version>r54</version>
</project>
2 changes: 1 addition & 1 deletion src/com/vauff/maunzdiscord/core/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Main
{
public static GatewayDiscordClient gateway;
public static MongoDatabase mongoDatabase;
public static String version = "r53";
public static String version = "r54";
public static Config cfg;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class MapImageTimer
{
/**
* Updates the mapImages hashmap with the latest available map images from vauff.com/mapimgs
* Updates the mapImages hashmap with the latest available map images from vauff.com and clears related caches
*/
public static Runnable timer = () ->
{
Expand Down
15 changes: 7 additions & 8 deletions src/com/vauff/maunzdiscord/servertracking/MapImages.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public static String getMapImageURL(String map, int appId)
// Force lower case since GameTracker does, and for an accurate levenshtein distance
String mapLower = map.toLowerCase();

if (mapImageLookupCache.containsKey(appId))
{
HashMap<String, String> gameCache = mapImageLookupCache.get(appId);
if (!mapImageLookupCache.containsKey(appId))
mapImageLookupCache.put(appId, new HashMap<>());

if (gameCache.containsKey(mapLower))
return gameCache.get(mapLower);
}
HashMap<String, String> gameCache = mapImageLookupCache.get(appId);

if (gameCache.containsKey(mapLower))
return gameCache.get(mapLower);

String url = getVauffMapImageURL(mapLower, appId);
String gtName = appIdToGameTrackerName(appId);
Expand All @@ -58,8 +58,7 @@ public static String getMapImageURL(String map, int appId)
if (url.equals("") && !gtName.equals(""))
url = "https://image.gametracker.com/images/maps/160x120/" + gtName + "/" + mapLower.replace(" ", "%20") + ".jpg";

if (mapImageLookupCache.containsKey(appId))
mapImageLookupCache.get(appId).put(mapLower, url);
mapImageLookupCache.get(appId).put(mapLower, url);

return url;
}
Expand Down

0 comments on commit bbac11c

Please sign in to comment.