package tools.mapletools; import provider.wz.WZFiles; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.time.Duration; import java.time.Instant; /** * @author RonanLana *
* This application parses the Character.wz folder inputted and adds/updates the "info/level" * node on every known equipment id. This addition enables client-side view of the equipment * level attribute on every equipment in the game, given proper item visibility, be it from * own equipments or from other players. *
* Estimated parse time: 10 seconds
*/
public class DojoUpdate {
private static final Path INPUT_DIRECTORY = WZFiles.MAP.getFile().resolve("Map").resolve("Map9");
private static final Path OUTPUT_DIRECTORY = ToolConstants.getOutputFile("dojo-maps");
private static final Path WORKING_DIRECTORY = Path.of("").toAbsolutePath();
private static final int DOJO_MIN_MAP_ID = 925_020_100;
private static final int DOJO_MAX_MAP_ID = 925_033_804;
private static final int INITIAL_STRING_LENGTH = 250;
private static PrintWriter printWriter = null;
private static BufferedReader bufferedReader = null;
private static boolean isDojoMapid;
private static byte status;
private static String getName(String token) {
int i, j;
char[] dest;
String d;
i = token.lastIndexOf("name");
i = token.indexOf("\"", i) + 1; //lower bound of the string
j = token.indexOf("\"", i); //upper bound
dest = new char[INITIAL_STRING_LENGTH];
try {
token.getChars(i, j, dest, 0);
} catch (StringIndexOutOfBoundsException e) {
// do nothing
return "";
} catch (Exception e) {
System.out.println("error in: " + token + "");
e.printStackTrace();
try {
Thread.sleep(100000000);
} catch (Exception ex) {
}
}
d = new String(dest);
return (d.trim());
}
private static void forwardCursor(int st) {
String line = null;
try {
while (status >= st && (line = bufferedReader.readLine()) != null) {
simpleToken(line);
printWriter.println(line);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static void simpleToken(String token) {
if (token.contains("/imgdir")) {
status -= 1;
} else if (token.contains("imgdir")) {
status += 1;
}
}
private static void translateToken(String token) {
if (token.contains("/imgdir")) {
status -= 1;
printWriter.println(token);
} else if (token.contains("imgdir")) {
printWriter.println(token);
status += 1;
if (status == 2) {
String d = getName(token);
if (!d.contentEquals("info")) {
forwardCursor(status);
}
} else if (status > 2) {
forwardCursor(status);
}
} else {
if (status == 2 && isDojoMapid) {
String item = getName(token);
if (item.contentEquals("onFirstUserEnter")) {
printWriter.println("