Skip to content

Commit dfe9b24

Browse files
committed
refactor: move statics out of and into MovedStatics
1 parent c7c31b6 commit dfe9b24

19 files changed

+76
-84
lines changed

src/main/java/org/runejs/client/ClientScriptRunner.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.runejs.client.language.Native;
1111
import org.runejs.client.media.renderable.actor.Player;
1212
import org.runejs.client.net.PacketBuffer;
13-
import org.runejs.client.scene.InteractiveObject;
1413
import org.runejs.client.sound.MusicSystem;
1514
import org.runejs.client.sound.SoundSystem;
1615
import org.runejs.client.util.BitUtils;
@@ -79,7 +78,7 @@ public static void handleChatNamesRightClick(int arg1) {
7978
username = username.substring(5);
8079
if((chatType == 1 || chatType == 2) && (chatType == 1 || ChatBox.publicChatMode == 0 || ChatBox.publicChatMode == 1 && Player.hasFriend(username))) {
8180
if(arg1 > i_2_ - 14 && arg1 <= i_2_ && !username.equals(Player.localPlayer.playerName)) {
82-
if(InteractiveObject.playerRights >= 1) {
81+
if(Game.playerRights >= 1) {
8382
MovedStatics.addActionRow(English.reportAbuse, 0, 0, 0, ActionRowType.REPORT_ABUSE.getId(), Native.white + username);
8483
}
8584

@@ -91,7 +90,7 @@ public static void handleChatNamesRightClick(int arg1) {
9190
if((chatType == 3 || chatType == 7) && ChatBox.splitPrivateChat == 0 && (chatType == 7 || ChatBox.privateChatMode == 0 || ChatBox.privateChatMode == 1 && Player.hasFriend(username))) {
9291
offset++;
9392
if(arg1 > -14 + i_2_ && arg1 <= i_2_) {
94-
if(InteractiveObject.playerRights >= 1) {
93+
if(Game.playerRights >= 1) {
9594
MovedStatics.addActionRow(English.reportAbuse, 0, 0, 0, ActionRowType.REPORT_ABUSE.getId(), Native.white + username);
9695
}
9796

@@ -1202,7 +1201,7 @@ public static String method532(GameInterface gameInterface, String arg2) {
12021201
str = MovedStatics.method204(MovedStatics.aSignlinkNode_394.integerData);
12031202
if (MovedStatics.aSignlinkNode_394.value != null) {
12041203
byte[] is = ((String) MovedStatics.aSignlinkNode_394.value).getBytes(StandardCharsets.ISO_8859_1);
1205-
str = InteractiveObject.method279(is, 0, is.length).toString();
1204+
str = RSString.method279(is, 0, is.length).toString();
12061205
}
12071206
}
12081207
arg2 = arg2.substring(0, i) + str + arg2.substring(i + 4);

src/main/java/org/runejs/client/Game.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ public class Game {
101101
public static int anInt292 = 0;
102102
public static boolean accountFlagged = false;
103103
public static long aLong1841;
104+
public static int clientVersion;
105+
public static int playerRights = 0;
104106
private static int gameServerPort;
105107
private static int duplicateClickCount = 0;
106108
private static int lastClickY = 0;
@@ -675,11 +677,11 @@ public static void setConfigToDefaults() {
675677
GameInterface.fullscreenSiblingInterfaceId = -1;
676678
GameInterface.resetInterface(GameInterface.tabAreaInterfaceId);
677679
GameInterface.tabAreaInterfaceId = -1;
678-
GameInterface.resetInterface(GroundItemTile.walkableWidgetId);
680+
GameInterface.resetInterface(GameInterface.walkableWidgetId);
679681
ChatBox.inputType = 0;
680682
ChatBox.messagePromptRaised = false;
681683
MovedStatics.menuOpen = false;
682-
GroundItemTile.walkableWidgetId = -1;
684+
GameInterface.walkableWidgetId = -1;
683685
Native.clickToContinueString = null;
684686
MovedStatics.lastContinueTextWidgetId = -1;
685687
flashingTabId = -1;
@@ -1274,12 +1276,12 @@ else if(x > 764)
12741276
int i_13_ = i_10_ * 765 + i;
12751277
OutgoingPackets.buffer.putIntLE((i_11_ << 19) + (i_12_ << 20) + i_13_);
12761278
}
1277-
if(InteractiveObject.anInt487 > 0)
1278-
InteractiveObject.anInt487--;
1279+
if(MovedStatics.anInt487 > 0)
1280+
MovedStatics.anInt487--;
12791281
if(MovedStatics.obfuscatedKeyStatus[96] || MovedStatics.obfuscatedKeyStatus[97] || MovedStatics.obfuscatedKeyStatus[98] || MovedStatics.obfuscatedKeyStatus[99])
12801282
MovedStatics.aBoolean565 = true;
1281-
if(MovedStatics.aBoolean565 && InteractiveObject.anInt487 <= 0) {
1282-
InteractiveObject.anInt487 = 20;
1283+
if(MovedStatics.aBoolean565 && MovedStatics.anInt487 <= 0) {
1284+
MovedStatics.anInt487 = 20;
12831285
MovedStatics.aBoolean565 = false;
12841286
OutgoingPackets.buffer.putPacket(58);
12851287
OutgoingPackets.buffer.putShortBE(Game.playerCamera.getYaw());
@@ -1661,7 +1663,7 @@ public static void handleLoginScreenActions() {
16611663
if (loginStatus == 9 && MovedStatics.gameServerSocket.inputStreamAvailable() >= 8) {
16621664
Configuration.USERNAME = Native.username.toString();
16631665
Configuration.PASSWORD = Native.password.toString();
1664-
InteractiveObject.playerRights = MovedStatics.gameServerSocket.read();
1666+
playerRights = MovedStatics.gameServerSocket.read();
16651667
accountFlagged = MovedStatics.gameServerSocket.read() == 1;
16661668
Player.localPlayerId = MovedStatics.gameServerSocket.read();
16671669
Player.localPlayerId <<= 8;
@@ -2303,7 +2305,7 @@ public void startup() {
23032305
metaChannel = null;
23042306
}
23052307
if (modewhere != 0)
2306-
InteractiveObject.showFps = true;
2308+
MovedStatics.showFps = true;
23072309
chatboxInterface = new GameInterface();
23082310
}
23092311
}

src/main/java/org/runejs/client/GameShell.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public class GameShell extends Canvas implements GameErrorHandler, Runnable, Foc
2626
public static int fps = 0;
2727
public static boolean closedClient = false;
2828
public static int currentTickSample;
29+
/**
30+
* Something to do with timing.. sleep time maybe? Not sure
31+
*/
32+
public static int anInt2024 = 1;
2933
private static volatile boolean clientFocused = true;
3034
private final int millisPerTick = 20;
3135
public boolean gameShellError = false;
@@ -113,7 +117,7 @@ public void run() {
113117
openErrorPage("wrongjava");
114118
return;
115119
}
116-
MovedStatics.anInt2024 = 5;
120+
anInt2024 = 5;
117121
}
118122
}
119123
if (Game.signlink.gameShell != null) {
@@ -133,7 +137,7 @@ public void run() {
133137

134138
// Initialize client loop
135139
while (exitTimeInMillis == 0L || System.currentTimeMillis() < exitTimeInMillis) {
136-
MovedStatics.ticksPerLoop = SceneCluster.gameTimer.getTicks(millisPerTick, MovedStatics.anInt2024);
140+
MovedStatics.ticksPerLoop = SceneCluster.gameTimer.getTicks(millisPerTick, anInt2024);
137141
for (int currentTick = 0; currentTick < MovedStatics.ticksPerLoop; currentTick++) {
138142
long currentTimeMillis = System.currentTimeMillis();
139143

@@ -272,7 +276,7 @@ public void displayClientFrame(int clientVersion, int width, int height, int fil
272276
return;
273277
}
274278
MovedStatics.width = height;
275-
MovedStatics.clientVersion = clientVersion;
279+
Game.clientVersion = clientVersion;
276280
MovedStatics.height = width;
277281
currentGameShell = this;
278282
if (Game.signlink == null) {
@@ -337,7 +341,7 @@ public void openClientApplet(String cacheFolder, int cacheIndexes, int fileStore
337341
try {
338342
int height = 503;
339343
int width = 765;
340-
MovedStatics.clientVersion = clientVersion;
344+
Game.clientVersion = clientVersion;
341345
MovedStatics.width = width;
342346
MovedStatics.height = height;
343347
currentGameShell = this;

src/main/java/org/runejs/client/MovedStatics.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,7 @@ public class MovedStatics {
251251
public static IndexedImage tabHighlightImageTopMiddle;
252252
public static ImageRGB[] cursorCross;
253253
public static ProducingGraphicsBuffer mapbackLeft;
254-
public static int clientVersion;
255254
public static int ticksPerLoop;
256-
/**
257-
* Something to do with timing.. sleep time maybe? Not sure
258-
*/
259-
public static int anInt2024 = 1;
260255
public static boolean showIconsRedrawnText = false;
261256
public static IndexedImage[] tabIcons;
262257
public static boolean lastItemDragged = false;
@@ -326,6 +321,13 @@ public class MovedStatics {
326321
public static boolean[] obfuscatedKeyStatus = new boolean[112];
327322
public static int[] crc8LookupTable = new int[256];
328323
public static int currentTickSample;
324+
public static boolean showFps = false;
325+
public static int anInt487 = 0;
326+
/**
327+
* Top row of sideicon tabs
328+
*/
329+
public static ProducingGraphicsBuffer tabTop;
330+
public static byte[][] aByteArrayArray1370;
329331

330332
public static void method440() {
331333
if (aBoolean512) {
@@ -387,7 +389,7 @@ public static void addSplitPrivateChatActionRows() {
387389
x = 450;
388390
if (MouseHandler.mouseX < 4 + x) {
389391
int actionRowOffset = ActionRowType.LOW_PRIORITY_MODIFIER;
390-
if (InteractiveObject.playerRights >= 1) {
392+
if (Game.playerRights >= 1) {
391393
addActionRow(English.reportAbuse, 0, 0, 0, actionRowOffset + ActionRowType.REPORT_ABUSE.getId(), Native.white + username);
392394
}
393395
addActionRow(English.addIgnore, 0, 0, 0, actionRowOffset + ActionRowType.ADD_IGNORE.getId(), Native.white + username);
@@ -449,7 +451,7 @@ public static IndexedImage method538() {
449451
class40_sub5_sub14_sub2.imgWidth = anIntArray456[0];
450452
class40_sub5_sub14_sub2.imgHeight = Npc.anIntArray3312[0];
451453
class40_sub5_sub14_sub2.palette = Buffer.anIntArray1972;
452-
class40_sub5_sub14_sub2.imgPixels = GroundItemTile.aByteArrayArray1370[0];
454+
class40_sub5_sub14_sub2.imgPixels = aByteArrayArray1370[0];
453455
ActorDefinition.method569();
454456
return class40_sub5_sub14_sub2;
455457
}
@@ -510,7 +512,7 @@ public static void printException(String arg0, Throwable exception) {
510512
string = string.replace('@', '_');
511513
string = string.replace('&', '_');
512514
string = string.replace('#', '_');
513-
SignlinkNode signlinkNode = signlink.addType4Node(new URL(signlink.gameShell.getCodeBase(), "clienterror.ws?c=" + clientVersion + "&u=" + aLong853 + "&v1=" + Signlink.javaVendor + "&v2=" + Signlink.javaVersion + "&e=" + string));
515+
SignlinkNode signlinkNode = signlink.addType4Node(new URL(signlink.gameShell.getCodeBase(), "clienterror.ws?c=" + Game.clientVersion + "&u=" + aLong853 + "&v1=" + Signlink.javaVendor + "&v2=" + Signlink.javaVersion + "&e=" + string));
514516
while (signlinkNode.status == 0)
515517
threadSleep(1L);
516518
if (signlinkNode.status != 1)
@@ -526,7 +528,7 @@ public static void method184(byte[] data, int arg1) {
526528
buffer.currentPosition = -2 + data.length;
527529
anInt2581 = buffer.getUnsignedShortBE();
528530
anIntArray3111 = new int[anInt2581];
529-
GroundItemTile.aByteArrayArray1370 = new byte[anInt2581][];
531+
aByteArrayArray1370 = new byte[anInt2581][];
530532
anIntArray456 = new int[anInt2581];
531533
Npc.anIntArray3312 = new int[anInt2581];
532534
anIntArray1347 = new int[anInt2581];
@@ -557,7 +559,7 @@ public static void method184(byte[] data, int arg1) {
557559
int i_41_ = anIntArray456[i_39_];
558560
int i_42_ = i_40_ * i_41_;
559561
byte[] is = new byte[i_42_];
560-
GroundItemTile.aByteArrayArray1370[i_39_] = is;
562+
aByteArrayArray1370[i_39_] = is;
561563
int i_43_ = buffer.getUnsignedByte();
562564
if (i_43_ == 0) {
563565
for (int i_46_ = 0; i_42_ > i_46_; i_46_++)
@@ -576,7 +578,7 @@ public static String method204(int arg0) {
576578
}
577579

578580
public static void method527(int currentTabId, int[] tabWidgetIds, boolean arg3, int arg4) {
579-
InteractiveObject.tabTop.prepareRasterizer();
581+
tabTop.prepareRasterizer();
580582
Buffer.tabTopBack.drawImage(0, 0);
581583
if (arg3) {
582584
if (tabWidgetIds[currentTabId] != -1) {
@@ -647,7 +649,7 @@ public static void method527(int currentTabId, int[] tabWidgetIds, boolean arg3,
647649
try {
648650
Graphics graphics = Game.gameCanvas.getGraphics();
649651
if (ScreenController.frameMode == ScreenMode.FIXED) {
650-
InteractiveObject.tabTop.drawGraphics(516, 160, graphics);
652+
tabTop.drawGraphics(516, 160, graphics);
651653
tabBottom.drawGraphics(496, 466, graphics);
652654
}
653655
} catch (Exception exception) {
@@ -1417,7 +1419,7 @@ private static void method344(int arg0) {
14171419
tabHighlightImageBottomRightEdge = null;
14181420
ChatBox.chatBoxImageProducer = null;
14191421
mapBackRight = null;
1420-
InteractiveObject.tabTop = null;
1422+
tabTop = null;
14211423
if(arg0 < -28) {
14221424
chatboxRight = null;
14231425
tabPieceUpperRight = null;
@@ -1554,9 +1556,9 @@ public static void draw3dScreen() {
15541556
if (crossType == 2) {
15551557
cursorCross[4 + crossIndex / 100].drawImage(GameInterface.crossX - 8 - 4, GameInterface.crossY - 8 - 4);
15561558
}
1557-
if (GameInterface.gameScreenInterfaceId != -1 || GroundItemTile.walkableWidgetId != -1) {
1559+
if (GameInterface.gameScreenInterfaceId != -1 || GameInterface.walkableWidgetId != -1) {
15581560
int areaId = GameInterface.gameScreenInterfaceId != -1 ? 0 : 4;
1559-
int id = GameInterface.gameScreenInterfaceId != -1 ? GameInterface.gameScreenInterfaceId : GroundItemTile.walkableWidgetId;
1561+
int id = GameInterface.gameScreenInterfaceId != -1 ? GameInterface.gameScreenInterfaceId : GameInterface.walkableWidgetId;
15601562
Renderable.handleSequences(id);
15611563
int yOffset = (ScreenController.drawHeight /2) - (334/2) - (184/2);
15621564
int xOffset = (ScreenController.drawWidth /2) - (512/2) - (234/3);
@@ -1579,7 +1581,7 @@ public static void draw3dScreen() {
15791581
if (multiCombatState == 1) {
15801582
multiCombatIcon.drawImage(472, 296);
15811583
}
1582-
if (InteractiveObject.showFps) {
1584+
if (showFps) {
15831585
int y = 20;
15841586
int x = 507;
15851587
if(ScreenController.frameMode != ScreenMode.FIXED) {
@@ -1914,7 +1916,7 @@ public static void method763(Component arg0, CacheArchive arg2) {
19141916
Rasterizer.resetPixels();
19151917
chatModes = createGraphicsBuffer(496, 50, arg0);
19161918
tabBottom = createGraphicsBuffer(269, 37, arg0);
1917-
InteractiveObject.tabTop = createGraphicsBuffer(249, 45, arg0);
1919+
tabTop = createGraphicsBuffer(249, 45, arg0);
19181920
ImageRGB image = method1028(arg2, Native.imgBackleft1, Native.aClass1_305);
19191921
framePieceRight = createGraphicsBuffer(image.imageWidth, image.imageHeight, arg0);
19201922
image.drawInverse(0, 0);

src/main/java/org/runejs/client/RSString.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ public static RSString createString(int length) {
4949
return string;
5050
}
5151

52+
public static RSString method279(byte[] arg0, int arg2, int arg3) {
53+
RSString class1 = new RSString();
54+
class1.length = 0;
55+
class1.chars = new byte[arg3];
56+
for(int i = arg2; arg3 + arg2 > i; i++) {
57+
if(arg0[i] != 0)
58+
class1.chars[class1.length++] = arg0[i];
59+
}
60+
return class1;
61+
}
62+
5263

5364
public RSString substring(int arg1) {
5465
return substring(arg1, length);

src/main/java/org/runejs/client/cache/def/ActorDefinition.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.runejs.client.media.renderable.actor.Player;
1515
import org.runejs.client.node.CachedNode;
1616
import org.runejs.client.node.NodeCache;
17-
import org.runejs.client.scene.GroundItemTile;
1817
import org.runejs.client.util.BitUtils;
1918

2019
import java.awt.*;
@@ -58,7 +57,7 @@ public class ActorDefinition extends CachedNode implements EntityDefinition {
5857

5958
public static void method569() {
6059
MovedStatics.anIntArray456 = null;
61-
GroundItemTile.aByteArrayArray1370 = null;
60+
MovedStatics.aByteArrayArray1370 = null;
6261
Npc.anIntArray3312 = null;
6362
MovedStatics.anIntArray3111 = null;
6463
Buffer.anIntArray1972 = null;
@@ -106,7 +105,7 @@ public static ImageRGB method578() {
106105
class40_sub5_sub14_sub4.offsetY = MovedStatics.anIntArray3111[0];
107106
class40_sub5_sub14_sub4.imageWidth = MovedStatics.anIntArray456[0];
108107
class40_sub5_sub14_sub4.imageHeight = Npc.anIntArray3312[0];
109-
byte[] is = GroundItemTile.aByteArrayArray1370[0];
108+
byte[] is = MovedStatics.aByteArrayArray1370[0];
110109
int i = class40_sub5_sub14_sub4.imageWidth * class40_sub5_sub14_sub4.imageHeight;
111110
class40_sub5_sub14_sub4.pixels = new int[i];
112111
for(int i_5_ = 0; i_5_ < i; i_5_++) {

src/main/java/org/runejs/client/cache/media/IndexedImage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.runejs.client.io.Buffer;
77
import org.runejs.client.media.Rasterizer;
88
import org.runejs.client.media.renderable.actor.Npc;
9-
import org.runejs.client.scene.GroundItemTile;
109

1110
public class IndexedImage extends Rasterizer {
1211
public int imgWidth;
@@ -53,7 +52,7 @@ public static IndexedImage[] method315() {
5352
class40_sub5_sub14_sub2.imgWidth = MovedStatics.anIntArray456[i];
5453
class40_sub5_sub14_sub2.imgHeight = Npc.anIntArray3312[i];
5554
class40_sub5_sub14_sub2.palette = Buffer.anIntArray1972;
56-
class40_sub5_sub14_sub2.imgPixels = GroundItemTile.aByteArrayArray1370[i];
55+
class40_sub5_sub14_sub2.imgPixels = MovedStatics.aByteArrayArray1370[i];
5756
}
5857
ActorDefinition.method569();
5958
return class40_sub5_sub14_sub2s;

src/main/java/org/runejs/client/cache/media/TypeFace.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.runejs.client.io.Buffer;
1212
import org.runejs.client.media.Rasterizer;
1313
import org.runejs.client.media.renderable.actor.Npc;
14-
import org.runejs.client.scene.GroundItemTile;
1514

1615
import java.awt.*;
1716
import java.util.Random;
@@ -99,7 +98,7 @@ public TypeFace(int[] arg0, int[] arg1, int[] arg2, int[] arg3, byte[][] arg4) {
9998
}
10099

101100
public static TypeFace constructFont() {
102-
TypeFace class40_sub5_sub14_sub1 = new TypeFace(MovedStatics.anIntArray3111, MovedStatics.anIntArray456, Npc.anIntArray3312, Buffer.anIntArray1972, GroundItemTile.aByteArrayArray1370);
101+
TypeFace class40_sub5_sub14_sub1 = new TypeFace(MovedStatics.anIntArray3111, MovedStatics.anIntArray456, Npc.anIntArray3312, Buffer.anIntArray1972, MovedStatics.aByteArrayArray1370);
103102
ActorDefinition.method569();
104103
return class40_sub5_sub14_sub1;
105104
}

0 commit comments

Comments
 (0)