Skip to content

Commit 12363e6

Browse files
committed
refactor: rename and move AnimationSequence statics
1 parent 5d5fcdd commit 12363e6

File tree

5 files changed

+72
-69
lines changed

5 files changed

+72
-69
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import org.runejs.client.media.renderable.actor.Actor;
99
import org.runejs.client.node.CachedNode;
1010

11+
/**
12+
* anim skeleton?
13+
*/
1114
public class Class40_Sub5_Sub15 extends CachedNode {
1215
public FrameDefinition[] aFrameDefinitionArray2794;
1316

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

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.runejs.client.node.Class40_Sub6;
2121
import org.runejs.client.node.HashTable;
2222
import org.runejs.client.cache.CacheArchive;
23-
import org.runejs.client.cache.media.AnimationSequence;
2423
import org.runejs.client.cache.media.IndexedImage;
2524
import org.runejs.client.cache.media.TypeFace;
2625
import org.runejs.client.frame.ChatBox;
@@ -329,6 +328,11 @@ public class MovedStatics {
329328
public static ProducingGraphicsBuffer tabTop;
330329
public static byte[][] aByteArrayArray1370;
331330
public static Object anObject162 = new Object();
331+
/**
332+
* Last varp handle cycle?
333+
*/
334+
public static int anInt2480 = 0;
335+
public static ImageRGB[] aClass40_Sub5_Sub14_Sub4Array2474;
332336

333337
public static void method440() {
334338
if (aBoolean512) {
@@ -1232,7 +1236,7 @@ public static void drawMenu(int xOffSet, int yOffSet) {
12321236

12331237
public static void handleVarPlayers(int varPlayerIndex) {
12341238
do {
1235-
AnimationSequence.anInt2480 = pulseCycle;
1239+
anInt2480 = pulseCycle;
12361240
SoundSystem.setObjectSounds();
12371241
int varPlayerType = VarPlayerDefinition.getDefinition(varPlayerIndex).type;
12381242
if(varPlayerType != 0) {
@@ -2585,7 +2589,7 @@ else if(i < Player.localPlayerCount)
25852589
if(i_2_ == 3) {
25862590
screenPos = screenPos.add(new Point2d(15, -10));
25872591
}
2588-
AnimationSequence.aClass40_Sub5_Sub14_Sub4Array2474[actor.anIntArray3086[i_2_]].drawImage(screenPos.x + -12, -12 + screenPos.y);
2592+
aClass40_Sub5_Sub14_Sub4Array2474[actor.anIntArray3086[i_2_]].drawImage(screenPos.x + -12, -12 + screenPos.y);
25892593
TypeFace.fontSmall.drawStringLeft(Integer.toString(actor.anIntArray3087[i_2_]), screenPos.x, 4 + screenPos.y, 0);
25902594
TypeFace.fontSmall.drawStringLeft(Integer.toString(actor.anIntArray3087[i_2_]), screenPos.x - 1, screenPos.y + 3, 16777215);
25912595
}
@@ -3318,4 +3322,39 @@ public static void method569() {
33183322
Buffer.anIntArray1972 = null;
33193323
anIntArray1347 = null;
33203324
}
3325+
3326+
/**
3327+
* walk to object
3328+
*/
3329+
public static boolean method596(int arg0, int arg1, byte junk, int arg3) {
3330+
int i = 0x7fff & arg1 >> 14;
3331+
int i_14_ = Game.currentScene.getArrangement(Player.worldLevel, arg0, arg3, arg1);
3332+
if(i_14_ == -1)
3333+
return false;
3334+
int orientation = 0x3 & i_14_ >> 6;
3335+
int type = 0x1f & i_14_;
3336+
if(type != 10 && type != 11 && type != 22)
3337+
Pathfinding.doObjectWalkTo(Player.localPlayer.pathY[0], Player.localPlayer.pathX[0], arg0, arg3, 0, 0, 0, 1 + type, orientation);
3338+
else {
3339+
GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(i);
3340+
int i_17_ = gameObjectDefinition.blockingMask;
3341+
if(orientation != 0)
3342+
i_17_ = (i_17_ >> 4 + -orientation) + (0xf & i_17_ << orientation);
3343+
int i_18_;
3344+
int i_19_;
3345+
if(orientation == 0 || orientation == 2) {
3346+
i_19_ = gameObjectDefinition.sizeY;
3347+
i_18_ = gameObjectDefinition.sizeX;
3348+
} else {
3349+
i_18_ = gameObjectDefinition.sizeY;
3350+
i_19_ = gameObjectDefinition.sizeX;
3351+
}
3352+
Pathfinding.doObjectWalkTo(Player.localPlayer.pathY[0], Player.localPlayer.pathX[0], arg0, arg3, i_18_, i_19_, i_17_, 0, 0);
3353+
}
3354+
GameInterface.crossX = MouseHandler.clickX;
3355+
crossType = 2;
3356+
GameInterface.crossY = MouseHandler.clickY;
3357+
crossIndex = 0;
3358+
return true;
3359+
}
33213360
}

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

Lines changed: 17 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,17 @@
22

33
import org.runejs.client.*;
44
import org.runejs.client.cache.CacheArchive;
5-
import org.runejs.client.cache.def.GameObjectDefinition;
6-
import org.runejs.client.cache.media.gameInterface.GameInterface;
7-
import org.runejs.client.input.MouseHandler;
85
import org.runejs.client.io.Buffer;
96
import org.runejs.client.media.renderable.Model;
10-
import org.runejs.client.media.renderable.actor.Pathfinding;
11-
import org.runejs.client.media.renderable.actor.Player;
127
import org.runejs.client.node.CachedNode;
138
import org.runejs.client.node.NodeCache;
149

1510
public class AnimationSequence extends CachedNode {
16-
public static ImageRGB[] aClass40_Sub5_Sub14_Sub4Array2474;
17-
public static int anInt2480 = 0;
18-
public static CacheArchive aCacheArchive_2484;
19-
public static NodeCache animationSequenceCache = new NodeCache(64);
20-
public static NodeCache aClass9_998 = new NodeCache(100);
21-
public static CacheArchive aCacheArchive_2162;
22-
public static CacheArchive aCacheArchive_2364;
11+
private static CacheArchive definitionArchive;
12+
private static NodeCache animationSequenceCache = new NodeCache(64);
13+
private static NodeCache skeletonCache = new NodeCache(100);
14+
private static CacheArchive skinArchive;
15+
private static CacheArchive skeletonArchive;
2316

2417
public int[] frameLengths;
2518
public int precedenceAnimating = -1;
@@ -44,46 +37,14 @@ public AnimationSequence() {
4437
stretches = false;
4538
}
4639

47-
public static boolean method596(int arg0, int arg1, byte junk, int arg3) {
48-
int i = 0x7fff & arg1 >> 14;
49-
int i_14_ = Game.currentScene.getArrangement(Player.worldLevel, arg0, arg3, arg1);
50-
if(i_14_ == -1)
51-
return false;
52-
int orientation = 0x3 & i_14_ >> 6;
53-
int type = 0x1f & i_14_;
54-
if(type != 10 && type != 11 && type != 22)
55-
Pathfinding.doObjectWalkTo(Player.localPlayer.pathY[0], Player.localPlayer.pathX[0], arg0, arg3, 0, 0, 0, 1 + type, orientation);
56-
else {
57-
GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(i);
58-
int i_17_ = gameObjectDefinition.blockingMask;
59-
if(orientation != 0)
60-
i_17_ = (i_17_ >> 4 + -orientation) + (0xf & i_17_ << orientation);
61-
int i_18_;
62-
int i_19_;
63-
if(orientation == 0 || orientation == 2) {
64-
i_19_ = gameObjectDefinition.sizeY;
65-
i_18_ = gameObjectDefinition.sizeX;
66-
} else {
67-
i_18_ = gameObjectDefinition.sizeY;
68-
i_19_ = gameObjectDefinition.sizeX;
69-
}
70-
Pathfinding.doObjectWalkTo(Player.localPlayer.pathY[0], Player.localPlayer.pathX[0], arg0, arg3, i_18_, i_19_, i_17_, 0, 0);
71-
}
72-
GameInterface.crossX = MouseHandler.clickX;
73-
MovedStatics.crossType = 2;
74-
GameInterface.crossY = MouseHandler.clickY;
75-
MovedStatics.crossIndex = 0;
76-
return true;
77-
}
78-
7940
private static Class40_Sub5_Sub15 method960(int arg1) {
80-
Class40_Sub5_Sub15 class40_sub5_sub15 = (Class40_Sub5_Sub15) aClass9_998.get((long) arg1);
81-
if(class40_sub5_sub15 != null)
82-
return class40_sub5_sub15;
83-
class40_sub5_sub15 = method421(aCacheArchive_2364, arg1, aCacheArchive_2162, false);
84-
if(class40_sub5_sub15 != null)
85-
aClass9_998.put((long) arg1, class40_sub5_sub15);
86-
return class40_sub5_sub15;
41+
Class40_Sub5_Sub15 skeleton = (Class40_Sub5_Sub15) skeletonCache.get((long) arg1);
42+
if(skeleton != null)
43+
return skeleton;
44+
skeleton = method421(skeletonArchive, arg1, skinArchive, false);
45+
if(skeleton != null)
46+
skeletonCache.put((long) arg1, skeleton);
47+
return skeleton;
8748
}
8849

8950
private static Class40_Sub5_Sub15 method421(CacheArchive skeletonArchive, int arg2, CacheArchive skinArchive, boolean arg4) {
@@ -118,7 +79,7 @@ public static AnimationSequence getAnimationSequence(int animationId) {
11879

11980
if(animationSequence != null)
12081
return animationSequence;
121-
byte[] is = aCacheArchive_2484.getFile(12, animationId);
82+
byte[] is = definitionArchive.getFile(12, animationId);
12283
animationSequence = new AnimationSequence();
12384
if(is != null)
12485
animationSequence.decodeAllAnimationSequences(new Buffer(is));
@@ -129,13 +90,13 @@ public static AnimationSequence getAnimationSequence(int animationId) {
12990

13091
public static void clearAnimationCache() {
13192
animationSequenceCache.clear();
132-
aClass9_998.clear();
93+
skeletonCache.clear();
13394
}
13495

13596
public static void initializeAnimationCaches(CacheArchive skinArchive, CacheArchive definitionArchive, CacheArchive skeletonArchive) {
136-
aCacheArchive_2162 = skinArchive;
137-
aCacheArchive_2364 = skeletonArchive;
138-
aCacheArchive_2484 = definitionArchive;
97+
AnimationSequence.skinArchive = skinArchive;
98+
AnimationSequence.skeletonArchive = skeletonArchive;
99+
AnimationSequence.definitionArchive = definitionArchive;
139100
}
140101

141102
public Model method590(Model arg0, AnimationSequence animationSequence, int arg2, int arg3, byte arg4) {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public static void processMenuActions(int arg1) {
651651
OutgoingPackets.sendMessage(new ExamineObjectOutboundMessage(objectId));
652652
}
653653
if(action == ActionRowType.INTERACT_WITH_OBJECT_OPTION_4.getId()) {
654-
AnimationSequence.method596(i, npcIdx, (byte) -79, i_10_);
654+
MovedStatics.method596(i, npcIdx, (byte) -79, i_10_);
655655

656656
int objectX = MovedStatics.baseX + i;
657657
int objectId = (0x1ffffd20 & npcIdx) >> 14;
@@ -976,7 +976,7 @@ public static void processMenuActions(int arg1) {
976976
OutgoingPackets.sendMessage(new ExamineItemOutboundMessage(npcIdx));
977977
}
978978
if(action == ActionRowType.INTERACT_WITH_OBJECT_OPTION_5.getId()) {
979-
AnimationSequence.method596(i, npcIdx, (byte) -11, i_10_);
979+
MovedStatics.method596(i, npcIdx, (byte) -11, i_10_);
980980

981981
int objectId = (0x1ffffd20 & npcIdx) >> 14;
982982
int objectY = i_10_ + MovedStatics.baseY;
@@ -1027,7 +1027,7 @@ public static void processMenuActions(int arg1) {
10271027
}
10281028
}
10291029
if(action == ActionRowType.INTERACT_WITH_OBJECT_OPTION_2.getId()) {
1030-
AnimationSequence.method596(i, npcIdx, (byte) -77, i_10_);
1030+
MovedStatics.method596(i, npcIdx, (byte) -77, i_10_);
10311031

10321032
int objectX = i + MovedStatics.baseX;
10331033
int objectY = i_10_ + MovedStatics.baseY;
@@ -1042,7 +1042,7 @@ public static void processMenuActions(int arg1) {
10421042
)
10431043
);
10441044
}
1045-
if(action == ActionRowType.USE_ITEM_ON_OBJECT.getId() && AnimationSequence.method596(i, npcIdx, (byte) -104, i_10_)) {
1045+
if(action == ActionRowType.USE_ITEM_ON_OBJECT.getId() && MovedStatics.method596(i, npcIdx, (byte) -104, i_10_)) {
10461046
int widgetId = (itemSelectedWidgetId >> 16) & 0xFFFF;
10471047
int containerId = itemSelectedWidgetId & 0xFFFF;
10481048

@@ -1283,7 +1283,7 @@ public static void processMenuActions(int arg1) {
12831283
}
12841284
}
12851285
if(action == ActionRowType.INTERACT_WITH_OBJECT_OPTION_3.getId()) {
1286-
AnimationSequence.method596(i, npcIdx, (byte) -104, i_10_);
1286+
MovedStatics.method596(i, npcIdx, (byte) -104, i_10_);
12871287

12881288
int objectY = i_10_ + MovedStatics.baseY;
12891289
int objectId = npcIdx >> 14 & 0x7fff;
@@ -1306,7 +1306,7 @@ public static void processMenuActions(int arg1) {
13061306
ChatBox.dialogueId = -1;
13071307
ChatBox.redrawChatbox = true;
13081308
}
1309-
if(action == ActionRowType.CAST_MAGIC_ON_OBJECT.getId() && AnimationSequence.method596(i, npcIdx, (byte) -27, i_10_)) {
1309+
if(action == ActionRowType.CAST_MAGIC_ON_OBJECT.getId() && MovedStatics.method596(i, npcIdx, (byte) -27, i_10_)) {
13101310
OutgoingPackets.sendMessage(
13111311
new CastMagicOnObjectOutboundMessage(
13121312
selectedSpell,
@@ -1493,7 +1493,7 @@ public static void processMenuActions(int arg1) {
14931493
}
14941494
}
14951495
if(action == ActionRowType.INTERACT_WITH_OBJECT_OPTION_1.getId()) {
1496-
AnimationSequence.method596(i, npcIdx, (byte) -47, i_10_);
1496+
MovedStatics.method596(i, npcIdx, (byte) -47, i_10_);
14971497
int objectId = 0x7fff & npcIdx >> 14;
14981498
int objectX = i + MovedStatics.baseX;
14991499
int objectY = i_10_ + MovedStatics.baseY;
@@ -1845,7 +1845,7 @@ public static void runClientScriptsForInterface(int minY, int arg1, int scrollWi
18451845
}
18461846
if (gameInterface.anObjectArray2712 != null && (arg3 & 0x80) != 0)
18471847
ClientScriptRunner.runClientScripts(gameInterface.anObjectArray2712, 0, 0, gameInterface, 0);
1848-
if (AnimationSequence.anInt2480 == MovedStatics.pulseCycle && gameInterface.anObjectArray2650 != null && (arg3 & 0x100) != 0)
1848+
if (MovedStatics.anInt2480 == MovedStatics.pulseCycle && gameInterface.anObjectArray2650 != null && (arg3 & 0x100) != 0)
18491849
ClientScriptRunner.runClientScripts(gameInterface.anObjectArray2650, 0, 0, gameInterface, 0);
18501850
}
18511851
}

src/main/java/org/runejs/client/scene/InteractiveObjectTemporary.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ public static void startup() {
180180
Minimap.mapFunctionIcons = method526(CacheArchive.gameImageCacheArchive, Native.mapFunction, "");
181181
else
182182
i++;
183-
if (AnimationSequence.aClass40_Sub5_Sub14_Sub4Array2474 != null)
183+
if (MovedStatics.aClass40_Sub5_Sub14_Sub4Array2474 != null)
184184
i++;
185185
else
186-
AnimationSequence.aClass40_Sub5_Sub14_Sub4Array2474 = method526(CacheArchive.gameImageCacheArchive, Native.hitmarks, "");
186+
MovedStatics.aClass40_Sub5_Sub14_Sub4Array2474 = method526(CacheArchive.gameImageCacheArchive, Native.hitmarks, "");
187187
if (MovedStatics.aClass40_Sub5_Sub14_Sub4Array603 == null)
188188
MovedStatics.aClass40_Sub5_Sub14_Sub4Array603 = method526(CacheArchive.gameImageCacheArchive, Native.headiconsPK, "");
189189
else

0 commit comments

Comments
 (0)