Skip to content

Commit ab31caf

Browse files
committed
refactor: non-static UpdateServer
1 parent 1ad1ea0 commit ab31caf

File tree

5 files changed

+88
-83
lines changed

5 files changed

+88
-83
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ public static void renderLoginScreen(Component arg0, CacheArchive huffmanCacheAr
542542
MusicSystem.method412(false, CacheArchive.musicCacheArchive, 0, Native.titleSong, 10, "", MusicSystem.musicVolume);
543543
else
544544
MusicSystem.method405(10);
545-
UpdateServer.resetUpdateServerRequests(false);
545+
Game.updateServer.resetUpdateServerRequests(false);
546546
MovedStatics.clearScreen = true;
547547
MovedStatics.aBoolean512 = true;
548548
}

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public class Game {
7676
*/
7777
public static final CutsceneCamera cutsceneCamera = new CutsceneCamera();
7878

79+
/**
80+
* TODO use interface
81+
*/
82+
public static final UpdateServer updateServer = new UpdateServer();
83+
7984
public static FriendList friendList;
8085

8186
public static final SocialList ignoreList = new SocialList(100);
@@ -871,7 +876,7 @@ public static void method353() {
871876
}
872877

873878

874-
if(aBoolean519 && UpdateServer.getActiveCount(false, true) == 0) {
879+
if(aBoolean519 && updateServer.getActiveCount(false, true) == 0) {
875880
aBoolean519 = false;
876881
}
877882
if(aBoolean519) {
@@ -2189,7 +2194,7 @@ public void processGameLoop() {
21892194

21902195
public void handleUpdateServer() {
21912196
if (gameStatusCode != 1000) {
2192-
boolean bool = UpdateServer.processUpdateServerResponse();
2197+
boolean bool = updateServer.processUpdateServerResponse();
21932198
if (!bool)
21942199
connectUpdateServer();
21952200
}
@@ -2238,13 +2243,13 @@ else if (gameStatusCode == 5) {
22382243
}
22392244

22402245
public void connectUpdateServer() {
2241-
if (UpdateServer.crcMismatches >= 4) {
2246+
if (updateServer.crcMismatches >= 4) {
22422247
this.openErrorPage("js5crc");
22432248
gameStatusCode = 1000;
22442249
} else {
2245-
if (UpdateServer.ioExceptions >= 4) {
2250+
if (updateServer.ioExceptions >= 4) {
22462251
if (gameStatusCode > 5) {
2247-
UpdateServer.ioExceptions = 3;
2252+
updateServer.ioExceptions = 3;
22482253
anInt509 = 3000;
22492254
} else {
22502255
this.openErrorPage("js5io");
@@ -2294,7 +2299,7 @@ public void connectUpdateServer() {
22942299
if (connectionStage != 4)
22952300
break;
22962301

2297-
UpdateServer.handleUpdateServerConnection(updateServerSocket, gameStatusCode > 20);
2302+
updateServer.handleUpdateServerConnection(updateServerSocket, gameStatusCode > 20);
22982303

22992304
updateServerSignlinkNode = null;
23002305
connectionStage = 0;
@@ -2335,7 +2340,7 @@ public void close() {
23352340
method249();
23362341
MusicSystem.syncedStop(false);
23372342
SoundSystem.stop();
2338-
UpdateServer.killUpdateServerSocket();
2343+
updateServer.killUpdateServerSocket();
23392344
method947(-1);
23402345
do {
23412346
try {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ public static void method440() {
387387
Class60.aProducingGraphicsBuffer_463 = null;
388388
Class60.anIntArray1013 = null;
389389
MusicSystem.method405(10);
390-
UpdateServer.resetUpdateServerRequests(true);
390+
Game.updateServer.resetUpdateServerRequests(true);
391391
aBoolean512 = false;
392392
}
393393
}

src/main/java/org/runejs/client/cache/CacheArchive.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public CacheArchive(CacheIndex dataIndex, CacheIndex metaIndex, int cacheIndexId
6060
aBoolean1811 = arg5;
6161
this.metaIndex = metaIndex;
6262
this.cacheIndexId = cacheIndexId;
63-
UpdateServer.getArchiveChecksum(this, this.cacheIndexId);
63+
Game.updateServer.getArchiveChecksum(this, this.cacheIndexId);
6464
}
6565

6666
public static CacheArchive loadArchive(int cacheIndexId, boolean arg1, boolean arg2, boolean arg4) {
@@ -164,7 +164,7 @@ public int getPercentLoaded() {
164164
return 100;
165165
if(aByteArrayArray212 != null)
166166
return 99;
167-
int i = UpdateServer.calculateDataLoaded(255, cacheIndexId);
167+
int i = Game.updateServer.calculateDataLoaded(255, cacheIndexId);
168168
if(i >= 100)
169169
i = 99;
170170
return i;
@@ -176,15 +176,15 @@ public void method198(boolean arg1, byte[] arg2, int arg3, CacheIndex arg4) {
176176
if(aBoolean1800)
177177
throw new RuntimeException();
178178
if(arg2 == null) {
179-
UpdateServer.method327(true, this, 255, cacheIndexId, (byte) 0,
179+
Game.updateServer.method327(true, this, 255, cacheIndexId, (byte) 0,
180180
archiveCrcValue);
181181
return;
182182
}
183183
crc32.reset();
184184
crc32.update(arg2, 0, arg2.length);
185185
int i = (int) crc32.getValue();
186186
if(i != archiveCrcValue) {
187-
UpdateServer.method327(true, this, 255, cacheIndexId, (byte) 0,
187+
Game.updateServer.method327(true, this, 255, cacheIndexId, (byte) 0,
188188
archiveCrcValue);
189189
return;
190190
}
@@ -197,7 +197,7 @@ public void method198(boolean arg1, byte[] arg2, int arg3, CacheIndex arg4) {
197197
if(arg2 == null || arg2.length <= 2) {
198198
aBooleanArray1796[arg3] = false;
199199
if(aBoolean1811 || arg1)
200-
UpdateServer.method327(arg1, this, cacheIndexId, arg3, (byte) 2, anIntArray252[arg3]);
200+
Game.updateServer.method327(arg1, this, cacheIndexId, arg3, (byte) 2, anIntArray252[arg3]);
201201
return;
202202
}
203203
crc32.reset();
@@ -207,7 +207,7 @@ public void method198(boolean arg1, byte[] arg2, int arg3, CacheIndex arg4) {
207207
if(i != anIntArray252[arg3] || i_0_ != anIntArray224[arg3]) {
208208
aBooleanArray1796[arg3] = false;
209209
if(aBoolean1811 || arg1)
210-
UpdateServer.method327(arg1, this, cacheIndexId, arg3, (byte) 2, anIntArray252[arg3]);
210+
Game.updateServer.method327(arg1, this, cacheIndexId, arg3, (byte) 2, anIntArray252[arg3]);
211211
return;
212212
}
213213
aBooleanArray1796[arg3] = true;
@@ -220,11 +220,11 @@ public void method177(int arg1) {
220220
if(dataIndex != null && aBooleanArray1796 != null && aBooleanArray1796[arg1])
221221
method602(this, arg1, dataIndex);
222222
else
223-
UpdateServer.method327(true, this, cacheIndexId, arg1, (byte) 2, anIntArray252[arg1]);
223+
Game.updateServer.method327(true, this, cacheIndexId, arg1, (byte) 2, anIntArray252[arg1]);
224224
}
225225

226226
public void method174(int arg0) {
227-
UpdateServer.method399(cacheIndexId, arg0);
227+
Game.updateServer.method399(cacheIndexId, arg0);
228228
}
229229

230230
public void method199() {
@@ -249,7 +249,7 @@ public void method199() {
249249
public void requestLatestVersion(int crcValue) {
250250
archiveCrcValue = crcValue;
251251
if(metaIndex == null)
252-
UpdateServer.method327(true, this, 255, cacheIndexId, (byte) 0, archiveCrcValue);
252+
Game.updateServer.method327(true, this, 255, cacheIndexId, (byte) 0, archiveCrcValue);
253253
else
254254
method602(this, cacheIndexId, metaIndex);
255255
}
@@ -259,7 +259,7 @@ public int method201(int arg0) {
259259
return 100;
260260
if(aBooleanArray1796[arg0])
261261
return 100;
262-
return UpdateServer.calculateDataLoaded(cacheIndexId, arg0);
262+
return Game.updateServer.calculateDataLoaded(cacheIndexId, arg0);
263263
}
264264

265265
public int method202() {

0 commit comments

Comments
 (0)