Skip to content

Commit af1b284

Browse files
authored
Merge pull request #170 from runejs/move-more-statics
refactor: move static members to more appropriate classes
2 parents 0ec45ea + dc6d5a5 commit af1b284

File tree

88 files changed

+4033
-4357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+4033
-4357
lines changed

src/main/java/org/runejs/OldEngine/MapDecompressor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
*/
66

77
import org.runejs.client.Class26;
8-
import org.runejs.client.Projectile;
98
import org.runejs.client.Landscape;
109
import org.runejs.client.MovedStatics;
11-
import org.runejs.client.cache.def.OverlayDefinition;
1210
import org.runejs.client.media.renderable.actor.Npc;
1311
import org.runejs.client.scene.util.CollisionMap;
1412

@@ -125,7 +123,7 @@ public static void spawnObject(int objectId, int x, int y, int z, int rotation,
125123
int localY = y - Class26.baseY; // ??? is this correct?
126124
int plane = z;
127125
if(localX > -1 && localY > -1) {
128-
if((OverlayDefinition.tile_flags[1][localY][localX] & 2) == 2) {
126+
if((MovedStatics.tile_flags[1][localY][localX] & 2) == 2) {
129127
plane--;
130128
}
131129
}
@@ -135,7 +133,7 @@ public static void spawnObject(int objectId, int x, int y, int z, int rotation,
135133
class20 = groundData[plane];
136134
}
137135
if(localY > 0 && localX > 0 && localY < 103 && localX < 103) {
138-
Projectile.addObject(objectId, localX, localY, z, rotation, type, Npc.currentScene, class20);
136+
MovedStatics.addObject(objectId, localX, localY, z, rotation, type, Npc.currentScene, class20);
139137
}
140138
}
141139

src/main/java/org/runejs/OldEngine/ObjectDecompressor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
*/
66

77
import org.runejs.client.Class26;
8-
import org.runejs.client.Projectile;
98
import org.runejs.client.Landscape;
109
import org.runejs.client.MovedStatics;
11-
import org.runejs.client.cache.def.OverlayDefinition;
1210
import org.runejs.client.io.Buffer;
1311
import org.runejs.client.media.renderable.actor.Npc;
1412
import org.runejs.client.scene.util.CollisionMap;
@@ -128,7 +126,7 @@ public static void spawnObject(int objectId, int x, int y, int z, int rotation,
128126
int localY = y - Class26.baseY; // ??? is this correct?
129127
int plane = z;
130128
if(localX > -1 && localY > -1) {
131-
if((OverlayDefinition.tile_flags[1][localY][localX] & 2) == 2) {
129+
if((MovedStatics.tile_flags[1][localY][localX] & 2) == 2) {
132130
plane--;
133131
}
134132
}
@@ -138,7 +136,7 @@ public static void spawnObject(int objectId, int x, int y, int z, int rotation,
138136
class20 = groundData[plane];
139137
}
140138
if(localY > 0 && localX > 0 && localY < 103 && localX < 103) {
141-
Projectile.addObject(objectId, localX, localY, z, rotation, type, Npc.currentScene, class20);
139+
MovedStatics.addObject(objectId, localX, localY, z, rotation, type, Npc.currentScene, class20);
142140
}
143141
}
144142

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

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

3-
import org.runejs.client.cache.media.gameInterface.GameInterface;
43
import org.runejs.client.util.SignlinkNode;
54

65
public class Class12 {
7-
public static GameInterface chatboxInterface;
8-
public static Class39 mouseCapturer;
9-
public static volatile int eventMouseX = -1;
106
public static int width;
117
public static SignlinkNode aSignlinkNode_394;
128

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

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

33
import org.runejs.client.node.Class40_Sub6;
4-
import org.runejs.client.cache.def.IdentityKit;
54
import org.runejs.client.cache.media.IndexedImage;
65
import org.runejs.client.cache.media.gameInterface.GameInterface;
76
import org.runejs.client.cache.media.gameInterface.GameInterfaceArea;
@@ -10,7 +9,6 @@
109
import org.runejs.client.media.renderable.actor.Player;
1110
import org.runejs.client.media.renderable.actor.PlayerAppearance;
1211
import org.runejs.client.scene.GroundItemTile;
13-
import org.runejs.client.scene.tile.Wall;
1412

1513
public class Class13 {
1614
public static boolean[] playerArray = new boolean[5];
@@ -20,8 +18,8 @@ public class Class13 {
2018
* but not the furthest-right (see `tabHighlightImageBottomRightEdge` for that).
2119
*/
2220
public static IndexedImage tabHighlightImageBottomRight;
23-
public static int mouseX = 0;
2421
public static int[] objectDataIds;
22+
private static int anInt356 = 0;
2523

2624
public static void handleActorAnimation(Actor actor) {
2725
if(actor.worldX < 128 || actor.worldY < 128 || actor.worldX >= 13184 || actor.worldY >= 13184) {
@@ -56,7 +54,7 @@ public static void handleRequests() {
5654
for(; ; ) {
5755
Class40_Sub6 class40_sub6;
5856
synchronized(RSCanvas.aLinkedList_53) {
59-
class40_sub6 = (Class40_Sub6) IdentityKit.aLinkedList_2604.removeFirst();
57+
class40_sub6 = (Class40_Sub6) MovedStatics.aLinkedList_2604.removeFirst();
6058
}
6159
if(class40_sub6 == null)
6260
break;
@@ -83,9 +81,9 @@ public static int generateHslBitset(int s, int l, int h) {
8381
}
8482

8583
public static synchronized byte[] method246(int arg1) {
86-
if(arg1 == 100 && Wall.anInt356 > 0) {
87-
byte[] is = GroundItemTile.aByteArrayArray1377[--Wall.anInt356];
88-
GroundItemTile.aByteArrayArray1377[Wall.anInt356] = null;
84+
if(arg1 == 100 && anInt356 > 0) {
85+
byte[] is = GroundItemTile.aByteArrayArray1377[--anInt356];
86+
GroundItemTile.aByteArrayArray1377[anInt356] = null;
8987
return is;
9088
}
9189
if(arg1 == 5000 && Main.anInt1764 > 0) {

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

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

3-
import org.runejs.client.cache.media.gameInterface.GameInterface;
4-
import org.runejs.client.frame.ChatBox;
5-
import org.runejs.client.language.English;
63
import org.runejs.client.media.renderable.actor.Player;
7-
import org.runejs.client.message.outbound.chat.ModifySocialListOutboundMessage;
8-
import org.runejs.client.net.OutgoingPackets;
9-
import org.runejs.client.scene.SceneCluster;
10-
import org.runejs.client.util.TextUtils;
114

125
import java.awt.*;
136

@@ -24,35 +17,6 @@ public static int method274() {
2417
return Class49.anInt1147++;
2518
}
2619

27-
public static void method275(long arg1) {
28-
if(arg1 != 0L) {
29-
if(MovedStatics.anInt1008 >= 100)
30-
ChatBox.addChatMessage("", English.yourIgnoreListIsFull.toString(), 0);
31-
else {
32-
String class1 = TextUtils.formatName(TextUtils.longToName(arg1));
33-
for(int i = 0; i < MovedStatics.anInt1008; i++) {
34-
if(arg1 == Player.ignores[i]) {
35-
ChatBox.addChatMessage("", class1 + English.suffixIsAlreadyOnYourIgnoreList, 0);
36-
return;
37-
}
38-
}
39-
for(int i = 0; Player.friendsCount > i; i++) {
40-
if(Class59.friends[i] == arg1) {
41-
ChatBox.addChatMessage("", English.pleaseRemove + class1 + English.fromYourFriendListFirst, 0);
42-
return;
43-
}
44-
}
45-
if(!class1.equals(Player.localPlayer.playerName)) {
46-
Player.ignores[MovedStatics.anInt1008++] = arg1;
47-
GameInterface.redrawTabArea = true;
48-
49-
OutgoingPackets.sendMessage(
50-
new ModifySocialListOutboundMessage(arg1, ModifySocialListOutboundMessage.SocialList.IGNORE, ModifySocialListOutboundMessage.SocialListAction.ADD));
51-
}
52-
}
53-
}
54-
}
55-
5620
public static void animatePlayers(int playerIndex) {
5721
for(int currentPlayerIndex = playerIndex; Player.localPlayerCount > currentPlayerIndex; currentPlayerIndex++) {
5822
int actualIndex;

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

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,7 @@
11
package org.runejs.client;
22

3-
import org.runejs.client.cache.CacheArchive;
4-
import org.runejs.client.cache.def.GameObjectDefinition;
5-
import org.runejs.client.cache.def.OverlayDefinition;
6-
import org.runejs.client.cache.media.ImageRGB;
7-
import org.runejs.client.cache.media.IndexedImage;
8-
import org.runejs.client.io.Buffer;
9-
import org.runejs.client.scene.Scene;
10-
import org.runejs.client.scene.util.CollisionMap;
11-
123
public class Class24 {
134
public static int[] fullScreenTextureArray;
145

15-
public static IndexedImage[] method337(CacheArchive arg1, int arg2, int arg3) {
16-
if(!ImageRGB.spriteExists(arg2, arg3, arg1))
17-
return null;
18-
return MovedStatics.method315();
19-
}
20-
21-
public static int getRotatedTileX(int rotation, int x, int y) {
22-
rotation &= 0x3;
23-
if(rotation == 0)
24-
return x;
25-
if(rotation == 1)
26-
return y;
27-
if(rotation == 2)
28-
return -x + 7;
29-
return 7 + -y;
30-
}
31-
32-
33-
public static void constructMapRegionObjects(int drawX, int drawY, int drawingPlane, int orientation, int x, int y, int plane, Scene scene, byte[] objectData, CollisionMap[] collisionMaps) {
34-
Buffer objectBuffer = new Buffer(objectData);
35-
int i = -1;
36-
for(; ; ) {
37-
int idOffset = objectBuffer.getSmart();
38-
if(idOffset == 0)
39-
break;
40-
int objectPositionInfo = 0;
41-
i += idOffset;
42-
for(; ; ) {
43-
int objectInfoOffset = objectBuffer.getSmart();
44-
if(objectInfoOffset == 0)
45-
break;
46-
objectPositionInfo += -1 + objectInfoOffset;
47-
int objectPlane = objectPositionInfo >> 12;
48-
int objectX = 0x3f & objectPositionInfo >> 6;
49-
int objectMetadata = objectBuffer.getUnsignedByte();
50-
int objectType = objectMetadata >> 2;
51-
int objectY = objectPositionInfo & 0x3f;
52-
int originalOrientation = objectMetadata & 0x3;
53-
if(objectPlane == drawingPlane && drawX <= objectX && objectX < 8 + drawX && drawY <= objectY && drawY + 8 > objectY) {
54-
GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(i);
55-
int tileX = getRotatedObjectX(objectX & 0x7, 0x7 & objectY, gameObjectDefinition.sizeX, gameObjectDefinition.sizeY, orientation, originalOrientation) + x;
56-
int tileY = getRotatedObjectY(objectX & 0x7, objectY & 0x7, gameObjectDefinition.sizeX, gameObjectDefinition.sizeY, orientation, originalOrientation) + y;
57-
if(tileX > 0 && tileY > 0 && tileX < 103 && tileY < 103) {
58-
CollisionMap collisionMap = null;
59-
int collisionMapPlane = plane;
60-
if((OverlayDefinition.tile_flags[1][tileX][tileY] & 0x2) == 2) // bridge tile, go down 1 level
61-
collisionMapPlane--;
62-
if(collisionMapPlane >= 0)
63-
collisionMap = collisionMaps[collisionMapPlane];
64-
Projectile.addObject(i, tileX, tileY, plane, originalOrientation + orientation & 0x3, objectType, scene, collisionMap);
65-
}
66-
}
67-
}
68-
}
69-
}
70-
71-
public static int getRotatedObjectX(int x, int y, int sizeX, int sizeY, int orientation, int originalOrientation) {
72-
orientation &= 0x3;
73-
if ((originalOrientation & 0x1) == 1) {
74-
int i = sizeX;
75-
sizeX = sizeY;
76-
sizeY = i;
77-
}
78-
if (orientation == 0)
79-
return x;
80-
if (orientation == 1)
81-
return y;
82-
if (orientation == 2)
83-
return 7 - (x + sizeX) + 1;
84-
return 7 + -y + 1 + -sizeY;
85-
}
866

87-
public static int getRotatedObjectY(int x, int y, int sizeX, int sizeY, int orientation, int originalOrientation) {
88-
orientation &= 0x3;
89-
if((originalOrientation & 0x1) == 1) {
90-
int i = sizeX;
91-
sizeX = sizeY;
92-
sizeY = i;
93-
}
94-
if(orientation == 0)
95-
return y;
96-
if(orientation == 1)
97-
return 1 + -sizeX + 7 - x;
98-
if(orientation == 2)
99-
return -sizeY + 1 + -y + 7;
100-
return x;
101-
}
1027
}

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,8 @@
55
import java.awt.*;
66

77
public class Class26 {
8-
public static int loginScreenState = 0;
98
public static Image loadingBoxImage;
109
public static CacheArchive aCacheArchive_632;
1110
public static int baseY;
1211

13-
public static Class stringToType(String typeCode) throws ClassNotFoundException {
14-
if(typeCode.equals("B"))
15-
return Byte.TYPE;
16-
if(typeCode.equals("I"))
17-
return Integer.TYPE;
18-
if(typeCode.equals("S"))
19-
return Short.TYPE;
20-
if(typeCode.equals("J"))
21-
return Long.TYPE;
22-
if(typeCode.equals("Z"))
23-
return Boolean.TYPE;
24-
if(typeCode.equals("F"))
25-
return Float.TYPE;
26-
if(typeCode.equals("D"))
27-
return Double.TYPE;
28-
if(typeCode.equals("C"))
29-
return Character.TYPE;
30-
return Class.forName(typeCode);
31-
}
32-
3312
}

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
import org.runejs.client.chat.ChatColorEffect;
77
import org.runejs.client.chat.ChatShapeEffect;
88
import org.runejs.client.frame.ChatBox;
9-
import org.runejs.client.language.Native;
109
import org.runejs.client.media.Rasterizer;
1110
import org.runejs.client.media.renderable.actor.Actor;
1211
import org.runejs.client.media.renderable.actor.Npc;
1312
import org.runejs.client.media.renderable.actor.Player;
1413
import org.runejs.client.media.renderable.actor.PlayerAppearance;
1514
import org.runejs.client.scene.Point2d;
1615
import org.runejs.client.scene.SceneCluster;
17-
import org.runejs.client.scene.tile.FloorDecoration;
1816

1917
public class Class33 {
20-
public static int anInt784 = 0;
2118
public static int[] selectedMenuActions = new int[500];
2219

2320

@@ -52,7 +49,7 @@ else if(i < Player.localPlayerCount)
5249
if(screenPos != null)
5350
ProducingGraphicsBuffer_Sub1.headIconSprites[npcDefinition.headIcon].drawImage(-12 + screenPos.x, screenPos.y + -30);
5451
}
55-
if(Player.headIconDrawType == 1 && HuffmanEncoding.anInt1545 == Player.npcIds[-Player.localPlayerCount + i] && MovedStatics.pulseCycle % 20 < 10) {
52+
if(Player.headIconDrawType == 1 && MovedStatics.anInt1545 == Player.npcIds[-Player.localPlayerCount + i] && MovedStatics.pulseCycle % 20 < 10) {
5653
Point2d screenPos = MovedStatics.getProjectedScreenPosition(actor.anInt3117 + 15, actor.worldY, actor.worldX);
5754
if(screenPos != null)
5855
MovedStatics.hintIconSprites[0].drawImage(screenPos.x + -12, screenPos.y + -28);
@@ -65,7 +62,7 @@ else if(i < Player.localPlayerCount)
6562

6663
if (screenPos != null) {
6764
if(targetPlayer.isSkulled != -1) {
68-
FloorDecoration.aClass40_Sub5_Sub14_Sub4Array603[targetPlayer.isSkulled].drawImage(screenPos.x - 12, screenPos.y - drawHeight);
65+
MovedStatics.aClass40_Sub5_Sub14_Sub4Array603[targetPlayer.isSkulled].drawImage(screenPos.x - 12, screenPos.y - drawHeight);
6966
drawHeight += 25;
7067
}
7168
if(targetPlayer.headIcon != -1) {
@@ -295,21 +292,4 @@ public static boolean menuHasAddFriend(int arg1) {
295292
return i == ActionRowType.ADD_FRIEND.getId();
296293
}
297294

298-
public static int getRotatedTileY(int x, int y, int rotation) {
299-
rotation &= 0x3;
300-
if(rotation == 0)
301-
return y;
302-
if(rotation == 1)
303-
return 7 + -x;
304-
if(rotation == 2)
305-
return -y + 7;
306-
return x;
307-
308-
}
309-
310-
public static void setLoginScreenMessage(String line1, String line2, String line3) {
311-
Native.loginScreenMessageLineOne = line1;
312-
Native.loginScreenMessageLineTwo = line2;
313-
Native.loginScreenMessageLineThree = line3;
314-
}
315295
}

0 commit comments

Comments
 (0)