Skip to content

Commit 22ad114

Browse files
authored
Merge pull request #176 from runejs/move-out-of-movedstatics
refactor: moving some more statics around
2 parents ff5ab42 + 84c5d12 commit 22ad114

21 files changed

+119
-128
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: 15 additions & 13 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());
@@ -1313,8 +1315,8 @@ else if(x > 764)
13131315
MovedStatics.crossType = 0;
13141316
}
13151317
if(GameInterface.atInventoryInterfaceType != 0) {
1316-
RSRuntimeException.anInt1651++;
1317-
if(RSRuntimeException.anInt1651 >= 15) {
1318+
GameInterface.anInt1651++;
1319+
if(GameInterface.anInt1651 >= 15) {
13181320
if(GameInterface.atInventoryInterfaceType == 2)
13191321
GameInterface.redrawTabArea = true;
13201322
if(GameInterface.atInventoryInterfaceType == 3)
@@ -1334,9 +1336,9 @@ else if(x > 764)
13341336
GameInterface.redrawTabArea = true;
13351337
GameInterface.activeInterfaceType = 0;
13361338
if(MovedStatics.lastItemDragged && Buffer.lastItemDragTime >= 5) {
1337-
RSRuntimeException.lastActiveInvInterface = -1;
1339+
GameInterface.lastActiveInvInterface = -1;
13381340
MovedStatics.processRightClick();
1339-
if(RSRuntimeException.lastActiveInvInterface == GameInterface.modifiedWidgetId && mouseInvInterfaceIndex != GameInterface.selectedInventorySlot) {
1341+
if(GameInterface.lastActiveInvInterface == GameInterface.modifiedWidgetId && mouseInvInterfaceIndex != GameInterface.selectedInventorySlot) {
13401342
GameInterface childInterface = GameInterface.getInterface(GameInterface.modifiedWidgetId);
13411343
int moveItemInsertionMode = 0;
13421344
if(MovedStatics.bankInsertMode == 1 && childInterface.contentType == 206)
@@ -1380,7 +1382,7 @@ else if(x > 764)
13801382
else if(MovedStatics.menuActionRow > 0)
13811383
GameInterface.processMenuActions(MovedStatics.menuActionRow - 1);
13821384
}
1383-
RSRuntimeException.anInt1651 = 10;
1385+
GameInterface.anInt1651 = 10;
13841386
MouseHandler.clickType = 0;
13851387
}
13861388
}
@@ -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/Landscape.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class Landscape {
4949
public static int[] terrainDataIds;
5050
public static int[][][] tile_height = new int[4][105][105];
5151
public static int randomiserLightness = -16 + (int) (Math.random() * 33.0);
52+
public static int randomiserHue = -8 + (int) (17.0 * Math.random());
5253
private static int lowestPlane = 99;
5354

5455
public static void loadRegion() {
@@ -245,7 +246,7 @@ public static void loadRegion() {
245246
MovedStatics.processGameStatus(30);
246247
method973();
247248
OutgoingPackets.buffer.putPacket(178);
248-
RSRuntimeException.method1057(126);
249+
MovedStatics.method1057();
249250
} else
250251
MovedStatics.anInt1634 = 2;
251252
} else
@@ -380,12 +381,12 @@ private static void createRegion(Scene scene, CollisionMap[] collisionMaps) {
380381
}
381382
}
382383
}
383-
MovedStatics.randomiserHue += (int) (5.0 * Math.random()) + -2;
384+
randomiserHue += (int) (5.0 * Math.random()) + -2;
384385
randomiserLightness += -2 + (int) (5.0 * Math.random());
385-
if(MovedStatics.randomiserHue < -8)
386-
MovedStatics.randomiserHue = -8;
387-
if(MovedStatics.randomiserHue > 8)
388-
MovedStatics.randomiserHue = 8;
386+
if(randomiserHue < -8)
387+
randomiserHue = -8;
388+
if(randomiserHue > 8)
389+
randomiserHue = 8;
389390
if(randomiserLightness < -16)
390391
randomiserLightness = -16;
391392
if(randomiserLightness > 16)
@@ -487,7 +488,7 @@ private static void createRegion(Scene scene, CollisionMap[] collisionMaps) {
487488
int l = lightness / direction;
488489
hslBitsetOriginal = generateHslBitset(s, l, h);
489490
l += randomiserLightness;
490-
h = h + MovedStatics.randomiserHue & 0xff;
491+
h = h + randomiserHue & 0xff;
491492
if(l >= 0) {
492493
if(l > 255)
493494
l = 255;
@@ -523,7 +524,7 @@ private static void createRegion(Scene scene, CollisionMap[] collisionMaps) {
523524
overlayMinimapColour = -2;
524525
} else {
525526
hslBitset = generateHslBitset(overlayDefinition.lightness, overlayDefinition.saturation, overlayDefinition.hue);
526-
int h = MovedStatics.randomiserHue + overlayDefinition.hue & 0xff;
527+
int h = randomiserHue + overlayDefinition.hue & 0xff;
527528
int s = randomiserLightness + overlayDefinition.saturation;
528529
if(s < 0)
529530
s = 0;
@@ -535,7 +536,7 @@ else if(s > 255)
535536
if(overlayMinimapColour != -2)
536537
rgb = Rasterizer3D.hsl2rgb[MovedStatics.mixLightnessSigned(overlayMinimapColour, 96)];
537538
if(overlayDefinition.secondaryColor != -1) {
538-
int i_54_ = 0xff & MovedStatics.randomiserHue + overlayDefinition.otherHue;
539+
int i_54_ = 0xff & randomiserHue + overlayDefinition.otherHue;
539540
int i_55_ = overlayDefinition.otherSaturation + randomiserLightness;
540541
if(i_55_ >= 0) {
541542
if(i_55_ > 255)

0 commit comments

Comments
 (0)