Skip to content

Commit 586806e

Browse files
committed
refactor: rename chat countdown
1 parent 50fe6ca commit 586806e

File tree

5 files changed

+36
-32
lines changed

5 files changed

+36
-32
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ else if(x > 764)
13021302
} else {
13031303
MovedStatics.animatePlayers(-1);
13041304
MovedStatics.animateNpcs();
1305-
MovedStatics.method313();
1305+
Actor.tickChatTimers();
13061306
if(MovedStatics.crossType != 0) {
13071307
MovedStatics.crossIndex += 20;
13081308
if(MovedStatics.crossIndex >= 400)

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

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,31 +1504,7 @@ public static Point2d getScreenMidpoint() {
15041504
}
15051505
}
15061506

1507-
public static void method313() {
1508-
for(int i = -1; Player.localPlayerCount > i; i++) {
1509-
int i_6_;
1510-
if(i == -1)
1511-
i_6_ = 2047;
1512-
else
1513-
i_6_ = Player.trackedPlayerIndices[i];
1514-
Player class40_sub5_sub17_sub4_sub1 = Player.trackedPlayers[i_6_];
1515-
if(class40_sub5_sub17_sub4_sub1 != null && class40_sub5_sub17_sub4_sub1.anInt3078 > 0) {
1516-
class40_sub5_sub17_sub4_sub1.anInt3078--;
1517-
if(class40_sub5_sub17_sub4_sub1.anInt3078 == 0)
1518-
class40_sub5_sub17_sub4_sub1.forcedChatMessage = null;
1519-
}
1520-
}
1521-
for(int i_7_ = 0; i_7_ < Player.npcCount; i_7_++) {
1522-
int i_8_ = Player.npcIds[i_7_];
1523-
Npc class40_sub5_sub17_sub4_sub2 = Player.npcs[i_8_];
1524-
if(class40_sub5_sub17_sub4_sub2 != null && class40_sub5_sub17_sub4_sub2.anInt3078 > 0) {
1525-
class40_sub5_sub17_sub4_sub2.anInt3078--;
1526-
if(class40_sub5_sub17_sub4_sub2.anInt3078 == 0)
1527-
class40_sub5_sub17_sub4_sub2.forcedChatMessage = null;
1528-
}
1529-
}
1530-
}
1531-
public static int[] anIntArray1847 = new int[2000];
1507+
public static int[] anIntArray1847 = new int[2000];
15321508
public static long aLong1841;
15331509

15341510
private static int interpolateForPerlin(int arg0, int arg1, int arg2, boolean arg3, int arg4) {
@@ -2709,7 +2685,7 @@ else if(i < Player.localPlayerCount)
27092685
PlayerAppearance.anIntArray685[SceneCluster.anInt770] = screenPos.y;
27102686
PlayerAppearance.overheadChatColor[SceneCluster.anInt770] = actor.chatcolor;
27112687
PlayerAppearance.overheadChatShape[SceneCluster.anInt770] = actor.chatEffects;
2712-
PlayerAppearance.anIntArray684[SceneCluster.anInt770] = actor.anInt3078;
2688+
PlayerAppearance.anIntArray684[SceneCluster.anInt770] = actor.chatTimer;
27132689
PlayerAppearance.overheadChatMessage[SceneCluster.anInt770] = actor.forcedChatMessage;
27142690
SceneCluster.anInt770++;
27152691
}

src/main/java/org/runejs/client/media/renderable/actor/Actor.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public abstract class Actor extends Renderable {
1212
public int anInt3074;
1313
public int turnRightAnimationId;
1414
public int anInt3077;
15-
public int anInt3078;
15+
public int chatTimer;
1616
public int turnAroundAnimationId;
1717
public int initialFaceDirection;
1818
public int forceMoveStartY;
@@ -89,7 +89,7 @@ public Actor() {
8989
anInt3104 = 0;
9090
graphicId = -1;
9191
anInt3117 = 200;
92-
anInt3078 = 100;
92+
chatTimer = 100;
9393
anInt3120 = 0;
9494
playingAnimationDelay = 0;
9595
anInt3077 = -1;
@@ -354,6 +354,34 @@ public static void startForcedMovement(Actor actor) {
354354
actor.anInt3118 = actor.initialFaceDirection;
355355
}
356356

357+
/**
358+
* Decrease the time remaining for all actor chats.
359+
*/
360+
public static void tickChatTimers() {
361+
for(int i = -1; Player.localPlayerCount > i; i++) {
362+
int pid;
363+
if(i == -1)
364+
pid = 2047;
365+
else
366+
pid = Player.trackedPlayerIndices[i];
367+
Player player = Player.trackedPlayers[pid];
368+
if(player != null && player.chatTimer > 0) {
369+
player.chatTimer--;
370+
if(player.chatTimer == 0)
371+
player.forcedChatMessage = null;
372+
}
373+
}
374+
for(int i = 0; i < Player.npcCount; i++) {
375+
int nid = Player.npcIds[i];
376+
Npc npc = Player.npcs[nid];
377+
if(npc != null && npc.chatTimer > 0) {
378+
npc.chatTimer--;
379+
if(npc.chatTimer == 0)
380+
npc.forcedChatMessage = null;
381+
}
382+
}
383+
}
384+
357385
public void move(int moveDirection, boolean isRunning) {
358386
int i = pathY[0];
359387
int i_19_ = pathX[0];

src/main/java/org/runejs/client/media/renderable/actor/Npc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void parseNpcUpdateMasks(PacketBuffer buffer) {
5353
}
5454
if((0x40 & mask) != 0) {
5555
npc.forcedChatMessage = buffer.getString();
56-
npc.anInt3078 = 100;
56+
npc.chatTimer = 100;
5757
}
5858
if((mask & 0x80) != 0) {
5959
npc.actorDefinition = ActorDefinition.getDefinition(buffer.getUnsignedShortBE());

src/main/java/org/runejs/client/media/renderable/actor/Player.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public static void parsePlayerUpdateMasks(PacketBuffer appearanceBuffer, Player
155155
String incomming = MovedStatics.method956(appearanceBuffer);
156156
String class1 = RSString.formatChatString(incomming);
157157
player.forcedChatMessage = class1.trim();
158-
player.anInt3078 = 150;
158+
player.chatTimer = 150;
159159
player.chatEffects = chatEffectsAndColors & 0xff;
160160
player.chatcolor = chatEffectsAndColors >> 8;
161161
if(playerRights == 2 || playerRights == 3)
@@ -195,7 +195,7 @@ else if(playerRights == 1)
195195
ChatBox.addChatMessage(player.playerName, player.forcedChatMessage, 2);
196196
} else if(player == localPlayer)
197197
ChatBox.addChatMessage(player.playerName, player.forcedChatMessage, 2);
198-
player.anInt3078 = 150;
198+
player.chatTimer = 150;
199199
player.chatcolor = 0;
200200
player.chatEffects = 0;
201201
}

0 commit comments

Comments
 (0)