Skip to content

Commit 50fe6ca

Browse files
committed
refactor: move cs2 static
1 parent f8c7efe commit 50fe6ca

File tree

3 files changed

+55
-55
lines changed

3 files changed

+55
-55
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.ObjectInputStream;
2929
import java.lang.reflect.Field;
3030
import java.lang.reflect.Method;
31+
import java.nio.charset.StandardCharsets;
3132
import java.util.Calendar;
3233
import java.util.Date;
3334

@@ -1154,4 +1155,55 @@ public static void method406(int arg0, int arg1, int arg2) {
11541155
OutgoingPackets.buffer.putShortBE(arg0);
11551156
}
11561157
}
1158+
1159+
public static String method532(GameInterface gameInterface, String arg2) {
1160+
if (arg2.contains(Native.percent)) {
1161+
for (; ; ) {
1162+
int i = arg2.indexOf(Native.percentOne);
1163+
if (i == -1)
1164+
break;
1165+
arg2 = arg2.substring(0, i) + method872(999999999, ClientScript.parseClientScripts(0, gameInterface)) + arg2.substring(2 + i);
1166+
}
1167+
for (; ; ) {
1168+
int i = arg2.indexOf(Native.percentTwo);
1169+
if (i == -1)
1170+
break;
1171+
arg2 = arg2.substring(0, i) + method872(999999999, ClientScript.parseClientScripts(1, gameInterface)) + arg2.substring(i + 2);
1172+
}
1173+
for (; ; ) {
1174+
int i = arg2.indexOf(Native.percentThree);
1175+
if (i == -1)
1176+
break;
1177+
arg2 = arg2.substring(0, i) + method872(999999999, ClientScript.parseClientScripts(2, gameInterface)) + arg2.substring(2 + i);
1178+
}
1179+
for (; ; ) {
1180+
int i = arg2.indexOf(Native.percentFour);
1181+
if (i == -1)
1182+
break;
1183+
arg2 = arg2.substring(0, i) + method872(999999999, ClientScript.parseClientScripts(3, gameInterface)) + arg2.substring(i + 2);
1184+
}
1185+
for (; ; ) {
1186+
int i = arg2.indexOf(Native.percentFive);
1187+
if (i == -1)
1188+
break;
1189+
arg2 = arg2.substring(0, i) + method872(999999999, ClientScript.parseClientScripts(4, gameInterface)) + arg2.substring(i + 2);
1190+
}
1191+
for (; ; ) {
1192+
// check client script results for value
1193+
int i = arg2.indexOf(Native.percentDns);
1194+
if (i == -1)
1195+
break;
1196+
String str = "";
1197+
if (MovedStatics.aSignlinkNode_394 != null) {
1198+
str = MovedStatics.method204(MovedStatics.aSignlinkNode_394.integerData);
1199+
if (MovedStatics.aSignlinkNode_394.value != null) {
1200+
byte[] is = ((String) MovedStatics.aSignlinkNode_394.value).getBytes(StandardCharsets.ISO_8859_1);
1201+
str = InteractiveObject.method279(is, 0, is.length).toString();
1202+
}
1203+
}
1204+
arg2 = arg2.substring(0, i) + str + arg2.substring(i + 4);
1205+
}
1206+
}
1207+
return arg2;
1208+
}
11571209
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public static boolean drawInterface(int areaId, int minX, int minY, int maxX, in
360360
textColor = 16777215;
361361
}
362362

