Skip to content

Commit e7dca50

Browse files
committed
refactor: SignlinkNode.Status
1 parent 208dc65 commit e7dca50

File tree

6 files changed

+31
-20
lines changed

6 files changed

+31
-20
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,15 @@ public static void createClientScriptCheckPacket(int packetId, PacketBuffer buff
199199

200200
for(int i = 0; clientScriptRunner.scriptCount > i; i++) {
201201
if(clientScriptRunner.valueNodes[i] != null) {
202-
if(clientScriptRunner.valueNodes[i].status == 2)
202+
if(clientScriptRunner.valueNodes[i].status == SignlinkNode.Status.ERRORED)
203203
clientScriptRunner.errorCodes[i] = -5;
204-
if(clientScriptRunner.valueNodes[i].status == 0)
204+
if(clientScriptRunner.valueNodes[i].status == SignlinkNode.Status.NOT_INITIALIZED)
205205
bool = true;
206206
}
207207
if(clientScriptRunner.functionNodes[i] != null) {
208-
if(clientScriptRunner.functionNodes[i].status == 2)
208+
if(clientScriptRunner.functionNodes[i].status == SignlinkNode.Status.ERRORED)
209209
clientScriptRunner.errorCodes[i] = -6;
210-
if(clientScriptRunner.functionNodes[i].status == 0)
210+
if(clientScriptRunner.functionNodes[i].status == SignlinkNode.Status.NOT_INITIALIZED)
211211
bool = true;
212212
}
213213
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,10 +1598,10 @@ public static void handleLoginScreenActions() {
15981598
if (MovedStatics.gameServerSignlinkNode == null) {
15991599
MovedStatics.gameServerSignlinkNode = signlink.createSocketNode(currentPort);
16001600
}
1601-
if (MovedStatics.gameServerSignlinkNode.status == 2) {
1601+
if (MovedStatics.gameServerSignlinkNode.status == SignlinkNode.Status.ERRORED) {
16021602
throw new IOException();
16031603
}
1604-
if (MovedStatics.gameServerSignlinkNode.status == 1) {
1604+
if (MovedStatics.gameServerSignlinkNode.status == SignlinkNode.Status.INITIALIZED) {
16051605
MovedStatics.gameServerSocket = new GameSocket((Socket) MovedStatics.gameServerSignlinkNode.value, signlink);
16061606
loginStatus = 2;
16071607
MovedStatics.gameServerSignlinkNode = null;
@@ -2260,11 +2260,11 @@ public void connectUpdateServer() {
22602260
connectionStage++;
22612261
}
22622262
if (connectionStage == 1) {
2263-
if (updateServerSignlinkNode.status == 2) {
2263+
if (updateServerSignlinkNode.status == SignlinkNode.Status.ERRORED) {
22642264
method35(-1);
22652265
break;
22662266
}
2267-
if (updateServerSignlinkNode.status == 1)
2267+
if (updateServerSignlinkNode.status == SignlinkNode.Status.INITIALIZED)
22682268
connectionStage++;
22692269
}
22702270
if (connectionStage == 2) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public void kill() {
5454
}
5555

5656
if (signLinkNode != null) {
57-
while (signLinkNode.status == 0) {
57+
while (signLinkNode.status == SignlinkNode.Status.NOT_INITIALIZED) {
5858
MovedStatics.threadSleep(1L);
5959
}
6060

61-
if (signLinkNode.status == 1) {
61+
if (signLinkNode.status == SignlinkNode.Status.INITIALIZED) {
6262
try {
6363
// Kill the signLinkNode
6464
((Thread) signLinkNode.value).join();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,9 @@ public static void printException(String arg0, Throwable exception) {
546546
string = string.replace('&', '_');
547547
string = string.replace('#', '_');
548548
SignlinkNode signlinkNode = signlink.addType4Node(new URL(signlink.gameShell.getCodeBase(), "clienterror.ws?c=" + Game.clientVersion + "&u=" + aLong853 + "&v1=" + Signlink.javaVendor + "&v2=" + Signlink.javaVersion + "&e=" + string));
549-
while (signlinkNode.status == 0)
549+
while (signlinkNode.status == SignlinkNode.Status.NOT_INITIALIZED)
550550
threadSleep(1L);
551-
if (signlinkNode.status != 1)
551+
if (signlinkNode.status != SignlinkNode.Status.INITIALIZED)
552552
return;
553553
DataInputStream datainputstream = (DataInputStream) signlinkNode.value;
554554
datainputstream.read();

src/main/java/org/runejs/client/util/Signlink.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ else if(type == 9) {
206206
throw new Exception();
207207
}
208208

209-
currentNode.status = 1;
209+
currentNode.status = SignlinkNode.Status.INITIALIZED;
210210
} catch(Exception exception) {
211-
currentNode.status = 2;
211+
currentNode.status = SignlinkNode.Status.ERRORED;
212212
}
213213
}
214214

src/main/java/org/runejs/client/util/SignlinkNode.java

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

33
public class SignlinkNode {
4+
public enum Status {
5+
NOT_INITIALIZED(0),
6+
INITIALIZED(1),
7+
ERRORED(2);
8+
9+
private final int value;
10+
11+
Status(int value) {
12+
this.value = value;
13+
}
14+
15+
public int getValue() {
16+
return value;
17+
}
18+
}
19+
420
public int integerData;
521

622
/**
@@ -13,12 +29,7 @@ public class SignlinkNode {
1329
*/
1430
public int type;
1531

16-
/**
17-
* 0 = Not initialized
18-
* 1 = Initialized
19-
* 2 = Errored
20-
*/
21-
public volatile int status = 0;
32+
public volatile Status status = Status.NOT_INITIALIZED;
2233

2334
public Object objectData;
2435
public SignlinkNode prev;

0 commit comments

Comments
 (0)