Skip to content

Commit 661ca10

Browse files
committed
refactor: move statics off CollisionMap (including reworking a static method)
1 parent 4006a94 commit 661ca10

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.runejs.client.io.Buffer;
44
import org.runejs.client.node.Class40_Sub6;
5-
import org.runejs.client.scene.util.CollisionMap;
65

76
public class Class44 implements Runnable {
87
public void run() {
@@ -14,10 +13,10 @@ public void run() {
1413
}
1514
if(class40_sub6 == null) {
1615
MovedStatics.threadSleep(100L);
17-
synchronized(CollisionMap.anObject162) {
16+
synchronized(MovedStatics.anObject162) {
1817
if(Buffer.anInt1987 <= 1) {
1918
Buffer.anInt1987 = 0;
20-
CollisionMap.anObject162.notifyAll();
19+
MovedStatics.anObject162.notifyAll();
2120
break;
2221
}
2322
Buffer.anInt1987--;
@@ -34,10 +33,10 @@ public void run() {
3433
MovedStatics.aLinkedList_2604.addLast(class40_sub6);
3534
}
3635
}
37-
synchronized(CollisionMap.anObject162) {
36+
synchronized(MovedStatics.anObject162) {
3837
if(Buffer.anInt1987 <= 1) {
3938
Buffer.anInt1987 = 0;
40-
CollisionMap.anObject162.notifyAll();
39+
MovedStatics.anObject162.notifyAll();
4140
break;
4241
}
4342
Buffer.anInt1987 = 600;

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.runejs.client.scene.camera.CameraRotation;
3030
import org.runejs.client.scene.camera.CutsceneCamera;
3131
import org.runejs.client.scene.camera.SphericalCamera;
32-
import org.runejs.client.scene.util.CollisionMap;
3332
import org.runejs.client.sound.MusicSystem;
3433
import org.runejs.client.sound.SoundSystem;
3534
import org.runejs.client.util.Signlink;
@@ -103,6 +102,10 @@ public class Game {
103102
public static long aLong1841;
104103
public static int clientVersion;
105104
public static int playerRights = 0;
105+
/**
106+
* Backup port if the first one fails?
107+
*/
108+
private static int someOtherPort;
106109
private static int gameServerPort;
107110
private static int duplicateClickCount = 0;
108111
private static int lastClickY = 0;
@@ -1692,7 +1695,7 @@ public static void handleLoginScreenActions() {
16921695
if (MovedStatics.anInt2321 < 1) {
16931696
MovedStatics.anInt2321++;
16941697
if (gameServerPort == currentPort) {
1695-
currentPort = CollisionMap.someOtherPort;
1698+
currentPort = someOtherPort;
16961699
} else {
16971700
currentPort = gameServerPort;
16981701
}
@@ -1706,7 +1709,7 @@ public static void handleLoginScreenActions() {
17061709
} catch (IOException ioexception) {
17071710
if (MovedStatics.anInt2321 < 1) {
17081711
if (currentPort == gameServerPort) {
1709-
currentPort = CollisionMap.someOtherPort;
1712+
currentPort = someOtherPort;
17101713
} else {
17111714
currentPort = gameServerPort;
17121715
}
@@ -1719,11 +1722,11 @@ public static void handleLoginScreenActions() {
17191722
}
17201723

17211724
private static void method947(int arg0) {
1722-
synchronized(CollisionMap.anObject162) {
1725+
synchronized(MovedStatics.anObject162) {
17231726
if((Buffer.anInt1987 ^ 0xffffffff) != arg0) {
17241727
Buffer.anInt1987 = 1;
17251728
try {
1726-
CollisionMap.anObject162.wait();
1729+
MovedStatics.anObject162.wait();
17271730
} catch(InterruptedException interruptedexception) {
17281731
/* empty */
17291732
}
@@ -2047,7 +2050,7 @@ public void method35(int arg1) {
20472050
if (currentPort != gameServerPort)
20482051
currentPort = gameServerPort;
20492052
else
2050-
currentPort = CollisionMap.someOtherPort;
2053+
currentPort = someOtherPort;
20512054
updateServerSocket = null;
20522055
updateServerSignlinkNode = null;
20532056
anInt292++;
@@ -2280,7 +2283,7 @@ public void close() {
22802283

22812284
public void startup() {
22822285
// Define ports
2283-
CollisionMap.someOtherPort = modewhere == 0 ? 443 : 50000 + Player.worldId;
2286+
someOtherPort = modewhere == 0 ? 443 : 50000 + Player.worldId;
22842287
gameServerPort = modewhere != 0 ? Player.worldId + 40000 : Configuration.GAME_PORT;
22852288
currentPort = gameServerPort;
22862289

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ public class MovedStatics {
328328
*/
329329
public static ProducingGraphicsBuffer tabTop;
330330
public static byte[][] aByteArrayArray1370;
331+
public static Object anObject162 = new Object();
331332

332333
public static void method440() {
333334
if (aBoolean512) {
@@ -457,7 +458,7 @@ public static IndexedImage method538() {
457458
}
458459

459460
public static void method332(int arg0) {
460-
synchronized (CollisionMap.anObject162) {
461+
synchronized (anObject162) {
461462
if (Buffer.anInt1987 == 0)
462463
Game.signlink.createThreadNode(5, new Class44());
463464
Buffer.anInt1987 = arg0;
@@ -853,7 +854,7 @@ public static void method1013() {
853854
public static void processGameStatus(int statusCode) {
854855
if (statusCode != Game.gameStatusCode) {
855856
if (Game.gameStatusCode == 0)
856-
CollisionMap.method144(12433);
857+
method144(12433);
857858
if (statusCode == 20 || statusCode == 40) {
858859
Game.anInt1756 = 0;
859860
anInt2321 = 0;
@@ -1481,7 +1482,7 @@ private static void addObject(int arg0, int arg1, int arg2, int arg3, int arg4,
14811482
int i_5_ = arg7;
14821483
if(i_5_ < 3 && (tile_flags[1][arg2][arg0] & 0x2) == 2)
14831484
i_5_++;
1484-
CollisionMap.addObject(Landscape.currentCollisionMap[arg7], arg1, i_5_, arg7, arg3, Game.currentScene, arg4, arg0, arg2);
1485+
Landscape.currentCollisionMap[arg7].addObject(arg1, i_5_, arg7, arg3, Game.currentScene, arg4, arg0, arg2);
14851486
}
14861487
}
14871488
}
@@ -3281,4 +3282,13 @@ public static void method1057() {
32813282
tickSamples[i] = 0L;
32823283
ticksPerLoop = 0;
32833284
}
3285+
3286+
public static void method144(int arg0) {
3287+
3288+
fontMetrics = null;
3289+
helveticaBold = null;
3290+
if(arg0 == 12433)
3291+
loadingBoxImage = null;
3292+
3293+
}
32843294
}

src/main/java/org/runejs/client/media/renderable/actor/Player.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.runejs.client.language.Native;
1313
import org.runejs.client.media.renderable.Model;
1414
import org.runejs.client.net.PacketBuffer;
15-
import org.runejs.client.scene.util.CollisionMap;
1615

1716
public class Player extends Actor {
1817

@@ -50,6 +49,10 @@ public class Player extends Actor {
5049
public static int localPlayerId = -1;
5150
public static String[] playerActions = new String[5];
5251
public static boolean[] playerActionsLowPriority = new boolean[5];
52+
/**
53+
* Relates to converting longs to Player usernames
54+
*/
55+
private static byte[] aByteArray169 = new byte[]{95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57};
5356
public int skillLevel;
5457
public int anInt3258;
5558
public int combatLevel = 0;
@@ -239,7 +242,7 @@ public static RSString longToUsername(long arg1) {
239242
while(arg1 != 0) {
240243
long l_10_ = arg1;
241244
arg1 /= 37L;
242-
is[--i] = CollisionMap.aByteArray169[(int) (-(arg1 * 37L) + l_10_)];
245+
is[--i] = aByteArray169[(int) (-(arg1 * 37L) + l_10_)];
243246
}
244247
RSString class1 = new RSString();
245248
class1.chars = is;

src/main/java/org/runejs/client/scene/util/CollisionMap.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
import org.runejs.client.util.BitUtils;
99

1010
public class CollisionMap {
11-
public static Object anObject162 = new Object();
12-
public static byte[] aByteArray169 = new byte[]{95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57};
13-
public static int someOtherPort;
14-
15-
1611
public int insetX;
1712
public int height;
1813
public int[][] clippingData;
@@ -30,17 +25,9 @@ public CollisionMap(int arg0, int arg1) {
3025

3126
}
3227

33-
public static void method144(int arg0) {
34-
35-
MovedStatics.fontMetrics = null;
36-
MovedStatics.helveticaBold = null;
37-
if(arg0 == 12433)
38-
MovedStatics.loadingBoxImage = null;
39-
40-
}
41-
28+
public void addObject(int arg1, int arg2, int arg3, int arg4, Scene arg5, int arg7, int arg8, int arg9) {
29+
CollisionMap arg0 = this;
4230

43-
public static void addObject(CollisionMap arg0, int arg1, int arg2, int arg3, int arg4, Scene arg5, int arg7, int arg8, int arg9) {
4431
int i = Landscape.tile_height[arg2][arg9][arg8];
4532
int i_0_ = Landscape.tile_height[arg2][1 + arg9][arg8];
4633
int i_1_ = Landscape.tile_height[arg2][arg9][1 + arg8];

0 commit comments

Comments
 (0)