Skip to content

Commit 989b8a6

Browse files
committed
refactor: remove statics from HuffmanEncoding
1 parent e8309b5 commit 989b8a6

File tree

13 files changed

+194
-206
lines changed

13 files changed

+194
-206
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ else if(i < Player.localPlayerCount)
5050
if(screenPos != null)
5151
ProducingGraphicsBuffer_Sub1.headIconSprites[npcDefinition.headIcon].drawImage(-12 + screenPos.x, screenPos.y + -30);
5252
}
53-
if(Player.headIconDrawType == 1 && HuffmanEncoding.anInt1545 == Player.npcIds[-Player.localPlayerCount + i] && MovedStatics.pulseCycle % 20 < 10) {
53+
if(Player.headIconDrawType == 1 && MovedStatics.anInt1545 == Player.npcIds[-Player.localPlayerCount + i] && MovedStatics.pulseCycle % 20 < 10) {
5454
Point2d screenPos = MovedStatics.getProjectedScreenPosition(actor.anInt3117 + 15, actor.worldY, actor.worldX);
5555
if(screenPos != null)
5656
MovedStatics.hintIconSprites[0].drawImage(screenPos.x + -12, screenPos.y + -28);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ public static void startup() {
177177
if (Minimap.minimapCompass != null)
178178
i++;
179179
else
180-
Minimap.minimapCompass = HuffmanEncoding.method1028(CacheArchive.gameImageCacheArchive, Native.compass, "");
180+
Minimap.minimapCompass = MovedStatics.method1028(CacheArchive.gameImageCacheArchive, Native.compass, "");
181181
if (MovedStatics.minimapEdge == null)
182-
MovedStatics.minimapEdge = HuffmanEncoding.method1028(CacheArchive.gameImageCacheArchive, Native.mapEdge, "");
182+
MovedStatics.minimapEdge = MovedStatics.method1028(CacheArchive.gameImageCacheArchive, Native.mapEdge, "");
183183
else
184184
i++;
185185
if (MovedStatics.mapSceneIcons != null)
@@ -207,7 +207,7 @@ public static void startup() {
207207
else
208208
i++;
209209
if (LinkedList.aClass40_Sub5_Sub14_Sub4_1057 == null)
210-
LinkedList.aClass40_Sub5_Sub14_Sub4_1057 = HuffmanEncoding.method1028(CacheArchive.gameImageCacheArchive, Native.overlayMultiway, "");
210+
LinkedList.aClass40_Sub5_Sub14_Sub4_1057 = MovedStatics.method1028(CacheArchive.gameImageCacheArchive, Native.overlayMultiway, "");
211211
else
212212
i++;
213213
if (Minimap.minimapMarkers == null)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ public static void renderLoginScreen(Component arg0, CacheArchive huffmanCacheAr
594594
Rasterizer.drawFilledRectangle(0, 0, 42, 42, 0x4d4431);
595595
Rasterizer.drawUnfilledRectangle(0, 0, 42, 42, 0x242017);
596596
musicIcon.drawImage(4, 3);
597-
titleImg = HuffmanEncoding.method1028(gameImageCacheArchive, Native.logo, "");
597+
titleImg = MovedStatics.method1028(gameImageCacheArchive, Native.logo, "");
598598
Class39.aProducingGraphicsBuffer_907.prepareRasterizer();
599599
// UNCOMMENT LINE UNDER FOR LOGO
600600
// class40_sub5_sub14_sub4.drawImage(-128 + 382 + -(class40_sub5_sub14_sub4.imageWidth / 2), 18);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ public static void runClientScripts(Object[] listeners, int arg1, int arg2, Game
878878
} else if(scriptOpcode == 4102) {
879879
String class1 = scriptStringValues[--stringValueIndex];
880880
int i_77_ = scriptIntValues[--intValueIndex];
881-
scriptStringValues[stringValueIndex++] = class1 + HuffmanEncoding.method1024(true, i_77_);
881+
scriptStringValues[stringValueIndex++] = class1 + method1024(true, i_77_);
882882
} else if(scriptOpcode == 4103) {
883883
String class1 = scriptStringValues[--stringValueIndex];
884884
scriptStringValues[stringValueIndex++] = class1.toLowerCase();
@@ -1098,4 +1098,8 @@ private static Class stringToType(String typeCode) throws ClassNotFoundException
10981098
return Character.TYPE;
10991099
return Class.forName(typeCode);
11001100
}
1101+
1102+
private static RSString method1024(boolean arg0, int arg2) {
1103+
return PacketBuffer.method521(arg0, 10, arg2);
1104+
}
11011105
}

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

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

3-
import org.runejs.client.cache.CacheArchive;
4-
import org.runejs.client.cache.media.ImageRGB;
5-
import org.runejs.client.language.English;
6-
import org.runejs.client.language.Native;
7-
import org.runejs.client.media.renderable.actor.Player;
8-
import org.runejs.client.net.PacketBuffer;
9-
import org.runejs.client.scene.tile.SceneTile;
103
import org.runejs.client.util.BitUtils;
11-
import org.runejs.client.cache.def.ActorDefinition;
12-
import org.runejs.client.cache.def.ItemDefinition;
13-
import org.runejs.Configuration;
14-
15-
import java.text.MessageFormat;
164

175
public class HuffmanEncoding {
18-
public static ProducingGraphicsBuffer chatModes;
19-
public static int anInt1545 = 0;
20-
public static int reportAbuseInterfaceID = -1;
21-
public static int[] anIntArray1564 = new int[]{-1, -1, -1, -1, -1, -1, -1, -1, 85, 80, 84, -1, 91, -1, -1, -1, 81, 82, 86, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, 83, 104, 105, 103, 102, 96, 98, 97, 99, -1, -1, -1, -1, -1, -1, -1, 25, 16, 17, 18, 19, 20, 21, 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, 48, 68, 66, 50, 34, 51, 52, 53, 39, 54, 55, 56, 70, 69, 40, 41, 32, 35, 49, 36, 38, 67, 33, 65, 37, 64, -1, -1, -1, -1, -1, 228, 231, 227, 233, 224, 219, 225, 230, 226, 232, 89, 87, -1, 88, 229, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, 101, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
226

237
public int[] chatDecryptKeys;
248
public int[] chatMask;
@@ -93,133 +77,6 @@ public HuffmanEncoding(byte[] arg0) {
9377
}
9478

9579

96-
public static RSString method1024(boolean arg0, int arg2) {
97-
return PacketBuffer.method521(arg0, 10, arg2);
98-
}
99-
100-
public static void processNpcMenuOptions(ActorDefinition actorDefinition, int x, int y, int index) {
101-
if (ActorDefinition.menuActionRow < 400) {
102-
if (actorDefinition.childIds != null) {
103-
actorDefinition = actorDefinition.getChildDefinition();
104-
}
105-
if (actorDefinition != null && actorDefinition.isClickable) {
106-
String npcDisplayName = actorDefinition.name;
107-
if (actorDefinition.combatLevel != 0) {
108-
npcDisplayName = npcDisplayName + SceneTile.getCombatLevelColour(Player.localPlayer.combatLevel, actorDefinition.combatLevel) + Native.leftParenthesisWithSpacePrefix + English.prefixLevel + actorDefinition.combatLevel + Native.rightParenthesis;
109-
}
110-
if (MovedStatics.itemSelected == 1) {
111-
MovedStatics.addActionRow(English.use, index, x, y, ActionRowType.USE_ITEM_ON_NPC.getId(), Native.selectedItemName + Native.toYellow + npcDisplayName);
112-
} else if (Main.widgetSelected == 1) {
113-
if ((0x2 & ItemDefinition.selectedMask) == 2) {
114-
MovedStatics.addActionRow(Native.selectedSpellVerb, index, x, y, ActionRowType.CAST_MAGIC_ON_NPC.getId(), Native.selectedSpellName + Native.toYellow + npcDisplayName);
115-
}
116-
} else {
117-
String[] options = actorDefinition.options;
118-
if (Class60.DEBUG_DISPLAY_ALL_ACTION_ROWS) {
119-
options = MovedStatics.getAllOptionsWithIndices(options);
120-
}
121-
122-
// add non-attack options to NPC
123-
if (options != null) {
124-
for (int i = 4; i >= 0; i--) {
125-
if (options[i] != null && !options[i].equalsIgnoreCase(English.attack)) {
126-
int actionType = 0;
127-
if (i == 0) {
128-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_1.getId();
129-
}
130-
if (i == 1) {
131-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_2.getId();
132-
}
133-
if (i == 2) {
134-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_3.getId();
135-
}
136-
if (i == 3) {
137-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_4.getId();
138-
}
139-
if (i == 4) {
140-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_5.getId();
141-
}
142-
MovedStatics.addActionRow(options[i], index, x, y, actionType, Native.yellow + npcDisplayName);
143-
}
144-
}
145-
}
146-
147-
// add 'Attack' option to NPC
148-
if (options != null) {
149-
for (int i = 4; i >= 0; i--) {
150-
if (options[i] != null && options[i].equalsIgnoreCase(English.attack)) {
151-
int actionTypeOffset = 0;
152-
153-
// deprioritise the action in the list if the NPC is higher level than the player
154-
if (Player.localPlayer.combatLevel < actorDefinition.combatLevel) {
155-
actionTypeOffset = ActionRowType.LOW_PRIORITY_MODIFIER;
156-
}
157-
158-
int actionType = 0;
159-
if (i == 0) {
160-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_1.getId() + actionTypeOffset;
161-
}
162-
if (i == 1) {
163-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_2.getId() + actionTypeOffset;
164-
}
165-
if (i == 2) {
166-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_3.getId() + actionTypeOffset;
167-
}
168-
if (i == 3) {
169-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_4.getId() + actionTypeOffset;
170-
}
171-
if (i == 4) {
172-
actionType = ActionRowType.INTERACT_WITH_NPC_OPTION_5.getId() + actionTypeOffset;
173-
}
174-
MovedStatics.addActionRow(options[i], index, x, y, actionType, Native.yellow +npcDisplayName);
175-
}
176-
}
177-
}
178-
StringBuilder examineText = new StringBuilder();
179-
examineText.append(MessageFormat.format("<col=ffff00>{0}</col>", actorDefinition.name));
180-
181-
if(actorDefinition.combatLevel != 0) {
182-
String combatLevel = " " +
183-
SceneTile.getCombatLevelColour(Player.localPlayer.combatLevel, actorDefinition.combatLevel)
184-
+ Native.leftParenthesis + English.prefixLevel + actorDefinition.combatLevel + Native.rightParenthesis;
185-
examineText.append(combatLevel);
186-
}
187-
188-
189-
if (Configuration.DEBUG_CONTEXT) {
190-
examineText.append(" <col=00ff00>(</col>");
191-
examineText.append(
192-
MessageFormat.format("<col=ffffff>{0}</col>",
193-
Integer.toString(actorDefinition.id)
194-
)
195-
);
196-
examineText.append("<col=00ff00>) (</col>");
197-
examineText.append(
198-
MessageFormat.format("<col=ffffff>{0}, {1}</col>",
199-
Integer.toString(x + MovedStatics.baseX),
200-
Integer.toString(y + Class26.baseY)
201-
)
202-
);
203-
examineText.append("<col=00ff00>)</col>");
204-
205-
206-
}
207-
MovedStatics.addActionRow(English.examine, index, x, y, ActionRowType.EXAMINE_NPC.getId(), examineText.toString());
208-
}
209-
}
210-
}
211-
}
212-
213-
public static boolean method1027(int arg0) {
214-
return arg0 >= 48 && arg0 <= 57;
215-
}
216-
217-
public static ImageRGB method1028(CacheArchive arg0, String arg1, String arg3) {
218-
int i = arg0.getHash(arg1);
219-
int i_13_ = arg0.method179(i, arg3);
220-
return MovedStatics.method927(i_13_, arg0, i);
221-
}
222-
22380
public int method1023(byte[] arg0, int arg1, int arg2, byte[] arg3, int arg4, int arg5) {
22481
if (arg1 == 0) {
22582
return 0;

0 commit comments

Comments
 (0)