mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-01-31 12:52:36 +01:00
fixes
This commit is contained in:
parent
7030fcb9f2
commit
367f93ae86
@ -49,8 +49,8 @@ public class PacketStringUtils {
|
||||
packet = replaceAll(packet, "\\{u:([0-9]+)}",
|
||||
m -> "[" + (Integer.parseInt(m.group(1))/256) + "][" + (Integer.parseInt(m.group(1)) % 256) + "]");
|
||||
|
||||
packet = replaceAll(packet, "\\{h:([0-9]+)}",
|
||||
m -> "[" + (Integer.parseInt(m.group(1))/256) + "][" + (Integer.parseInt(m.group(1)) % 256) + "]");
|
||||
packet = replaceAll(packet, "\\{h:(-?[0-9]+)}",
|
||||
m -> toString(ByteBuffer.allocate(2).putShort(Short.parseShort(m.group(1))).array()));
|
||||
|
||||
packet = replaceAll(packet, "\\{b:([Ff]alse|[Tt]rue)}",
|
||||
m -> m.group(1).toLowerCase().equals("true") ? "[1]" : "[0]");
|
||||
@ -266,6 +266,9 @@ public class PacketStringUtils {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InvalidPacketException {
|
||||
HPacket fghdft = fromString("{l}{h:-1}{i:1}{i:0}{i:6}{i:4}{s:\"1.0\"}");
|
||||
System.out.println(fghdft);
|
||||
|
||||
HPacket zed = fromString("{test}{s:\"¥\"}{i:0}{i:0}");
|
||||
System.out.println(zed);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package gearth.ui.tools;
|
||||
|
||||
import gearth.misc.packet_info.PacketInfoManager;
|
||||
import gearth.protocol.HMessage;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextArea;
|
||||
@ -138,11 +140,26 @@ public class ToolsController extends SubForm {
|
||||
}
|
||||
|
||||
|
||||
private HPacket parseToPacket(String p) {
|
||||
PacketInfoManager packetInfoManager = getHConnection().getPacketInfoManager();
|
||||
HPacket packet = new HPacket(p);
|
||||
if (!packet.isPacketComplete() && packetInfoManager != null) {
|
||||
if (packet.canComplete(HMessage.Direction.TOCLIENT, packetInfoManager) && !packet.canComplete(HMessage.Direction.TOSERVER, packetInfoManager)) {
|
||||
packet.completePacket(HMessage.Direction.TOCLIENT, packetInfoManager);
|
||||
}
|
||||
else if (!packet.canComplete(HMessage.Direction.TOCLIENT, packetInfoManager) && packet.canComplete(HMessage.Direction.TOSERVER, packetInfoManager)) {
|
||||
packet.completePacket(HMessage.Direction.TOSERVER, packetInfoManager);
|
||||
}
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
public void btn_toExpr_clicked(ActionEvent actionEvent) {
|
||||
txt_exprArea.setText(new HPacket(txt_packetArea.getText()).toExpression(getHConnection().getPacketInfoManager(), true));
|
||||
txt_exprArea.setText(parseToPacket(txt_packetArea.getText()).toExpression(getHConnection().getPacketInfoManager(), true));
|
||||
}
|
||||
|
||||
public void btn_toPacket_clicked(ActionEvent actionEvent) {
|
||||
txt_packetArea.setText(new HPacket(txt_exprArea.getText()).toString());
|
||||
txt_packetArea.setText(parseToPacket(txt_exprArea.getText()).toString());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user