mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-17 09:25:06 +01:00
Debug system (#1894)
* Add build (compile) script: gradlew jar * Move server and services log levels to ConfigContainer, ability to enable/disable show packet payload and loop packets * Add some loop packets to known list
This commit is contained in:
@@ -99,7 +99,7 @@ public class GameServerPacketHandler {
|
||||
}
|
||||
|
||||
// Log unhandled packets
|
||||
if (GAME_INFO.logPackets == ServerDebugMode.MISSING) {
|
||||
if (GAME_INFO.logPackets == ServerDebugMode.MISSING || GAME_INFO.logPackets == ServerDebugMode.ALL) {
|
||||
Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + emu.grasscutter.net.packet.PacketOpcodesUtils.getOpcodeName(opcode));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,8 @@ public class GameSession implements GameSessionManager.KcpChannel {
|
||||
|
||||
public void logPacket(String sendOrRecv, int opcode, byte[] payload) {
|
||||
Grasscutter.getLogger().info(sendOrRecv + ": " + PacketOpcodesUtils.getOpcodeName(opcode) + " (" + opcode + ")");
|
||||
System.out.println(Utils.bytesToHex(payload));
|
||||
if (GAME_INFO.isShowPacketPayload)
|
||||
System.out.println(Utils.bytesToHex(payload));
|
||||
}
|
||||
|
||||
public void send(BasePacket packet) {
|
||||
@@ -122,7 +123,7 @@ public class GameSession implements GameSessionManager.KcpChannel {
|
||||
// Log
|
||||
switch (GAME_INFO.logPackets) {
|
||||
case ALL -> {
|
||||
if (!PacketOpcodesUtils.LOOP_PACKETS.contains(packet.getOpcode())) {
|
||||
if (!PacketOpcodesUtils.LOOP_PACKETS.contains(packet.getOpcode()) || GAME_INFO.isShowLoopPackets) {
|
||||
logPacket("SEND", packet.getOpcode(), packet.getData());
|
||||
}
|
||||
}
|
||||
@@ -154,7 +155,6 @@ public class GameSession implements GameSessionManager.KcpChannel {
|
||||
Grasscutter.getLogger().info(translate("messages.game.connect", this.getAddress().toString()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handleReceive(byte[] bytes) {
|
||||
// Decrypt and turn back into a packet
|
||||
@@ -200,7 +200,7 @@ public class GameSession implements GameSessionManager.KcpChannel {
|
||||
// Log packet
|
||||
switch (GAME_INFO.logPackets) {
|
||||
case ALL -> {
|
||||
if (!PacketOpcodesUtils.LOOP_PACKETS.contains(opcode)) {
|
||||
if (!PacketOpcodesUtils.LOOP_PACKETS.contains(opcode) || GAME_INFO.isShowLoopPackets) {
|
||||
logPacket("RECV", opcode, payload);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user