Skip to content

Commit

Permalink
Merge pull request #1049 from uckelman/tile_dir_fix_3.5
Browse files Browse the repository at this point in the history
V3.5 + 3.6: Use correct cache dir for caching tiles
  • Loading branch information
derimmer committed Dec 3, 2021
2 parents f278777 + 45a10a1 commit 192a477
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/VASL/build/module/map/ASLBoardPicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.net.URL;
import java.net.URLConnection;
Expand Down Expand Up @@ -448,7 +450,7 @@ private void tileBoard(String commonName) {

final ASLTilingHandler th = new ASLTilingHandler(
fpath.getAbsolutePath(),
new File(Info.getConfDir(), "tiles/" + hstr),
new File(getCacheDir(), "tiles/" + hstr),
new Dimension(256, 256),
1024,
42
Expand All @@ -461,6 +463,18 @@ private void tileBoard(String commonName) {
}
}

// TODO: Remove this after a release based on Vassal 3.6, and replace
// the call to it with Info.getCacheDir().
private File getCacheDir() {
try {
final Method m = Info.class.getDeclaredMethod("getCacheDir");
return (File) m.invoke(null);
}
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
return Info.getConfDir();
}
}

/**
* Ensures the given board exists and is up to date. If not it fetches it from the repository
* @param baseName the board base name (i.e. reversed board may start with r)
Expand Down

0 comments on commit 192a477

Please sign in to comment.