Added some refactoring around cache path logic

This commit is contained in:
Jonatino
2021-03-21 13:46:37 -04:00
parent f41aa220a4
commit 04634bc5b9
10 changed files with 49 additions and 40 deletions

View File

@@ -2000,7 +2000,7 @@ public final class Client extends GameEngine implements Usernamed {
byte var9 = 0; // L: 775
try {
Projectile.method2255("oldschool", var8, var9, 21); // L: 777
Projectile.findAndLoadCache("oldschool", var8, var9, 21); // L: 777
} catch (Exception var10) { // L: 779
SequenceDefinition.RunException_sendStackTrace((String)null, var10); // L: 780
}
@@ -5984,4 +5984,4 @@ public final class Client extends GameEngine implements Usernamed {
}
}
}
}
}

View File

@@ -31,11 +31,11 @@ public class DesktopPlatformInfoProvider implements PlatformInfoProvider {
@Export("get")
public PlatformInfo get() {
byte var1;
if (GZipDecompressor.field4046.startsWith("win")) { // L: 15
if (GZipDecompressor.formattedOperatingSystemName.startsWith("win")) { // L: 15
var1 = 1;
} else if (GZipDecompressor.field4046.startsWith("mac")) { // L: 16
} else if (GZipDecompressor.formattedOperatingSystemName.startsWith("mac")) { // L: 16
var1 = 2;
} else if (GZipDecompressor.field4046.startsWith("linux")) {
} else if (GZipDecompressor.formattedOperatingSystemName.startsWith("linux")) {
var1 = 3;
} else {
var1 = 4; // L: 18
@@ -210,4 +210,4 @@ public class DesktopPlatformInfoProvider implements PlatformInfoProvider {
public static StudioGame[] method6478() {
return new StudioGame[]{StudioGame.stellardawn, StudioGame.game5, StudioGame.oldscape, StudioGame.game4, StudioGame.runescape, StudioGame.game3}; // L: 17
}
}
}

View File

@@ -8,7 +8,8 @@ import net.runelite.mapping.ObfuscatedSignature;
@Implements("GZipDecompressor")
public class GZipDecompressor {
@ObfuscatedName("t")
public static String field4046;
@Export("formattedOperatingSystemName")
public static String formattedOperatingSystemName;
@ObfuscatedName("n")
@Export("inflater")
Inflater inflater;
@@ -49,4 +50,4 @@ public class GZipDecompressor {
throw new RuntimeException("");
}
} // L: 27
}
}

View File

@@ -56,7 +56,8 @@ public class JagexCache {
@Export("cacheGamebuild")
static int cacheGamebuild;
@ObfuscatedName("p")
static String field2065;
@Export("operatingSystemName")
static String operatingSystemName;
@ObfuscatedName("m")
@Export("userHomeDirectory")
static String userHomeDirectory;
@@ -225,4 +226,4 @@ public class JagexCache {
return 2; // L: 2643
}
}
}
}

View File

