Skip to content

Commit a52fc91

Browse files
committed
refactor: rename Buffer and Npc statics
1 parent eb4071d commit a52fc91

File tree

10 files changed

+77
-76
lines changed

10 files changed

+77
-76
lines changed

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

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

3-
import org.runejs.client.io.Buffer;
43
import org.runejs.client.node.Class40_Sub6;
54

65
public class Class44 implements Runnable {
@@ -14,12 +13,12 @@ public void run() {
1413
if(class40_sub6 == null) {
1514
MovedStatics.threadSleep(100L);
1615
synchronized(MovedStatics.anObject162) {
17-
if(Buffer.anInt1987 <= 1) {
18-
Buffer.anInt1987 = 0;
16+
if(MovedStatics.anInt1987 <= 1) {
17+
MovedStatics.anInt1987 = 0;
1918
MovedStatics.anObject162.notifyAll();
2019
break;
2120
}
22-
Buffer.anInt1987--;
21+
MovedStatics.anInt1987--;
2322
}
2423
} else {
2524
if(class40_sub6.anInt2112 == 0) {
@@ -34,12 +33,12 @@ public void run() {
3433
}
3534
}
3635
synchronized(MovedStatics.anObject162) {
37-
if(Buffer.anInt1987 <= 1) {
38-
Buffer.anInt1987 = 0;
36+
if(MovedStatics.anInt1987 <= 1) {
37+
MovedStatics.anInt1987 = 0;
3938
MovedStatics.anObject162.notifyAll();
4039
break;
4140
}
42-
Buffer.anInt1987 = 600;
41+
MovedStatics.anInt1987 = 600;
4342
}
4443
}
4544
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public static boolean drawInterface(int areaId, int minX, int minY, int maxX, in
270270
i_12_ = 0;
271271
if (i_14_ < 5 && i_14_ > -5)
272272
i_14_ = 0;
273-
if (Buffer.lastItemDragTime < 5) {
273+
if (GameInterface.lastItemDragTime < 5) {
274274
i_14_ = 0;
275275
i_12_ = 0;
276276
}
@@ -641,7 +641,7 @@ public static void setConfigToDefaults() {
641641
ChatBox.chatMessages[i] = null;
642642
GameInterface.itemCurrentlySelected = 0;
643643
MovedStatics.destinationX = 0;
644-
Buffer.anInt1985 = -1;
644+
MovedStatics.anInt1985 = -1;
645645
Player.npcCount = 0;
646646
SoundSystem.reset();
647647
widgetSelected = 0;
@@ -1329,7 +1329,7 @@ else if(x > 764)
13291329
}
13301330
MovedStatics.anInt199++;
13311331
if(GameInterface.activeInterfaceType != 0) {
1332-
Buffer.lastItemDragTime++;
1332+
GameInterface.lastItemDragTime++;
13331333
if(MouseHandler.mouseX > Renderable.anInt2869 + 5 || Renderable.anInt2869 + -5 > MouseHandler.mouseX || MovedStatics.anInt2798 + 5 < MouseHandler.mouseY || MovedStatics.anInt2798 - 5 > MouseHandler.mouseY)
13341334
MovedStatics.lastItemDragged = true;
13351335
if(MouseHandler.currentMouseButtonPressed == 0) {
@@ -1338,7 +1338,7 @@ else if(x > 764)
13381338
if(GameInterface.activeInterfaceType == 2)
13391339
GameInterface.redrawTabArea = true;
13401340
GameInterface.activeInterfaceType = 0;
1341-
if(MovedStatics.lastItemDragged && Buffer.lastItemDragTime >= 5) {
1341+
if(MovedStatics.lastItemDragged && GameInterface.lastItemDragTime >= 5) {
13421342
GameInterface.lastActiveInvInterface = -1;
13431343
MovedStatics.processRightClick();
13441344
if(GameInterface.lastActiveInvInterface == GameInterface.modifiedWidgetId && mouseInvInterfaceIndex != GameInterface.selectedInventorySlot) {
@@ -1417,7 +1417,7 @@ else if(MovedStatics.menuActionRow > 0)
14171417
}
14181418

14191419
if(MouseHandler.currentMouseButtonPressed == 1 || MouseHandler.clickType == 1)
1420-
Npc.anInt3294++;
1420+
MovedStatics.anInt3294++;
14211421

14221422
int i = 34;
14231423
if(GameInterface.gameScreenInterfaceId != -1)
@@ -1723,8 +1723,8 @@ public static void handleLoginScreenActions() {
17231723

17241724
private static void method947(int arg0) {
17251725
synchronized(MovedStatics.anObject162) {
1726-
if((Buffer.anInt1987 ^ 0xffffffff) != arg0) {
1727-
Buffer.anInt1987 = 1;
1726+
if((MovedStatics.anInt1987 ^ 0xffffffff) != arg0) {
1727+
MovedStatics.anInt1987 = 1;
17281728
try {
17291729
MovedStatics.anObject162.wait();
17301730
} catch(InterruptedException interruptedexception) {
@@ -1845,8 +1845,8 @@ public static void method910() {
18451845
if(true) {
18461846
if (VertexNormal.lowMemory && MovedStatics.onBuildTimePlane != Player.worldLevel)
18471847
Landscape.method789(Player.localPlayer.pathY[0], MovedStatics.regionY, MovedStatics.regionX, Player.localPlayer.pathX[0], Player.worldLevel);
1848-
else if (Buffer.anInt1985 != Player.worldLevel) {
1849-
Buffer.anInt1985 = Player.worldLevel;
1848+
else if (MovedStatics.anInt1985 != Player.worldLevel) {
1849+
MovedStatics.anInt1985 = Player.worldLevel;
18501850
Minimap.method299(Player.worldLevel);
18511851
}
18521852
}
@@ -2157,7 +2157,7 @@ else if (gameStatusCode == 5) {
21572157
method164();
21582158
} else if (gameStatusCode == 40)
21592159
MovedStatics.method940(English.connectionLost, false, English.pleaseWaitAttemptingToReestablish);
2160-
Npc.anInt3294 = 0;
2160+
MovedStatics.anInt3294 = 0;
21612161
}
21622162

21632163
public void connectUpdateServer() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ public static void method789(int chunkLocalX, int chunkY, int chunkX, int chunkL
14231423
if(obj.x < 0 || obj.y < 0 || obj.x >= 104 || obj.y >= 104)
14241424
obj.unlink();
14251425
}
1426-
Buffer.anInt1985 = -1;
1426+
MovedStatics.anInt1985 = -1;
14271427
if(MovedStatics.destinationX != 0) {
14281428
MovedStatics.destinationX -= i_34_;
14291429
Game.destinationY -= i_35_;

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

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,21 @@ public class MovedStatics {
336336
*/
337337
public static int anInt2480 = 0;
338338
public static ImageRGB[] aClass40_Sub5_Sub14_Sub4Array2474;
339+
public static int anInt1985 = -1;
340+
public static int anInt1987 = 0;
341+
public static IndexedImage tabTopBack;
342+
/**
343+
* Some kind of colour palette
344+
*/
345+
public static int[] anIntArray1972;
346+
/**
347+
* Sprite heights?
348+
*/
349+
public static int[] anIntArray3312;
350+
/**
351+
* Some kind of mouse information
352+
*/
353+
public static int anInt3294 = 0;
339354

340355
public static void method440() {
341356
if (aBoolean512) {
@@ -457,18 +472,18 @@ public static IndexedImage method538() {
457472
class40_sub5_sub14_sub2.xDrawOffset = anIntArray1347[0];
458473
class40_sub5_sub14_sub2.yDrawOffset = anIntArray3111[0];
459474
class40_sub5_sub14_sub2.imgWidth = anIntArray456[0];
460-
class40_sub5_sub14_sub2.imgHeight = Npc.anIntArray3312[0];
461-
class40_sub5_sub14_sub2.palette = Buffer.anIntArray1972;
475+
class40_sub5_sub14_sub2.imgHeight = anIntArray3312[0];
476+
class40_sub5_sub14_sub2.palette = anIntArray1972;
462477
class40_sub5_sub14_sub2.imgPixels = aByteArrayArray1370[0];
463478
method569();
464479
return class40_sub5_sub14_sub2;
465480
}
466481

467482
public static void method332(int arg0) {
468483
synchronized (anObject162) {
469-
if (Buffer.anInt1987 == 0)
484+
if (anInt1987 == 0)
470485
Game.signlink.createThreadNode(5, new Class44());
471-
Buffer.anInt1987 = arg0;
486+
anInt1987 = arg0;
472487
}
473488
}
474489

@@ -538,7 +553,7 @@ public static void method184(byte[] data, int arg1) {
538553
anIntArray3111 = new int[anInt2581];
539554
aByteArrayArray1370 = new byte[anInt2581][];
540555
anIntArray456 = new int[anInt2581];
541-
Npc.anIntArray3312 = new int[anInt2581];
556+
anIntArray3312 = new int[anInt2581];
542557
anIntArray1347 = new int[anInt2581];
543558

544559
buffer.currentPosition = data.length + -7 + -(anInt2581 * 8);
@@ -552,18 +567,18 @@ public static void method184(byte[] data, int arg1) {
552567
for (int i_36_ = 0; i_36_ < anInt2581; i_36_++)
553568
anIntArray456[i_36_] = buffer.getUnsignedShortBE();
554569
for (int i_37_ = 0; anInt2581 > i_37_; i_37_++)
555-
Npc.anIntArray3312[i_37_] = buffer.getUnsignedShortBE();
570+
anIntArray3312[i_37_] = buffer.getUnsignedShortBE();
556571

557572
buffer.currentPosition = data.length - (7 + anInt2581 * 8 + -3 + i * 3);
558-
Buffer.anIntArray1972 = new int[i];
573+
anIntArray1972 = new int[i];
559574
for (int i_38_ = 1; i > i_38_; i_38_++) {
560-
Buffer.anIntArray1972[i_38_] = buffer.getMediumBE();
561-
if (Buffer.anIntArray1972[i_38_] == 0)
562-
Buffer.anIntArray1972[i_38_] = 1;
575+
anIntArray1972[i_38_] = buffer.getMediumBE();
576+
if (anIntArray1972[i_38_] == 0)
577+
anIntArray1972[i_38_] = 1;
563578
}
564579
buffer.currentPosition = 0;
565580
for (int i_39_ = 0; anInt2581 > i_39_; i_39_++) {
566-
int i_40_ = Npc.anIntArray3312[i_39_];
581+
int i_40_ = anIntArray3312[i_39_];
567582
int i_41_ = anIntArray456[i_39_];
568583
int i_42_ = i_40_ * i_41_;
569584
byte[] is = new byte[i_42_];
@@ -587,7 +602,7 @@ public static String method204(int arg0) {
587602

588603
public static void method527(int currentTabId, int[] tabWidgetIds, boolean arg3, int arg4) {
589604
tabTop.prepareRasterizer();
590-
Buffer.tabTopBack.drawImage(0, 0);
605+
tabTopBack.drawImage(0, 0);
591606
if (arg3) {
592607
if (tabWidgetIds[currentTabId] != -1) {
593608
if (currentTabId == 0)
@@ -1420,7 +1435,7 @@ private static void method344(int arg0) {
14201435
tabHighlightImageTopRightEdge = null;
14211436
anIntArray852 = null;
14221437
chatModes = null;
1423-
Buffer.tabTopBack = null;
1438+
tabTopBack = null;
14241439
tabImageProducer = null;
14251440
tabHighlightImageTopLeftEdge = null;
14261441
gameScreenImageProducer = null;
@@ -1912,7 +1927,7 @@ public static void method763(Component arg0, CacheArchive arg2) {
19121927
Minimap.minimapBackgroundImage = Game.method359(Native.mapBack, Native.aClass1_305, arg2);
19131928
bottomChatBack = Game.method359(Native.imgBackbase1, Native.aClass1_305, arg2);
19141929
tabBottomBack = Game.method359(Native.imgBackbase2, Native.aClass1_305, arg2);
1915-
Buffer.tabTopBack = Game.method359(Native.imgBackhmid1, Native.aClass1_305, arg2);
1930+
tabTopBack = Game.method359(Native.imgBackhmid1, Native.aClass1_305, arg2);
19161931
ChatBox.chatBoxImageProducer = createGraphicsBuffer(479, 96, arg0);
19171932
chatboxBackgroundImage.drawImage(0, 0);
19181933
Minimap.mapbackProducingGraphicsBuffer = createGraphicsBuffer(172, 156, arg0);
@@ -3055,7 +3070,7 @@ public static boolean method793(int arg1) {
30553070
}
30563071

30573072
public static IndexedImage method769(int arg0, CacheArchive imageArchive, int arg2) {
3058-
if(!Buffer.method472(imageArchive, arg2))
3073+
if(!method472(imageArchive, arg2))
30593074
return null;
30603075
return method538();
30613076
}
@@ -3267,7 +3282,7 @@ public static void processMenuClick() {
32673282
GameInterface.activeInterfaceType = 1;
32683283
if(GameInterface.chatboxInterfaceId == id >> 16)
32693284
GameInterface.activeInterfaceType = 3;
3270-
Buffer.lastItemDragTime = 0;
3285+
GameInterface.lastItemDragTime = 0;
32713286
return;
32723287
}
32733288
}
@@ -3306,12 +3321,12 @@ public static ImageRGB method578() {
33063321
class40_sub5_sub14_sub4.offsetX = anIntArray1347[0];
33073322
class40_sub5_sub14_sub4.offsetY = anIntArray3111[0];
33083323
class40_sub5_sub14_sub4.imageWidth = anIntArray456[0];
3309-
class40_sub5_sub14_sub4.imageHeight = Npc.anIntArray3312[0];
3324+
class40_sub5_sub14_sub4.imageHeight = anIntArray3312[0];
33103325
byte[] is = aByteArrayArray1370[0];
33113326
int i = class40_sub5_sub14_sub4.imageWidth * class40_sub5_sub14_sub4.imageHeight;
33123327
class40_sub5_sub14_sub4.pixels = new int[i];
33133328
for(int i_5_ = 0; i_5_ < i; i_5_++) {
3314-
class40_sub5_sub14_sub4.pixels[i_5_] = Buffer.anIntArray1972[BitUtils.bitWiseAND(255, is[i_5_])];
3329+
class40_sub5_sub14_sub4.pixels[i_5_] = anIntArray1972[BitUtils.bitWiseAND(255, is[i_5_])];
33153330
}
33163331
method569();
33173332
return class40_sub5_sub14_sub4;
@@ -3320,9 +3335,9 @@ public static ImageRGB method578() {
33203335
public static void method569() {
33213336
anIntArray456 = null;
33223337
aByteArrayArray1370 = null;
3323-
Npc.anIntArray3312 = null;
3338+
anIntArray3312 = null;
33243339
anIntArray3111 = null;
3325-
Buffer.anIntArray1972 = null;
3340+
anIntArray1972 = null;
33263341
anIntArray1347 = null;
33273342
}
33283343

@@ -3615,4 +3630,19 @@ public static void startup() {
36153630
processGameStatus(10);
36163631
}
36173632
}
3633+
3634+
/**
3635+
* Reading some kind of cache
3636+
*
3637+
* TODO what is this? sprites?
3638+
*/
3639+
public static boolean method472(CacheArchive arg1, int arg2) {
3640+
byte[] is = arg1.method187(arg2);
3641+
if(is == null) {
3642+
return false;
3643+
}
3644+
method184(is, 0);
3645+
return true;
3646+
3647+
}
36183648
}

src/main/java/org/runejs/client/cache/media/ImageRGB.java

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

33
import org.runejs.client.MovedStatics;
44
import org.runejs.client.cache.CacheArchive;
5-
import org.runejs.client.io.Buffer;
65
import org.runejs.client.media.Rasterizer;
7-
import org.runejs.client.media.renderable.actor.Npc;
86
import org.runejs.client.util.BitUtils;
97

108
import java.awt.*;
@@ -252,12 +250,12 @@ public static ImageRGB[] method319() {
252250
class40_sub5_sub14_sub4.offsetX = MovedStatics.anIntArray1347[i];
253251
class40_sub5_sub14_sub4.offsetY = MovedStatics.anIntArray3111[i];
254252
class40_sub5_sub14_sub4.imageWidth = MovedStatics.anIntArray456[i];
255-
class40_sub5_sub14_sub4.imageHeight = Npc.anIntArray3312[i];
253+
class40_sub5_sub14_sub4.imageHeight = MovedStatics.anIntArray3312[i];
256254
byte[] is = MovedStatics.aByteArrayArray1370[i];
257255
int i_4_ = class40_sub5_sub14_sub4.imageHeight * class40_sub5_sub14_sub4.imageWidth;
258256
class40_sub5_sub14_sub4.pixels = new int[i_4_];
259257
for(int i_5_ = 0; i_5_ < i_4_; i_5_++)
260-
class40_sub5_sub14_sub4.pixels[i_5_] = Buffer.anIntArray1972[BitUtils.bitWiseAND(255, is[i_5_])];
258+
class40_sub5_sub14_sub4.pixels[i_5_] = MovedStatics.anIntArray1972[BitUtils.bitWiseAND(255, is[i_5_])];
261259
}
262260
MovedStatics.method569();
263261
return class40_sub5_sub14_sub4s;

src/main/java/org/runejs/client/cache/media/IndexedImage.java

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

33
import org.runejs.client.MovedStatics;
44
import org.runejs.client.cache.CacheArchive;
5-
import org.runejs.client.io.Buffer;
65
import org.runejs.client.media.Rasterizer;
7-
import org.runejs.client.media.renderable.actor.Npc;
86

97
public class IndexedImage extends Rasterizer {
108
public int imgWidth;
@@ -49,8 +47,8 @@ public static IndexedImage[] method315() {
4947
class40_sub5_sub14_sub2.xDrawOffset = MovedStatics.anIntArray1347[i];
5048
class40_sub5_sub14_sub2.yDrawOffset = MovedStatics.anIntArray3111[i];
5149
class40_sub5_sub14_sub2.imgWidth = MovedStatics.anIntArray456[i];
52-
class40_sub5_sub14_sub2.imgHeight = Npc.anIntArray3312[i];
53-
class40_sub5_sub14_sub2.palette = Buffer.anIntArray1972;
50+
class40_sub5_sub14_sub2.imgHeight = MovedStatics.anIntArray3312[i];
51+
class40_sub5_sub14_sub2.palette = MovedStatics.anIntArray1972;
5452
class40_sub5_sub14_sub2.imgPixels = MovedStatics.aByteArrayArray1370[i];
5553
}
5654
MovedStatics.method569();

src/main/java/org/runejs/client/cache/media/TypeFace.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import org.runejs.client.cache.media.textUtils.TextColourQueue;
88
import org.runejs.client.cache.media.textUtils.TextTagNode;
99
import org.runejs.client.cache.media.textUtils.TextTagQueue;
10-
import org.runejs.client.io.Buffer;
1110
import org.runejs.client.media.Rasterizer;
12-
import org.runejs.client.media.renderable.actor.Npc;
1311

1412
import java.awt.*;
1513
import java.util.Random;
@@ -97,7 +95,7 @@ public TypeFace(int[] arg0, int[] arg1, int[] arg2, int[] arg3, byte[][] arg4) {
9795
}
9896

9997
public static TypeFace constructFont() {
100-
TypeFace class40_sub5_sub14_sub1 = new TypeFace(MovedStatics.anIntArray3111, MovedStatics.anIntArray456, Npc.anIntArray3312, Buffer.anIntArray1972, MovedStatics.aByteArrayArray1370);
98+
TypeFace class40_sub5_sub14_sub1 = new TypeFace(MovedStatics.anIntArray3111, MovedStatics.anIntArray456, MovedStatics.anIntArray3312, MovedStatics.anIntArray1972, MovedStatics.aByteArrayArray1370);
10199
MovedStatics.method569();
102100
return class40_sub5_sub14_sub1;
103101
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public class GameInterface extends CachedNode {
9999
* Some kind of timer for item-on-widget clicks (e.g. triggered when taking items from bank)
100100
*/
101101
public static int anInt1651 = 0;
102+
public static int lastItemDragTime = 0;
102103
/**
103104
* The lightened edge (top and left) color of the scroll indicator chip.
104105
*/
@@ -1673,13 +1674,13 @@ public static void scrollInterface(int arg0, int arg1, int arg2, int arg3, GameI
16731674
anInt1171 = 0;
16741675
aBoolean1444 = false;
16751676
if(arg2 >= arg6 && arg2 < arg6 + 16 && arg1 >= arg8 && 16 + arg8 > arg1) {
1676-
arg5.scrollPosition -= Npc.anInt3294 * 4;
1677+
arg5.scrollPosition -= MovedStatics.anInt3294 * 4;
16771678
if(arg7 == 1)
16781679
redrawTabArea = true;
16791680
if(arg7 == 2 || arg7 == 3)
16801681
ChatBox.redrawChatbox = true;
16811682
} else if(arg6 > arg2 || arg6 + 16 <= arg2 || arg1 < arg8 + arg0 + -16 || arg1 >= arg8 + arg0) {
1682-
if(-anInt1171 + arg6 <= arg2 && 16 + arg6 + anInt1171 > arg2 && arg8 + 16 <= arg1 && arg1 < -16 + arg8 + arg0 && Npc.anInt3294 > 0) {
1683+
if(-anInt1171 + arg6 <= arg2 && 16 + arg6 + anInt1171 > arg2 && arg8 + 16 <= arg1 && arg1 < -16 + arg8 + arg0 && MovedStatics.anInt3294 > 0) {
16831684
aBoolean1444 = true;
16841685
int i = (-32 + arg0) * arg0 / arg3;
16851686
if(arg7 == 2 || arg7 == 3)
@@ -1693,7 +1694,7 @@ public static void scrollInterface(int arg0, int arg1, int arg2, int arg3, GameI
16931694
arg5.scrollPosition = (arg3 + -arg0) * i_18_ / i_17_;
16941695
}
16951696
} else {
1696-
arg5.scrollPosition += 4 * Npc.anInt3294;
1697+
arg5.scrollPosition += 4 * MovedStatics.anInt3294;
16971698
if(arg7 == 2 || arg7 == 3)
16981699
ChatBox.redrawChatbox = true;
16991700
if(arg7 == 1)

0 commit comments

Comments
 (0)