Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 3ea75bf

Browse files
committed
fix: Debugging 1.1 compatibility
1 parent 3c21655 commit 3ea75bf

4 files changed

Lines changed: 86 additions & 61 deletions

File tree

client/src/main/java/client.java

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,13 +3635,16 @@ private void drawMinimap() {
36353635
}
36363636

36373637
@OriginalMember(owner = "client!client", name = "b", descriptor = "(B)Ljava/awt/Component;")
3638-
@Override
36393638
protected Component getBaseComponent() {
3640-
if (signlink.mainapp == null) {
3641-
return this;
3642-
} else {
3639+
if (signlink.mainapp != null) {
36433640
return signlink.mainapp;
36443641
}
3642+
3643+
if (super.frame != null) {
3644+
return super.frame;
3645+
}
3646+
3647+
return this;
36453648
}
36463649

36473650
@OriginalMember(owner = "client!client", name = "m", descriptor = "(I)V")
@@ -3930,10 +3933,10 @@ private void readNpcInfo(@OriginalArg(0) Packet buf, @OriginalArg(1) int size) {
39303933
@OriginalMember(owner = "client!client", name = "a", descriptor = "(Ljava/lang/Runnable;I)V")
39313934
@Override
39323935
public void startThread(@OriginalArg(0) Runnable runnable, @OriginalArg(1) int priority) {
3933-
if (signlink.mainapp == null) {
3934-
super.startThread(runnable, priority);
3935-
} else {
3936+
if (signlink.mainapp != null) {
39363937
signlink.startthread(runnable, priority);
3938+
} else {
3939+
super.startThread(runnable, priority);
39373940
}
39383941
}
39393942

@@ -5979,11 +5982,15 @@ private void useMenuOption(@OriginalArg(1) int optionId) {
59795982

59805983
@OriginalMember(owner = "client!client", name = "s", descriptor = "(I)Ljava/lang/String;")
59815984
private String getHost() {
5982-
if (signlink.mainapp == null) {
5983-
return super.frame == null ? super.getDocumentBase().getHost().toLowerCase() : "runescape.com";
5984-
} else {
5985+
if (signlink.mainapp != null) {
59855986
return signlink.mainapp.getDocumentBase().getHost().toLowerCase();
59865987
}
5988+
5989+
if (super.frame != null) {
5990+
return "2004scape.org";
5991+
}
5992+
5993+
return super.getDocumentBase().getHost().toLowerCase();
59875994
}
59885995

59895996
@OriginalMember(owner = "client!client", name = "t", descriptor = "(I)V")
@@ -7247,7 +7254,11 @@ private void showContextMenu() {
72477254

72487255
@OriginalMember(owner = "client!client", name = "a", descriptor = "(Ljava/lang/String;)Ljava/io/DataInputStream;")
72497256
private DataInputStream openUrl(@OriginalArg(0) String url) throws IOException {
7250-
return signlink.mainapp == null ? new DataInputStream((new URL(this.getCodeBase(), url)).openStream()) : signlink.openurl(url);
7257+
if (signlink.mainapp != null) {
7258+
return signlink.openurl(url);
7259+
}
7260+
7261+
return new DataInputStream((new URL(this.getCodeBase(), url)).openStream());
72517262
}
72527263

72537264
@OriginalMember(owner = "client!client", name = "j", descriptor = "(B)V")
@@ -7853,7 +7864,11 @@ protected void unload() {
78537864

78547865
@OriginalMember(owner = "client!client", name = "A", descriptor = "(I)Ljava/net/Socket;")
78557866
private Socket openSocket(@OriginalArg(0) int port) throws IOException {
7856-
return signlink.mainapp == null ? new Socket(InetAddress.getByName(this.getCodeBase().getHost()), port) : signlink.opensocket(port);
7867+
if (signlink.mainapp != null) {
7868+
return signlink.opensocket(port);
7869+
}
7870+
7871+
return new Socket(InetAddress.getByName(this.getCodeBase().getHost()), port);
78577872
}
78587873

78597874
@OriginalMember(owner = "client!client", name = "a", descriptor = "(ZIILclient!z;I)V")
@@ -9124,7 +9139,11 @@ private void readNpcs(@OriginalArg(1) Packet buf, @OriginalArg(2) int size) {
91249139
@OriginalMember(owner = "client!client", name = "getParameter", descriptor = "(Ljava/lang/String;)Ljava/lang/String;")
91259140
@Override
91269141
public String getParameter(@OriginalArg(0) String name) {
9127-
return signlink.mainapp == null ? super.getParameter(name) : signlink.mainapp.getParameter(name);
9142+
if (signlink.mainapp != null) {
9143+
return signlink.mainapp.getParameter(name);
9144+
}
9145+
9146+
return super.getParameter(name);
91289147
}
91299148

91309149
@OriginalMember(owner = "client!client", name = "l", descriptor = "(Z)V")
@@ -9522,7 +9541,7 @@ private void drawError() {
95229541
g.setColor(Color.white);
95239542
g.drawString("Error - unable to load game!", 50, 50);
95249543
g.drawString("To play RuneScape make sure you play from", 50, 100);
9525-
g.drawString("http://www.runescape.com", 50, 150);
9544+
g.drawString("http://2004scape.org", 50, 150);
95269545
}
95279546

95289547
if (this.errorStarted) {
@@ -11312,14 +11331,17 @@ private boolean isFriend(@OriginalArg(1) String username) {
1131211331
public void init() {
1131311332
nodeId = Integer.parseInt(this.getParameter("nodeid"));
1131411333
portOffset = Integer.parseInt(this.getParameter("portoff"));
11334+
1131511335
@Pc(15) String lowmem = this.getParameter("lowmem");
1131611336
if (lowmem != null && lowmem.equals("1")) {
1131711337
setLowMemory();
1131811338
} else {
1131911339
setHighMemory();
1132011340
}
11341+
1132111342
@Pc(31) String free = this.getParameter("free");
1132211343
members = free == null || !free.equals("1");
11344+
1132311345
this.initApplet(789, 532);
1132411346
}
1132511347

client/src/main/java/jagex2/client/GameShell.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import java.applet.Applet;
1111
import java.awt.*;
1212
import java.awt.event.*;
13+
import java.net.InetAddress;
14+
15+
import sign.signlink;
1316

1417
@OriginalClass("client!a")
1518
public class GameShell extends Applet implements Runnable, MouseListener, MouseMotionListener, KeyListener, FocusListener, WindowListener {
@@ -87,7 +90,6 @@ public class GameShell extends Applet implements Runnable, MouseListener, MouseM
8790
protected final void initApplication(@OriginalArg(1) int width, @OriginalArg(0) int height) {
8891
this.screenWidth = width;
8992
this.screenHeight = height;
90-
// this.setPreferredSize(new Dimension(this.screenWidth, this.screenHeight));
9193
this.frame = new ViewBox(this, this.screenWidth, this.screenHeight);
9294
this.graphics = this.getBaseComponent().getGraphics();
9395
this.drawArea = new PixMap(this.getBaseComponent(), this.screenWidth, this.screenHeight);
@@ -274,9 +276,10 @@ public final void mousePressed(@OriginalArg(0) MouseEvent e) {
274276
@Pc(2) int x = e.getX();
275277
@Pc(5) int y = e.getY();
276278

277-
Insets insets = this.getInsets();
278-
x -= insets.left;
279-
y -= insets.top;
279+
if (this.frame != null) {
280+
x -= this.frame.insets.left;
281+
y -= this.frame.insets.top;
282+
}
280283

281284
this.idleCycles = 0;
282285
this.mouseClickX = x;
@@ -348,9 +351,10 @@ public final void mouseDragged(@OriginalArg(0) MouseEvent e) {
348351
@Pc(2) int x = e.getX();
349352
@Pc(5) int y = e.getY();
350353

351-
Insets insets = this.getInsets();
352-
x -= insets.left;
353-
y -= insets.top;
354+
if (this.frame != null) {
355+
x -= this.frame.insets.left;
356+
y -= this.frame.insets.top;
357+
}
354358

355359
this.idleCycles = 0;
356360
this.mouseX = x;
@@ -366,9 +370,10 @@ public final void mouseMoved(@OriginalArg(0) MouseEvent e) {
366370
@Pc(2) int x = e.getX();
367371
@Pc(5) int y = e.getY();
368372

369-
Insets insets = this.getInsets();
370-
x -= insets.left;
371-
y -= insets.top;
373+
if (this.frame != null) {
374+
x -= this.frame.insets.left;
375+
y -= this.frame.insets.top;
376+
}
372377

373378
this.idleCycles = 0;
374379
this.mouseX = x;
@@ -566,6 +571,10 @@ protected void refresh() {
566571

567572
@OriginalMember(owner = "client!a", name = "b", descriptor = "(B)Ljava/awt/Component;")
568573
protected Component getBaseComponent() {
574+
if (this.frame != null) {
575+
return this.frame;
576+
}
577+
569578
return this;
570579
}
571580

client/src/main/java/jagex2/client/ViewBox.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.openrs2.deob.annotation.OriginalArg;
44
import org.openrs2.deob.annotation.OriginalClass;
55
import org.openrs2.deob.annotation.OriginalMember;
6+
import org.openrs2.deob.annotation.Pc;
67

78
import java.awt.*;
89

@@ -12,22 +13,25 @@ public class ViewBox extends Frame {
1213
@OriginalMember(owner = "client!b", name = "b", descriptor = "Lclient!a;")
1314
private final GameShell shell;
1415

16+
public final Insets insets;
17+
1518
@OriginalMember(owner = "client!b", name = "<init>", descriptor = "(IILclient!a;I)V")
1619
public ViewBox(@OriginalArg(2) GameShell shell, @OriginalArg(3) int width, @OriginalArg(0) int height) {
1720
this.shell = shell;
1821
this.setTitle("Jagex");
1922
this.setResizable(false);
20-
21-
this.setLayout(new BorderLayout());
22-
this.add(shell);
23-
this.pack();
24-
25-
// for compatibility with Java < 1.4
26-
Insets insets = this.getInsets();
27-
this.setSize(width + insets.left + insets.bottom, height + insets.top + insets.bottom);
28-
this.setVisible(true);
29-
23+
this.show();
3024
this.toFront();
25+
this.insets = this.getInsets();
26+
this.resize(width + this.insets.left + this.insets.bottom, height + this.insets.top + this.insets.bottom);
27+
}
28+
29+
@OriginalMember(owner = "client!b", name = "getGraphics", descriptor = "()Ljava/awt/Graphics;")
30+
@Override
31+
public Graphics getGraphics() {
32+
@Pc(2) Graphics g = super.getGraphics();
33+
g.translate(this.insets.left, this.insets.top);
34+
return g;
3135
}
3236

3337
@OriginalMember(owner = "client!b", name = "update", descriptor = "(Ljava/awt/Graphics;)V")

client/src/main/java/sign/signlink.java

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -145,46 +145,33 @@ public static void startpriv(@OriginalArg(0) InetAddress address) {
145145
@OriginalMember(owner = "client!sign/signlink", name = "findcachedir", descriptor = "()Ljava/lang/String;")
146146
public static String findcachedir() {
147147
@Pc(50) String[] paths = new String[] {
148-
// prioritize home directories
149-
System.getProperty("user.home"),
150-
// System.getenv("HOME"), System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH"), System.getenv("USERPROFILE"),
151-
// System.getenv("user.home"), "~",
152-
// fall back to OS-specific paths
153-
"c:", "c:/windows", "c:/winnt", "d:/windows", "d:/winnt", "e:/windows", "e:/winnt", "f:/windows", "f:/winnt",
154-
// fall back to temporary cache directories (RAM or browser cache)
155-
"/tmp", ""
148+
"c:/windows/", "c:/winnt/", "d:/windows/", "d:/winnt/", "e:/windows/", "e:/winnt/", "f:/windows/", "f:/winnt/", "c:/",
149+
"~/", "/tmp/", ""
156150
};
157-
@Pc(52) String dir = ".lostcity";
151+
@Pc(52) String store = ".file_store_32";
158152

159153
for (@Pc(54) int i = 0; i < paths.length; i++) {
160154
try {
161-
@Pc(59) String path = paths[i];
162-
@Pc(67) File file;
155+
@Pc(59) String dir = paths[i];
156+
@Pc(67) File cache;
163157

164-
if (path == null) {
165-
continue;
166-
}
158+
if (dir.length() > 0) {
159+
cache = new File(dir);
167160

168-
if (path.length() > 0) {
169-
file = new File(path);
170-
171-
if (!file.exists()) {
161+
if (!cache.exists() || !cache.canWrite()) {
162+
System.out.println("Unable to find or write to cache directory: " + dir);
172163
continue;
173164
}
174165
}
175166

176-
file = new File(path + "/" + dir);
177-
if ((!file.exists() && !file.mkdir()) || !file.canWrite()) {
178-
continue;
179-
}
180-
181-
file = new File(path + "/" + dir + "/" + signlink.clientversion);
182-
if ((!file.exists() && !file.mkdir()) || !file.canWrite()) {
167+
cache = new File(dir + store);
168+
if ((!cache.exists() && !cache.mkdir()) || !cache.canWrite()) {
169+
System.out.println("Unable to find or write to cache directory: " + dir + store + "/");
183170
continue;
184171
}
185172

186-
return path + "/" + dir + "/" + signlink.clientversion + "/";
187-
} catch (@Pc(102) Exception ignored) {
173+
return dir + store + "/";
174+
} catch (@Pc(102) Exception _ex) {
188175
}
189176
}
190177

@@ -398,6 +385,9 @@ public void run() {
398385

399386
@Pc(3) String cacheDir = findcachedir();
400387
uid = getuid(cacheDir);
388+
if (cacheDir == null) {
389+
cacheDir = "";
390+
}
401391

402392
@Pc(8) int threadId = threadliveid;
403393
while (threadliveid == threadId) {

0 commit comments

Comments
 (0)