@@ -246,17 +246,18 @@ public final class Projectile extends Renderable {
descriptor = "(Ljava/lang/String;Ljava/lang/String;IIB)V",
garbageValue = "23"
)
public static void method2255(String var0, String var1, int var2, int var3) throws IOException {
@Export("findAndLoadCache")
public static void findAndLoadCache(String var0, String var1, int var2, int var3) throws IOException {
JagexCache.idxCount = var3; // L: 40
JagexCache.cacheGamebuild = var2; // L: 41
try {
JagexCache.field2065 = System.getProperty("os.name"); // L: 43
JagexCache.operatingSystemName = System.getProperty("os.name"); // L: 43
} catch (Exception var28) { // L: 45
JagexCache.field2065 = "Unknown"; // L: 46
JagexCache.operatingSystemName = "Unknown"; // L: 46
}
GZipDecompressor.field4046 = JagexCache.field2065.toLowerCase(); // L: 48
GZipDecompressor.formattedOperatingSystemName = JagexCache.operatingSystemName.toLowerCase(); // L: 48
try {
JagexCache.userHomeDirectory = System.getProperty("user.home"); // L: 50
@@ -267,7 +268,7 @@ public final class Projectile extends Renderable {
}
try {
if (GZipDecompressor.field4046.startsWith("win")) { // L: 55
if (GZipDecompressor.formattedOperatingSystemName.startsWith("win")) { // L: 55
if (JagexCache.userHomeDirectory == null) { // L: 56
JagexCache.userHomeDirectory = System.getenv("USERPROFILE");
}
@@ -285,8 +286,8 @@ public final class Projectile extends Renderable {
JagexCache.userHomeDirectory = "~/";
}
class224.field2576 = new String[]{"c:/rscache/", "/rscache/", "c:/windows/", "c:/winnt/", "c:/", JagexCache.userHomeDirectory, "/tmp/", ""}; // L: 65
Timer.field3621 = new String[]{".jagex_cache_" + JagexCache.cacheGamebuild, ".file_store_" + JagexCache.cacheGamebuild}; // L: 66
class224.cacheParentPaths = new String[]{"c:/rscache/", "/rscache/", "c:/windows/", "c:/winnt/", "c:/", JagexCache.userHomeDirectory, "/tmp/", ""}; // L: 65
Timer.cacheSubPaths = new String[]{".jagex_cache_" + JagexCache.cacheGamebuild, ".file_store_" + JagexCache.cacheGamebuild}; // L: 66
int var18 = 0;
label250:
@@ -347,7 +348,7 @@ public final class Projectile extends Renderable {
if (var7 != null) { // L: 109
var33 = new File(var7, "test.dat"); // L: 110
if (!class23.method235(var33, true)) { // L: 111
if (!class23.isWriteable(var33, true)) { // L: 111
var7 = null; // L: 112
}
}
@@ -355,10 +356,10 @@ public final class Projectile extends Renderable {
if (var7 == null && var18 == 0) { // L: 116
label225:
for (int var19 = 0; var19 < Timer.field3621.length; ++var19) { // L: 117
for (int var20 = 0; var20 < class224.field2576.length; ++var20) { // L: 118
File var21 = new File(class224.field2576[var20] + Timer.field3621[var19] + File.separatorChar + var0 + File.separatorChar); // L: 119
if (var21.exists() && class23.method235(new File(var21, "test.dat"), true)) { // L: 120 121
for (int var19 = 0; var19 < Timer.cacheSubPaths.length; ++var19) { // L: 117
for (int var20 = 0; var20 < class224.cacheParentPaths.length; ++var20) { // L: 118
File var21 = new File(class224.cacheParentPaths[var20] + Timer.cacheSubPaths[var19] + File.separatorChar + var0 + File.separatorChar); // L: 119
if (var21.exists() && class23.isWriteable(new File(var21, "test.dat"), true)) { // L: 120 121
var7 = var21.toString(); // L: 122
var9 = true; // L: 123
break label225; // L: 124
@@ -429,7 +430,7 @@ public final class Projectile extends Renderable {
for (int var23 = 0; var23 < var34.length; ++var23) { // L: 184
File var24 = var34[var23]; // L: 185
if (!class23.method235(var24, false)) { // L: 187
if (!class23.isWriteable(var24, false)) { // L: 187
++var18; // L: 67
continue label250;
}
@@ -438,8 +439,8 @@ public final class Projectile extends Renderable {
break;
}
class3.method36(JagexCache.cacheDir); // L: 194
Varcs.method2346(); // L: 195
class3.assetCacheDirExists(JagexCache.cacheDir); // L: 194
Varcs.findOrCreateRandomDatFile(); // L: 195
JagexCache.JagexCache_dat2File = new BufferedFile(new AccessFile(GraphicsObject.getFile("main_file_cache.dat2"), "rw", 1048576000L), 5200, 0); // L: 196
JagexCache.JagexCache_idx255File = new BufferedFile(new AccessFile(GraphicsObject.getFile("main_file_cache.idx255"), "rw", 1048576L), 6000, 0); // L: 197
WorldMapEvent.JagexCache_idxFiles = new BufferedFile[JagexCache.idxCount]; // L: 198
@@ -690,4 +691,4 @@ public final class Projectile extends Renderable {
}
} // L: 9183
}
}

View File

@@ -8,7 +8,8 @@ import net.runelite.mapping.ObfuscatedSignature;
@Implements("Timer")
public class Timer {
@ObfuscatedName("f")
static String[] field3621;
@Export("cacheSubPaths")
static String[] cacheSubPaths;
@ObfuscatedName("n")
@ObfuscatedGetter(
longValue = -2999131098664295081L
@@ -175,4 +176,4 @@ public class Timer {
var1.writeShort(this.field3613); // L: 76
var1.writeShort(this.field3619); // L: 77
} // L: 78
}
}

View File

@@ -398,7 +398,8 @@ public class Varcs {
descriptor = "(B)V",
garbageValue = "0"
)
static void method2346() {
@Export("findOrCreateRandomDatFile")
static void findOrCreateRandomDatFile() {
try {
File var0 = new File(JagexCache.userHomeDirectory, "random.dat"); // L: 250
int var2;
@@ -406,9 +407,9 @@ public class Varcs {
JagexCache.JagexCache_randomDat = new BufferedFile(new AccessFile(var0, "rw", 25L), 24, 0); // L: 252
} else {
label39:
for (int var1 = 0; var1 < Timer.field3621.length; ++var1) { // L: 255
for (var2 = 0; var2 < class224.field2576.length; ++var2) { // L: 256
File var3 = new File(class224.field2576[var2] + Timer.field3621[var1] + File.separatorChar + "random.dat"); // L: 257
for (int var1 = 0; var1 < Timer.cacheSubPaths.length; ++var1) { // L: 255
for (var2 = 0; var2 < class224.cacheParentPaths.length; ++var2) { // L: 256
File var3 = new File(class224.cacheParentPaths[var2] + Timer.cacheSubPaths[var1] + File.separatorChar + "random.dat"); // L: 257
if (var3.exists()) { // L: 258
JagexCache.JagexCache_randomDat = new BufferedFile(new AccessFile(var3, "rw", 25L), 24, 0); // L: 259
break label39; // L: 260
@@ -430,4 +431,4 @@ public class Varcs {
}
} // L: 276
}
}

View File

@@ -1,3 +1,4 @@
import net.runelite.mapping.Export;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
@@ -12,7 +13,8 @@ public class class224 {
@ObfuscatedName("c")
public static final short[][] field2574;
@ObfuscatedName("x")
static String[] field2576;
@Export("cacheParentPaths")
static String[] cacheParentPaths;
static {
field2577 = new short[]{6798, 8741, 25238, 4626, 4550}; // L: 4
@@ -90,4 +92,4 @@ public class class224 {
FileSystem.rasterProvider.apply(); // L: 5814
} // L: 5815
}
}

View File

@@ -13,7 +13,8 @@ public class class23 {
descriptor = "(Ljava/io/File;ZI)Z",
garbageValue = "-1646838359"
)
static boolean method235(File var0, boolean var1) {
@Export("isWriteable")
static boolean isWriteable(File var0, boolean deleteAfterWrite) {
try {
RandomAccessFile var2 = new RandomAccessFile(var0, "rw"); // L: 206
int var3 = var2.read(); // L: 207
@@ -21,7 +22,7 @@ public class class23 {
var2.write(var3); // L: 209
var2.seek(0L); // L: 210
var2.close(); // L: 211
if (var1) { // L: 212
if (deleteAfterWrite) { // L: 212
var0.delete();
}
@@ -136,4 +137,4 @@ public class class23 {
}
} // L: 2665
}
}

View File

@@ -119,7 +119,8 @@ public class class3 implements Enumerated {
descriptor = "(Ljava/io/File;B)V",
garbageValue = "1"
)
static void method36(File var0) {
@Export("assetCacheDirExists")
static void assetCacheDirExists(File var0) {
FileSystem.FileSystem_cacheDir = var0; // L: 16
if (!FileSystem.FileSystem_cacheDir.exists()) { // L: 17
throw new RuntimeException("");
@@ -212,4 +213,4 @@ public class class3 implements Enumerated {
return var2; // L: 100
}
}
}