Skip to content

Commit 1d50eaa

Browse files
authored
Merge pull request #161 from Jameskmonger/actor-updating-refactors
refactor: partial renaming of actor updating
2 parents b5adbf5 + 885b0ba commit 1d50eaa

File tree

10 files changed

+186
-186
lines changed

10 files changed

+186
-186
lines changed

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,30 @@ public class Class13 {
2626
public static void handleActorAnimation(Actor actor) {
2727
if(actor.worldX < 128 || actor.worldY < 128 || actor.worldX >= 13184 || actor.worldY >= 13184) {
2828
actor.playingAnimation = -1;
29-
actor.anInt3112 = 0;
30-
actor.anInt3107 = 0;
29+
actor.forceMoveEndCycle = 0;
30+
actor.forceMoveStartCycle = 0;
3131
actor.graphicId = -1;
32-
actor.worldX = actor.anInt3096 * 64 + 128 * actor.pathY[0];
33-
actor.worldY = actor.pathX[0] * 128 + 64 * actor.anInt3096;
32+
actor.worldX = actor.size * 64 + 128 * actor.pathY[0];
33+
actor.worldY = actor.pathX[0] * 128 + 64 * actor.size;
3434
actor.method790(0);
3535
}
3636
if(actor == Player.localPlayer && (actor.worldX < 1536 || actor.worldY < 1536 || actor.worldX >= 11776 || actor.worldY >= 11776)) {
3737
actor.graphicId = -1;
38-
actor.anInt3107 = 0;
39-
actor.anInt3112 = 0;
38+
actor.forceMoveStartCycle = 0;
39+
actor.forceMoveEndCycle = 0;
4040
actor.playingAnimation = -1;
41-
actor.worldX = actor.pathY[0] * 128 + actor.anInt3096 * 64;
42-
actor.worldY = 64 * actor.anInt3096 + actor.pathX[0] * 128;
41+
actor.worldX = actor.pathY[0] * 128 + actor.size * 64;
42+
actor.worldY = 64 * actor.size + actor.pathX[0] * 128;
4343
actor.method790(0);
4444
}
45-
if(actor.anInt3112 > MovedStatics.pulseCycle)
46-
method631(actor);
47-
else if(actor.anInt3107 < MovedStatics.pulseCycle)
48-
Class44.method898(255, actor);
45+
if(actor.forceMoveEndCycle > MovedStatics.pulseCycle)
46+
updateForcedMovement(actor);
47+
else if(actor.forceMoveStartCycle < MovedStatics.pulseCycle)
48+
Class44.processWalkingStep(255, actor);
4949
else
50-
PlayerAppearance.method381(actor);
51-
Projectile.method762(actor);
52-
Class40_Sub5_Sub15.method736(true, actor);
50+
PlayerAppearance.startForcedMovement(actor);
51+
Projectile.updateFacingDirection(actor);
52+
Class40_Sub5_Sub15.updateAnimation(actor);
5353
}
5454

5555
public static void handleRequests() {
@@ -136,20 +136,20 @@ public static void method249() {
136136
}
137137
}
138138

139-
public static void method631(Actor actor) {
140-
int i = actor.anInt3125 * 128 + 64 * actor.anInt3096;
141-
int i_0_ = actor.anInt3112 + -MovedStatics.pulseCycle;
142-
if(actor.anInt3073 == 0)
139+
public static void updateForcedMovement(Actor actor) {
140+
int deltaTime = actor.forceMoveEndCycle - MovedStatics.pulseCycle;
141+
int destX = actor.forceMoveStartX * 128 + 64 * actor.size;
142+
if(actor.forceMoveFaceDirection == 0)
143143
actor.initialFaceDirection = 1024;
144-
if(actor.anInt3073 == 1)
144+
if(actor.forceMoveFaceDirection == 1)
145145
actor.initialFaceDirection = 1536;
146-
if(actor.anInt3073 == 2)
146+
if(actor.forceMoveFaceDirection == 2)
147147
actor.initialFaceDirection = 0;
148-
int i_1_ = actor.anInt3096 * 64 + 128 * actor.anInt3081;
149-
actor.worldX += (i - actor.worldX) / i_0_;
150-
if(actor.anInt3073 == 3)
148+
int destY = actor.size * 64 + 128 * actor.forceMoveStartY;
149+
actor.worldX += (destX - actor.worldX) / deltaTime;
150+
if(actor.forceMoveFaceDirection == 3)
151151
actor.initialFaceDirection = 512;
152152
actor.anInt3074 = 0;
153-
actor.worldY += (-actor.worldY + i_1_) / i_0_;
153+
actor.worldY += (-actor.worldY + destY) / deltaTime;
154154
}
155155
}

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

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -59,75 +59,75 @@ public static boolean method735(int arg1) {
5959
return false;
6060
}
6161

62-
public static void method736(boolean arg0, Actor arg1) {
63-
arg1.aBoolean3105 = false;
64-
if(arg1.anInt3077 != -1) {
65-
AnimationSequence animationSequence = ProducingGraphicsBuffer_Sub1.getAnimationSequence(arg1.anInt3077);
62+
public static void updateAnimation(Actor actor) {
63+
actor.aBoolean3105 = false;
64+
if(actor.anInt3077 != -1) {
65+
AnimationSequence animationSequence = ProducingGraphicsBuffer_Sub1.getAnimationSequence(actor.anInt3077);
6666
if(animationSequence == null || animationSequence.frameIds == null)
67-
arg1.anInt3077 = -1;
67+
actor.anInt3077 = -1;
6868
else {
69-
arg1.anInt3120++;
70-
if(arg1.anInt3116 < animationSequence.frameIds.length && animationSequence.frameLengths[arg1.anInt3116] < arg1.anInt3120) {
71-
arg1.anInt3116++;
72-
arg1.anInt3120 = 1;
69+
actor.anInt3120++;
70+
if(actor.anInt3116 < animationSequence.frameIds.length && animationSequence.frameLengths[actor.anInt3116] < actor.anInt3120) {
71+
actor.anInt3116++;
72+
actor.anInt3120 = 1;
7373
}
74-
if(animationSequence.frameIds.length <= arg1.anInt3116) {
75-
arg1.anInt3116 = 0;
76-
arg1.anInt3120 = 0;
74+
if(animationSequence.frameIds.length <= actor.anInt3116) {
75+
actor.anInt3116 = 0;
76+
actor.anInt3120 = 0;
7777
}
7878
}
7979
}
80-
if(arg1.graphicId != -1 && MovedStatics.pulseCycle >= arg1.graphicDelay) {
81-
if(arg1.anInt3140 < 0)
82-
arg1.anInt3140 = 0;
83-
int i = SpotAnimDefinition.forId(arg1.graphicId).animationId;
80+
if(actor.graphicId != -1 && MovedStatics.pulseCycle >= actor.graphicDelay) {
81+
if(actor.anInt3140 < 0)
82+
actor.anInt3140 = 0;
83+
int i = SpotAnimDefinition.forId(actor.graphicId).animationId;
8484
if(i == -1)
85-
arg1.graphicId = -1;
85+
actor.graphicId = -1;
8686
else {
8787
AnimationSequence animationSequence = ProducingGraphicsBuffer_Sub1.getAnimationSequence(i);
8888
if(animationSequence == null || animationSequence.frameIds == null)
89-
arg1.graphicId = -1;
89+
actor.graphicId = -1;
9090
else {
91-
arg1.anInt3129++;
92-
if(animationSequence.frameIds.length > arg1.anInt3140 && arg1.anInt3129 > animationSequence.frameLengths[arg1.anInt3140]) {
93-
arg1.anInt3129 = 1;
94-
arg1.anInt3140++;
91+
actor.anInt3129++;
92+
if(animationSequence.frameIds.length > actor.anInt3140 && actor.anInt3129 > animationSequence.frameLengths[actor.anInt3140]) {
93+
actor.anInt3129 = 1;
94+
actor.anInt3140++;
9595
}
96-
if(animationSequence.frameIds.length <= arg1.anInt3140 && (arg1.anInt3140 < 0 || animationSequence.frameIds.length <= arg1.anInt3140))
97-
arg1.graphicId = -1;
96+
if(animationSequence.frameIds.length <= actor.anInt3140 && (actor.anInt3140 < 0 || animationSequence.frameIds.length <= actor.anInt3140))
97+
actor.graphicId = -1;
9898
}
9999
}
100100
}
101-
if(arg0) {
102-
if(arg1.playingAnimation != -1 && arg1.playingAnimationDelay <= 1) {
103-
AnimationSequence animationSequence = ProducingGraphicsBuffer_Sub1.getAnimationSequence(arg1.playingAnimation);
104-
if(animationSequence.precedenceAnimating == 1 && arg1.anInt3094 > 0 && arg1.anInt3112 <= MovedStatics.pulseCycle && MovedStatics.pulseCycle > arg1.anInt3107) {
105-
arg1.playingAnimationDelay = 1;
101+
if(true) {
102+
if(actor.playingAnimation != -1 && actor.playingAnimationDelay <= 1) {
103+
AnimationSequence animationSequence = ProducingGraphicsBuffer_Sub1.getAnimationSequence(actor.playingAnimation);
104+
if(animationSequence.precedenceAnimating == 1 && actor.anInt3094 > 0 && actor.forceMoveEndCycle <= MovedStatics.pulseCycle && MovedStatics.pulseCycle > actor.forceMoveStartCycle) {
105+
actor.playingAnimationDelay = 1;
106106
return;
107107
}
108108
}
109-
if(arg1.playingAnimation != -1 && arg1.playingAnimationDelay == 0) {
110-
AnimationSequence animationSequence = ProducingGraphicsBuffer_Sub1.getAnimationSequence(arg1.playingAnimation);
109+
if(actor.playingAnimation != -1 && actor.playingAnimationDelay == 0) {
110+
AnimationSequence animationSequence = ProducingGraphicsBuffer_Sub1.getAnimationSequence(actor.playingAnimation);
111111
if(animationSequence != null && animationSequence.frameIds != null) {
112-
arg1.anInt3115++;
113-
if(animationSequence.frameIds.length > arg1.anInt3104 && animationSequence.frameLengths[arg1.anInt3104] < arg1.anInt3115) {
114-
arg1.anInt3104++;
115-
arg1.anInt3115 = 1;
112+
actor.anInt3115++;
113+
if(animationSequence.frameIds.length > actor.anInt3104 && animationSequence.frameLengths[actor.anInt3104] < actor.anInt3115) {
114+
actor.anInt3104++;
115+
actor.anInt3115 = 1;
116116
}
117-
if(animationSequence.frameIds.length <= arg1.anInt3104) {
118-
arg1.anInt3104 -= animationSequence.frameStep;
119-
arg1.anInt3095++;
120-
if(animationSequence.maxLoops <= arg1.anInt3095)
121-
arg1.playingAnimation = -1;
122-
if(arg1.anInt3104 < 0 || arg1.anInt3104 >= animationSequence.frameIds.length)
123-
arg1.playingAnimation = -1;
117+
if(animationSequence.frameIds.length <= actor.anInt3104) {
118+
actor.anInt3104 -= animationSequence.frameStep;
119+
actor.anInt3095++;
120+
if(animationSequence.maxLoops <= actor.anInt3095)
121+
actor.playingAnimation = -1;
122+
if(actor.anInt3104 < 0 || actor.anInt3104 >= animationSequence.frameIds.length)
123+
actor.playingAnimation = -1;
124124
}
125-
arg1.aBoolean3105 = animationSequence.stretches;
125+
actor.aBoolean3105 = animationSequence.stretches;
126126
} else
127-
arg1.playingAnimation = -1;
127+
actor.playingAnimation = -1;
128128
}
129-
if(arg1.playingAnimationDelay > 0)
130-
arg1.playingAnimationDelay--;
129+
if(actor.playingAnimationDelay > 0)
130+
actor.playingAnimationDelay--;
131131
}
132132
}
133133

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

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,101 +18,101 @@ public class Class44 implements Runnable {
1818
public static int anInt1049 = 0;
1919

2020

21-
public static void method898(int arg0, Actor arg1) {
22-
arg1.anInt3077 = arg1.idleAnimation;
23-
if(arg1.anInt3109 == 0)
24-
arg1.anInt3074 = 0;
21+
public static void processWalkingStep(int arg0, Actor actor) {
22+
actor.anInt3077 = actor.idleAnimation;
23+
if(actor.anInt3109 == 0)
24+
actor.anInt3074 = 0;
2525
else {
26-
if(arg1.playingAnimation != -1 && arg1.playingAnimationDelay == 0) {
27-
AnimationSequence animationSequence = ProducingGraphicsBuffer_Sub1.getAnimationSequence(arg1.playingAnimation);
28-
if(arg1.anInt3094 > 0 && animationSequence.precedenceAnimating == 0) {
29-
arg1.anInt3074++;
26+
if(actor.playingAnimation != -1 && actor.playingAnimationDelay == 0) {
27+
AnimationSequence animationSequence = ProducingGraphicsBuffer_Sub1.getAnimationSequence(actor.playingAnimation);
28+
if(actor.anInt3094 > 0 && animationSequence.precedenceAnimating == 0) {
29+
actor.anInt3074++;
3030
return;
3131
}
32-
if(arg1.anInt3094 <= 0 && animationSequence.priority == 0) {
33-
arg1.anInt3074++;
32+
if(actor.anInt3094 <= 0 && animationSequence.priority == 0) {
33+
actor.anInt3074++;
3434
return;
3535
}
3636
}
37-
int i = arg1.worldX;
38-
int i_0_ = arg1.pathY[-1 + arg1.anInt3109] * 128 + 64 * arg1.anInt3096;
39-
int i_1_ = arg1.worldY;
40-
int i_2_ = 64 * arg1.anInt3096 + arg1.pathX[arg1.anInt3109 + -1] * 128;
37+
int i = actor.worldX;
38+
int i_0_ = actor.pathY[-1 + actor.anInt3109] * 128 + 64 * actor.size;
39+
int i_1_ = actor.worldY;
40+
int i_2_ = 64 * actor.size + actor.pathX[actor.anInt3109 + -1] * 128;
4141
if(-i + i_0_ > 256 || -i + i_0_ < -256 || -i_1_ + i_2_ > 256 || i_2_ + -i_1_ < -256) {
42-
arg1.worldX = i_0_;
43-
arg1.worldY = i_2_;
42+
actor.worldX = i_0_;
43+
actor.worldY = i_2_;
4444
} else {
4545
if(i < i_0_) {
4646
if(i_1_ < i_2_)
47-
arg1.initialFaceDirection = 1280;
47+
actor.initialFaceDirection = 1280;
4848
else if(i_2_ < i_1_)
49-
arg1.initialFaceDirection = 1792;
49+
actor.initialFaceDirection = 1792;
5050
else
51-
arg1.initialFaceDirection = 1536;
51+
actor.initialFaceDirection = 1536;
5252
} else if(i <= i_0_) {
5353
if(i_2_ <= i_1_) {
5454
if(i_2_ < i_1_)
55-
arg1.initialFaceDirection = 0;
55+
actor.initialFaceDirection = 0;
5656
} else
57-
arg1.initialFaceDirection = 1024;
57+
actor.initialFaceDirection = 1024;
5858
} else if(i_1_ < i_2_)
59-
arg1.initialFaceDirection = 768;
59+
actor.initialFaceDirection = 768;
6060
else if(i_2_ < i_1_)
61-
arg1.initialFaceDirection = 256;
61+
actor.initialFaceDirection = 256;
6262
else
63-
arg1.initialFaceDirection = 512;
64-
int i_3_ = arg1.turnAroundAnimationId;
63+
actor.initialFaceDirection = 512;
64+
int i_3_ = actor.turnAroundAnimationId;
6565
int i_4_ = 4;
66-
if(arg1.initialFaceDirection != arg1.anInt3118 && arg1.facingActorIndex == -1 && arg1.anInt3113 != 0)
66+
if(actor.initialFaceDirection != actor.anInt3118 && actor.facingActorIndex == -1 && actor.anInt3113 != 0)
6767
i_4_ = 2;
68-
if(arg1.anInt3109 > 2)
68+
if(actor.anInt3109 > 2)
6969
i_4_ = 6;
70-
if(arg1.anInt3109 > 3)
70+
if(actor.anInt3109 > 3)
7171
i_4_ = 8;
72-
int i_5_ = 0x7ff & -arg1.anInt3118 + arg1.initialFaceDirection;
72+
int i_5_ = 0x7ff & -actor.anInt3118 + actor.initialFaceDirection;
7373
if(i_5_ > 1024)
7474
i_5_ -= 2048;
7575
if((i_5_ ^ 0xffffffff) > arg0 || i_5_ > 256) {
7676
if(i_5_ < 256 || i_5_ >= 768) {
7777
if(i_5_ >= -768 && i_5_ <= -256)
78-
i_3_ = arg1.turnRightAnimationId;
78+
i_3_ = actor.turnRightAnimationId;
7979
} else
80-
i_3_ = arg1.turnLeftAnimationId;
80+
i_3_ = actor.turnLeftAnimationId;
8181
} else
82-
i_3_ = arg1.walkAnimationId;
82+
i_3_ = actor.walkAnimationId;
8383
if(i_3_ == -1)
84-
i_3_ = arg1.walkAnimationId;
85-
arg1.anInt3077 = i_3_;
86-
if(arg1.anInt3074 > 0 && arg1.anInt3109 > 1) {
87-
arg1.anInt3074--;
84+
i_3_ = actor.walkAnimationId;
85+
actor.anInt3077 = i_3_;
86+
if(actor.anInt3074 > 0 && actor.anInt3109 > 1) {
87+
actor.anInt3074--;
8888
i_4_ = 8;
8989
}
90-
if(arg1.aBooleanArray3072[-1 + arg1.anInt3109])
90+
if(actor.aBooleanArray3072[-1 + actor.anInt3109])
9191
i_4_ <<= 1;
9292
if(i_1_ < i_2_) {
93-
arg1.worldY += i_4_;
94-
if(arg1.worldY > i_2_)
95-
arg1.worldY = i_2_;
93+
actor.worldY += i_4_;
94+
if(actor.worldY > i_2_)
95+
actor.worldY = i_2_;
9696
} else if(i_1_ > i_2_) {
97-
arg1.worldY -= i_4_;
98-
if(arg1.worldY < i_2_)
99-
arg1.worldY = i_2_;
97+
actor.worldY -= i_4_;
98+
if(actor.worldY < i_2_)
99+
actor.worldY = i_2_;
100100
}
101-
if(i_4_ >= 8 && arg1.anInt3077 == arg1.walkAnimationId && arg1.runAnimationId != -1)
102-
arg1.anInt3077 = arg1.runAnimationId;
101+
if(i_4_ >= 8 && actor.anInt3077 == actor.walkAnimationId && actor.runAnimationId != -1)
102+
actor.anInt3077 = actor.runAnimationId;
103103
if(i < i_0_) {
104-
arg1.worldX += i_4_;
105-
if(i_0_ < arg1.worldX)
106-
arg1.worldX = i_0_;
104+
actor.worldX += i_4_;
105+
if(i_0_ < actor.worldX)
106+
actor.worldX = i_0_;
107107
} else if(i_0_ < i) {
108-
arg1.worldX -= i_4_;
109-
if(i_0_ > arg1.worldX)
110-
arg1.worldX = i_0_;
108+
actor.worldX -= i_4_;
109+
if(i_0_ > actor.worldX)
110+
actor.worldX = i_0_;
111111
}
112-
if(arg1.worldX == i_0_ && i_2_ == arg1.worldY) {
113-
if(arg1.anInt3094 > 0)
114-
arg1.anInt3094--;
115-
arg1.anInt3109--;
112+
if(actor.worldX == i_0_ && i_2_ == actor.worldY) {
113+
if(actor.anInt3094 > 0)
114+
actor.anInt3094--;
115+
actor.anInt3109--;
116116
}
117117
}
118118
}

0 commit comments

Comments
 (0)