363-
text = MovedStatics.method532(gameInterface, text);
363+
text = ClientScriptRunner.method532(gameInterface, text);
364364
font.drawText(text, absoluteX, absoluteY, gameInterface.originalWidth, gameInterface.originalHeight, textColor, gameInterface.textShadowed, gameInterface.xTextAlignment, gameInterface.yTextAlignment, gameInterface.lineHeight);
365365
}
366366
} else if (gameInterface.type == GameInterfaceType.GRAPHIC) {
@@ -546,7 +546,7 @@ else if (gameInterface.xTextAlignment == 1)
546546
int textHeight = 0;
547547
TypeFace class40_sub5_sub14_sub1 = MovedStatics.fontNormal;
548548
String text = gameInterface.disabledText;
549-
text = MovedStatics.method532(gameInterface, text);
549+
text = ClientScriptRunner.method532(gameInterface, text);
550550
while (text.length() > 0) {
551551
int lineBreakCharacter = text.indexOf(Native.lineBreak);
552552
String textLine;
@@ -578,7 +578,7 @@ else if (gameInterface.xTextAlignment == 1)
578578
Rasterizer.drawUnfilledRectangle(tooltipX, tooltipY, textWidth, textHeight, 0);
579579
text = gameInterface.disabledText;
580580
int tooltipTitleY = 2 + tooltipY + class40_sub5_sub14_sub1.characterDefaultHeight;
581-
text = MovedStatics.method532(gameInterface, text);
581+
text = ClientScriptRunner.method532(gameInterface, text);
582582
while (text.length() > 0) {
583583
int lineBreakCharacter = text.indexOf(Native.lineBreak);
584584
String textLine;

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

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

33
import org.runejs.client.cache.CacheIndex;
4-
import org.runejs.client.cache.cs.ClientScript;
54
import org.runejs.client.cache.media.ImageRGB;
65
import org.runejs.client.cache.media.gameInterface.GameInterface;
76
import org.runejs.client.cache.media.gameInterface.GameInterfaceArea;
@@ -2280,57 +2279,6 @@ public static void method940(String arg1, boolean arg2, String arg3) {
22802279
drawGameScreenGraphics();
22812280
}
22822281

2283-
public static String method532(GameInterface gameInterface, String arg2) {
2284-
if (arg2.contains(Native.percent)) {
2285-
for (; ; ) {
2286-
int i = arg2.indexOf(Native.percentOne);
2287-
if (i == -1)
2288-
break;
2289-
arg2 = arg2.substring(0, i) + ClientScriptRunner.method872(999999999, ClientScript.parseClientScripts(0, gameInterface)) + arg2.substring(2 + i);
2290-
}
2291-
for (; ; ) {
2292-
int i = arg2.indexOf(Native.percentTwo);
2293-
if (i == -1)
2294-
break;
2295-
arg2 = arg2.substring(0, i) + ClientScriptRunner.method872(999999999, ClientScript.parseClientScripts(1, gameInterface)) + arg2.substring(i + 2);
2296-
}
2297-
for (; ; ) {
2298-
int i = arg2.indexOf(Native.percentThree);
2299-
if (i == -1)
2300-
break;
2301-
arg2 = arg2.substring(0, i) + ClientScriptRunner.method872(999999999, ClientScript.parseClientScripts(2, gameInterface)) + arg2.substring(2 + i);
2302-
}
2303-
for (; ; ) {
2304-
int i = arg2.indexOf(Native.percentFour);
2305-
if (i == -1)
2306-
break;
2307-
arg2 = arg2.substring(0, i) + ClientScriptRunner.method872(999999999, ClientScript.parseClientScripts(3, gameInterface)) + arg2.substring(i + 2);
2308-
}
2309-
for (; ; ) {
2310-
int i = arg2.indexOf(Native.percentFive);
2311-
if (i == -1)
2312-
break;
2313-
arg2 = arg2.substring(0, i) + ClientScriptRunner.method872(999999999, ClientScript.parseClientScripts(4, gameInterface)) + arg2.substring(i + 2);
2314-
}
2315-
for (; ; ) {
2316-
// check client script results for value
2317-
int i = arg2.indexOf(Native.percentDns);
2318-
if (i == -1)
2319-
break;
2320-
String str = "";
2321-
if (aSignlinkNode_394 != null) {
2322-
str = method204(aSignlinkNode_394.integerData);
2323-
if (aSignlinkNode_394.value != null) {
2324-
byte[] is = ((String) aSignlinkNode_394.value).getBytes(StandardCharsets.ISO_8859_1);
2325-
str = InteractiveObject.method279(is, 0, is.length).toString();
2326-
}
2327-
}
2328-
arg2 = arg2.substring(0, i) + str + arg2.substring(i + 4);
2329-
}
2330-
}
2331-
return arg2;
2332-
}
2333-
23342282
public static String getCombatLevelColour(int arg0, int arg1) {
23352283
int diff = -arg1 + arg0;
23362284
if (diff < -9)

0 commit comments

Comments
 (0)