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 byte var9 = 0; // L: 775
try { try {
Projectile.method2255("oldschool", var8, var9, 21); // L: 777 Projectile.findAndLoadCache("oldschool", var8, var9, 21); // L: 777
} catch (Exception var10) { // L: 779 } catch (Exception var10) { // L: 779
SequenceDefinition.RunException_sendStackTrace((String)null, var10); // L: 780 SequenceDefinition.RunException_sendStackTrace((String)null, var10); // L: 780
} }

View File

@@ -31,11 +31,11 @@ public class DesktopPlatformInfoProvider implements PlatformInfoProvider {
@Export("get") @Export("get")
public PlatformInfo get() { public PlatformInfo get() {
byte var1; byte var1;
if (GZipDecompressor.field4046.startsWith("win")) { // L: 15 if (GZipDecompressor.formattedOperatingSystemName.startsWith("win")) { // L: 15
var1 = 1; var1 = 1;
} else if (GZipDecompressor.field4046.startsWith("mac")) { // L: 16 } else if (GZipDecompressor.formattedOperatingSystemName.startsWith("mac")) { // L: 16
var1 = 2; var1 = 2;
} else if (GZipDecompressor.field4046.startsWith("linux")) { } else if (GZipDecompressor.formattedOperatingSystemName.startsWith("linux")) {
var1 = 3; var1 = 3;
} else { } else {
var1 = 4; // L: 18 var1 = 4; // L: 18

View File

@@ -8,7 +8,8 @@ import net.runelite.mapping.ObfuscatedSignature;
@Implements("GZipDecompressor") @Implements("GZipDecompressor")
public class GZipDecompressor { public class GZipDecompressor {
@ObfuscatedName("t") @ObfuscatedName("t")
public static String field4046; @Export("formattedOperatingSystemName")
public static String formattedOperatingSystemName;
@ObfuscatedName("n") @ObfuscatedName("n")
@Export("inflater") @Export("inflater")
Inflater inflater; Inflater inflater;

View File

@@ -56,7 +56,8 @@ public class JagexCache {
@Export("cacheGamebuild") @Export("cacheGamebuild")
static int cacheGamebuild; static int cacheGamebuild;
@ObfuscatedName("p") @ObfuscatedName("p")
static String field2065; @Export("operatingSystemName")
static String operatingSystemName;
@ObfuscatedName("m") @ObfuscatedName("m")
@Export("userHomeDirectory") @Export("userHomeDirectory")
static String userHomeDirectory; static String userHomeDirectory;

View File

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

View File

@@ -8,7 +8,8 @@ import net.runelite.mapping.ObfuscatedSignature;
@Implements("Timer") @Implements("Timer")
public class Timer { public class Timer {
@ObfuscatedName("f") @ObfuscatedName("f")
static String[] field3621; @Export("cacheSubPaths")
static String[] cacheSubPaths;
@ObfuscatedName("n") @ObfuscatedName("n")
@ObfuscatedGetter( @ObfuscatedGetter(
longValue = -2999131098664295081L longValue = -2999131098664295081L

View File

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

View File

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

View File

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

View File

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