Fix issues with random stuff not loading when logging in

This commit is contained in:
Melledy 2023-12-05 05:09:30 -08:00
parent 3eed08012c
commit 107c592522
3 changed files with 21 additions and 6 deletions

View File

@ -50,7 +50,7 @@ public class GameServerPacketHandler {
if (handler != null) {
// Check cooldown to prevent packet spam
long timestamp = System.currentTimeMillis();
if (session.getPacketCooldown().get(cmdId) >= timestamp) {
if (session.getPacketCooldown().get(cmdId) >= timestamp && !CmdIdUtils.ALLOWED_FILTER_PACKETS.contains(cmdId)) {
//LunarCore.getLogger().warn("Dropped a packet " + CmdIdUtils.getCmdIdName(cmdId));
return;
} else {

View File

@ -132,7 +132,7 @@ public class GameSession {
// Log packet
if (LunarCore.getConfig().getLogOptions().packets) {
if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.LOOP_PACKETS.contains(opcode))) {
if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.IGNORED_LOG_PACKETS.contains(opcode))) {
logPacket("RECV", opcode, data);
}
}
@ -159,8 +159,8 @@ public class GameSession {
// Log
if (LunarCore.getConfig().getLogOptions().packets) {
if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.LOOP_PACKETS.contains(packet.getCmdId()))) {
logPacket("RECV", packet.getCmdId(), packet.getData());
if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.IGNORED_LOG_PACKETS.contains(packet.getCmdId()))) {
logPacket("SEND", packet.getCmdId(), packet.getData());
}
}
}
@ -177,7 +177,7 @@ public class GameSession {
// Log
if (LunarCore.getConfig().getLogOptions().packets) {
if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.LOOP_PACKETS.contains(cmdId))) {
if (!(LunarCore.getConfig().getLogOptions().filterLoopingPackets && CmdIdUtils.IGNORED_LOG_PACKETS.contains(cmdId))) {
logPacket("SEND", cmdId, Utils.EMPTY_BYTE_ARRAY);
}
}

View File

@ -16,13 +16,28 @@ import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
public class CmdIdUtils {
public static final IntSet LOOP_PACKETS = IntOpenHashSet.of(
/**
* Packet ids that will NOT be logged if "filterLoopingPackets" is true in the config
*/
public static final IntSet IGNORED_LOG_PACKETS = IntOpenHashSet.of(
CmdId.PlayerHeartBeatCsReq,
CmdId.PlayerHeartBeatScRsp,
CmdId.SceneEntityMoveCsReq,
CmdId.SceneEntityMoveScRsp,
CmdId.GetQuestDataScRsp
);
/**
* Packet ids that will NOT be caught by the spam filter
*/
public static final IntSet ALLOWED_FILTER_PACKETS = IntOpenHashSet.of(
CmdId.PlayerGetTokenCsReq,
CmdId.PlayerLoginCsReq,
CmdId.PlayerHeartBeatCsReq,
CmdId.GetMissionStatusCsReq,
CmdId.GetMissionStatusCsReq,
CmdId.GetMissionEventDataCsReq
);
private static Int2ObjectMap<String> cmdIdMap;