Skip to content

Commit 2d5516b

Browse files
committed
refactor: remove statics from SceneCluster
1 parent a47cc70 commit 2d5516b

File tree

5 files changed

+26
-33
lines changed

5 files changed

+26
-33
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.runejs.client.cache.media.gameInterface.InterfaceModelType;
4242
import org.runejs.Configuration;
4343
import org.runejs.client.util.SignlinkNode;
44+
import org.runejs.client.util.Timer;
4445

4546
import java.awt.*;
4647
import java.io.IOException;
@@ -101,6 +102,8 @@ public class Game {
101102
public static long aLong1841;
102103
public static int clientVersion;
103104
public static int playerRights = 0;
105+
public static Timer gameTimer;
106+
public static int idleLogout = 0;
104107
/**
105108
* Backup port if the first one fails?
106109
*/
@@ -631,7 +634,7 @@ public static void setConfigToDefaults() {
631634
IncomingPackets.cyclesSinceLastPacket = 0;
632635
Player.headIconDrawType = 0;
633636
OutgoingPackets.buffer.currentPosition = 0;
634-
SceneCluster.idleLogout = 0;
637+
idleLogout = 0;
635638
IncomingPackets.thirdLastOpcode = -1;
636639
IncomingPackets.incomingPacketBuffer.currentPosition = 0;
637640
MovedStatics.menuActionRow = 0;
@@ -1168,8 +1171,8 @@ public static void moveTowardsTarget() {
11681171
public static void updateGame() {
11691172
if(MovedStatics.systemUpdateTime > 1)
11701173
MovedStatics.systemUpdateTime--;
1171-
if(SceneCluster.idleLogout > 0)
1172-
SceneCluster.idleLogout--;
1174+
if(idleLogout > 0)
1175+
idleLogout--;
11731176
if(aBoolean871) {
11741177
aBoolean871 = false;
11751178
dropClient();
@@ -1469,7 +1472,7 @@ else if(ChatBox.dialogueId != -1)
14691472
int i_20_ = MouseHandler.resetFramesSinceMouseInput();
14701473
int i_21_ = KeyFocusListener.resetFramesSinceKeyboardInput();
14711474
if(i_20_ > 4500 && i_21_ > 4500) {
1472-
SceneCluster.idleLogout = 250;
1475+
idleLogout = 250;
14731476
MouseHandler.setFramesSinceMouseInput(4000);
14741477
OutgoingPackets.buffer.putPacket(216);
14751478
}
@@ -1878,7 +1881,7 @@ public static void method249() {
18781881
}
18791882

18801883
public static void dropClient() {
1881-
if(SceneCluster.idleLogout > 0) {
1884+
if(idleLogout > 0) {
18821885
// Instant logout
18831886
logout();
18841887
} else {
@@ -1895,7 +1898,7 @@ public static void setLowMemory() {
18951898
}
18961899

18971900
public static void method992() {
1898-
SceneCluster.gameTimer.start();
1901+
gameTimer.start();
18991902
for(int i = 0; i < 32; i++)
19001903
GameShell.tickSamples[i] = 0L;
19011904
for(int i = 0; i < 32; i++)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import org.runejs.client.frame.ScreenMode;
55
import org.runejs.client.language.Native;
66
import org.runejs.client.media.renderable.actor.Player;
7-
import org.runejs.client.scene.SceneCluster;
87
import org.runejs.client.util.Signlink;
98
import org.runejs.client.util.Timer;
109

@@ -132,12 +131,12 @@ public void run() {
132131
setCanvas();
133132
MovedStatics.aProducingGraphicsBuffer_2213 = MovedStatics.createGraphicsBuffer(MovedStatics.width, MovedStatics.height, Game.gameCanvas);
134133
this.game.startup();
135-
SceneCluster.gameTimer = Timer.create();
136-
SceneCluster.gameTimer.start();
134+
Game.gameTimer = Timer.create();
135+
Game.gameTimer.start();
137136

138137
// Initialize client loop
139138
while (exitTimeInMillis == 0L || System.currentTimeMillis() < exitTimeInMillis) {
140-
MovedStatics.ticksPerLoop = SceneCluster.gameTimer.getTicks(millisPerTick, anInt2024);
139+
MovedStatics.ticksPerLoop = Game.gameTimer.getTicks(millisPerTick, anInt2024);
141140
for (int currentTick = 0; currentTick < MovedStatics.ticksPerLoop; currentTick++) {
142141
long currentTimeMillis = System.currentTimeMillis();
143142

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,7 @@ public static boolean menuHasAddFriend(int arg1) {
25252525
* Anything that is a 2D item attached to an actor in the world.
25262526
*/
25272527
public static void draw2DActorAttachments() {
2528-
SceneCluster.anInt770 = 0;
2528+
int overheadChatMessageCount = 0;
25292529
for(int i = -1; Player.localPlayerCount + Player.npcCount > i; i++) {
25302530
Actor actor;
25312531
if(i == -1)
@@ -2583,16 +2583,16 @@ else if(i < Player.localPlayerCount)
25832583
if(actor.forcedChatMessage != null && (i >= Player.localPlayerCount || ChatBox.publicChatMode == 0 || ChatBox.publicChatMode == 3 || ChatBox.publicChatMode == 1 && Player.hasFriend(((Player) actor).playerName))) {
25842584
Point2d screenPos = getProjectedScreenPosition(actor.anInt3117, actor.worldY, actor.worldX);
25852585

2586-
if(screenPos != null && 50 > SceneCluster.anInt770) {
2587-
Actor.overheadChatHalfWidth[SceneCluster.anInt770] = TypeFace.fontBold.getStringWidth(actor.forcedChatMessage) / 2;
2588-
Actor.overheadChatLetterHeight[SceneCluster.anInt770] = TypeFace.fontBold.characterDefaultHeight;
2589-
Actor.overheadChatX[SceneCluster.anInt770] = screenPos.x;
2590-
Actor.overheadChatY[SceneCluster.anInt770] = screenPos.y;
2591-
Actor.overheadChatColor[SceneCluster.anInt770] = actor.chatcolor;
2592-
Actor.overheadChatShape[SceneCluster.anInt770] = actor.chatEffects;
2593-
Actor.overheadChatTimer[SceneCluster.anInt770] = actor.chatTimer;
2594-
Actor.overheadChatMessage[SceneCluster.anInt770] = actor.forcedChatMessage;
2595-
SceneCluster.anInt770++;
2586+
if(screenPos != null && 50 > overheadChatMessageCount) {
2587+
Actor.overheadChatHalfWidth[overheadChatMessageCount] = TypeFace.fontBold.getStringWidth(actor.forcedChatMessage) / 2;
2588+
Actor.overheadChatLetterHeight[overheadChatMessageCount] = TypeFace.fontBold.characterDefaultHeight;
2589+
Actor.overheadChatX[overheadChatMessageCount] = screenPos.x;
2590+
Actor.overheadChatY[overheadChatMessageCount] = screenPos.y;
2591+
Actor.overheadChatColor[overheadChatMessageCount] = actor.chatcolor;
2592+
Actor.overheadChatShape[overheadChatMessageCount] = actor.chatEffects;
2593+
Actor.overheadChatTimer[overheadChatMessageCount] = actor.chatTimer;
2594+
Actor.overheadChatMessage[overheadChatMessageCount] = actor.forcedChatMessage;
2595+
overheadChatMessageCount++;
25962596
}
25972597
}
25982598
if(pulseCycle < actor.anInt3139) {
@@ -2627,7 +2627,7 @@ else if(i < Player.localPlayerCount)
26272627
}
26282628
}
26292629
}
2630-
for(int i = 0; SceneCluster.anInt770 > i; i++) {
2630+
for(int i = 0; overheadChatMessageCount > i; i++) {
26312631
int i_3_ = Actor.overheadChatX[i];
26322632
int i_4_ = Actor.overheadChatY[i];
26332633
int i_5_ = Actor.overheadChatHalfWidth[i];
@@ -3309,7 +3309,7 @@ public static void processMenuClick() {
33093309
}
33103310

33113311
public static void method1057() {
3312-
SceneCluster.gameTimer.reset();
3312+
Game.gameTimer.reset();
33133313
for(int i = 0; i < 32; i++)
33143314
GameShell.tickSamples[i] = 0L;
33153315
for(int i = 0; i < 32; i++)

src/main/java/org/runejs/client/cache/media/gameInterface/GameInterface.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.runejs.client.net.OutgoingPackets;
3434
import org.runejs.client.node.CachedNode;
3535
import org.runejs.client.node.NodeCache;
36-
import org.runejs.client.scene.SceneCluster;
3736
import org.runejs.client.util.TextUtils;
3837
import org.runejs.client.*;
3938
import org.runejs.Configuration;
@@ -1723,7 +1722,7 @@ public static boolean method166(byte arg0, GameInterface arg1) {
17231722
}
17241723
}
17251724
if(i == 205) {
1726-
SceneCluster.idleLogout = 250;
1725+
Game.idleLogout = 250;
17271726
return true;
17281727
}
17291728
if(i == 501) {

src/main/java/org/runejs/client/scene/SceneCluster.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
package org.runejs.client.scene;
22

3-
import org.runejs.client.util.Timer;
4-
53
public class SceneCluster {
6-
public static Timer gameTimer;
7-
public static int anInt770 = 0;
8-
public static int idleLogout = 0;
9-
104
public int worldDistanceFromCameraStartX;
115
public int worldDistanceFromCameraEndY;
126
public int tileStartY;
@@ -25,6 +19,4 @@ public class SceneCluster {
2519
public int tileEndX;
2620
public int worldEndZ;
2721
public int worldDistanceFromCameraEndX;
28-
29-
3022
}

0 commit comments

Comments
 (0)