Enhance socket management and improve android support

- Added proper socket closure and nullification in OnDemandFetcher to prevent resource leaks.
- Introduced touch target areas in RSApplet to streamline touch interactions.
- Made fullGameScreen public in RSApplet for external access.
- Implemented a master screen buffer and a locking mechanism in RSImageProducer for better synchronization.
- Reduced initial sleep duration in Signlink and added a close method for better resource management.
- Increased texture array sizes in Texture for improved rendering capabilities.
- Modified WorldController to optimize rendering logic based on platform (Android) and enhance performance.
This commit is contained in:
Dark98 committed 2026-11-10 20:34:25 +00:00
1 parent 9570a35bae
commit 87fece4854
9 files changed
+622 -244

No files matched your search

@@ -13,6 +13,13 @@ public class ClientSettings {
*/
public static boolean ANDROID = false;
/**
* Viewport dimensions for 3D rendering.
* Default 512x334 in fixed mode; scaled to native widescreen in resizable mode.
*/
public static int VIEWPORT_WIDTH = 512;
public static int VIEWPORT_HEIGHT = 334;
/**
* @QoL
* Require control key to zoom the client
File diff suppressed because it is too large. Load diff
@@ -210,6 +210,14 @@ public final class OnDemandFetcher extends OnDemandFetcherParent implements Runn
public void disable() {
running = false;
try {
if (socket != null) {
socket.close();
}
} catch (Exception ignored) {}
socket = null;
inputStream = null;
outputStream = null;
}
public void method554(boolean flag) {
+8 -1
View File
@@ -19,6 +19,13 @@ public class RSApplet extends Applet implements Runnable, MouseListener, MouseWh
private int mouseWheelY = 0;
public static boolean removeShiftDropOnMenuOpen;
public static final int TARGET_DEFAULT = 0;
public static final int TARGET_VIEWPORT = 1;
public static final int TARGET_TAB = 2;
public static final int TARGET_CHAT = 3;
public static final int TARGET_MINIMAP = 4;
public static int touchTargetArea = TARGET_DEFAULT;
final void createClientFrame(int i, int j) {
myWidth = j;
myHeight = i;
@@ -738,7 +745,7 @@ public class RSApplet extends Applet implements Runnable, MouseListener, MouseWh
int myWidth;
int myHeight;
Graphics graphics;
RSImageProducer fullGameScreen;
public RSImageProducer fullGameScreen;
RSFrame gameFrame;
private boolean shouldClearScreen;
boolean awtFocus;
@@ -13,6 +13,9 @@ import java.awt.image.ImageProducer;
final class RSImageProducer implements ImageProducer, ImageObserver {
public static final int[] masterScreenBuffer = new int[765 * 503];
public static final Object masterBufferLock = new Object();
public RSImageProducer(int i, int j, Component component) {
anInt316 = i;
anInt317 = j;
+38 -4
View File
@@ -13,10 +13,10 @@ public final class Signlink implements Runnable {
threadliveid = (int) (Math.random() * 99999999D);
if (active) {
try {
Thread.sleep(500L);
Thread.sleep(100L);
} catch (Exception _ex) {
}
active = false;
close();
}
socketreq = 0;
threadreq = null;
@@ -24,6 +24,7 @@ public final class Signlink implements Runnable {
saveReq = null;
urlreq = null;
socketip = inetaddress;
reporterror = true;
Thread thread = new Thread(new Signlink());
thread.setDaemon(true);
thread.start();
@@ -35,6 +36,32 @@ public final class Signlink implements Runnable {
}
}
public static synchronized void close() {
active = false;
threadliveid = 0;
reporterror = true;
try {
if (cache_dat != null) {
cache_dat.close();
cache_dat = null;
}
} catch (Exception ignored) {}
for (int j = 0; j < 5; j++) {
try {
if (cache_idx[j] != null) {
cache_idx[j].close();
cache_idx[j] = null;
}
} catch (Exception ignored) {}
}
try {
if (socket != null) {
socket.close();
socket = null;
}
} catch (Exception ignored) {}
}
enum Position {
LEFT, RIGHT, NORMAL
};
@@ -44,15 +71,22 @@ public final class Signlink implements Runnable {
@Override
public void run() {
active = true;
String s = findcachedir();
try {
if (cache_dat != null) {
try { cache_dat.close(); } catch (Exception ignored) {}
}
cache_dat = new RandomAccessFile(s + "main_file_cache.dat", "rw");
for (int j = 0; j < 5; j++)
for (int j = 0; j < 5; j++) {
if (cache_idx[j] != null) {
try { cache_idx[j].close(); } catch (Exception ignored) {}
}
cache_idx[j] = new RandomAccessFile(s + "main_file_cache.idx" + j, "rw");
}
} catch (Exception exception) {
exception.printStackTrace();
}
active = true;
for (int i = threadliveid; threadliveid == i;) {
if (socketreq != 0) {
try {
+2 -2
View File
@@ -2101,11 +2101,11 @@ final class Texture extends DrawingArea {
private static int[][] anIntArrayArray1483 = new int[50][];
static {
anIntArray1468 = new int[512];
anIntArray1468 = new int[2048];
anIntArray1469 = new int[2048];
anIntArray1470 = new int[2048];
anIntArray1471 = new int[2048];
for (int i = 1; i < 512; i++) {
for (int i = 1; i < 2048; i++) {
anIntArray1468[i] = 32768 / i;
}
@@ -929,7 +929,7 @@ final class WorldController {
for (int k2 = anInt451; k2 < anInt452; k2++) {
Ground class30_sub3 = aclass30_sub3[i2][k2];
if (class30_sub3 != null) {
if (class30_sub3.anInt1321 > i1 || !aBooleanArrayArray492[i2 - anInt453 + drawDistance][k2 - anInt454 + drawDistance] && anIntArrayArrayArray440[k1][i2][k2] - l < 50) {
if (class30_sub3.anInt1321 > i1 || (!ClientSettings.ANDROID && !aBooleanArrayArray492[i2 - anInt453 + drawDistance][k2 - anInt454 + drawDistance]) && anIntArrayArrayArray440[k1][i2][k2] - l < 50) {
class30_sub3.aBoolean1322 = false;
class30_sub3.aBoolean1323 = false;
class30_sub3.anInt1325 = 0;
@@ -1706,7 +1706,7 @@ final class WorldController {
}
boolean flag = false;
while (k1 <= j2) {
if (aBooleanArrayArray492[l][k1++]) {
if (ClientSettings.ANDROID || aBooleanArrayArray492[l][k1++]) {
flag = true;
break;
}
@@ -1746,7 +1746,7 @@ final class WorldController {
}
boolean flag1 = false;
while (l1 <= k2) {
if (aBooleanArrayArray492[l1++][i1]) {
if (ClientSettings.ANDROID || aBooleanArrayArray492[l1++][i1]) {
flag1 = true;
break;
}
@@ -1792,7 +1792,7 @@ final class WorldController {
boolean flag2 = false;
label0 : for (int i4 = i3; i4 <= l3; i4++) {
for (int j4 = i2; j4 <= l2; j4++) {
if (!aBooleanArrayArray492[i4][j4]) {
if (!ClientSettings.ANDROID && !aBooleanArrayArray492[i4][j4]) {
continue;
}
flag2 = true;