From 4470bf34efc88614fb6359162da9ce932b1d8639 Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Fri, 16 Dec 2022 01:20:24 +0100 Subject: [PATCH 1/2] Remove empty packets --- core/src/network/network_socket.cpp | 1 + core/src/packet/packet_zz.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/network/network_socket.cpp b/core/src/network/network_socket.cpp index ceeddc6..fb828e4 100644 --- a/core/src/network/network_socket.cpp +++ b/core/src/network/network_socket.cpp @@ -127,6 +127,7 @@ void NetworkSocket::ws_readData(QString f_data) QStringList l_all_packets = l_data.split("%"); l_all_packets.removeLast(); // Remove the entry after the last delimiter + l_all_packets.removeAll({}); // Remove empty or null strings. if (l_all_packets.value(0).startsWith("MC", Qt::CaseInsensitive)) { l_all_packets = QStringList{l_all_packets.value(0)}; diff --git a/core/src/packet/packet_zz.cpp b/core/src/packet/packet_zz.cpp index c04b098..73017cd 100644 --- a/core/src/packet/packet_zz.cpp +++ b/core/src/packet/packet_zz.cpp @@ -29,7 +29,7 @@ void PacketZZ::handlePacket(AreaData *area, AOClient &client) const QString l_modcallNotice = "!!!MODCALL!!!\nArea: " + l_areaName + "\nCaller: " + l_name + "\n"; - if (!m_content[0].isEmpty()) + if (m_content.size() > 0 && !m_content[0].isEmpty()) l_modcallNotice.append("Reason: " + m_content[0]); else l_modcallNotice.append("No reason given."); From cf9d53d7b393919cd7999e7e924a865bd276ae66 Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Fri, 16 Dec 2022 01:23:27 +0100 Subject: [PATCH 2/2] Appease clang --- core/src/network/network_socket.cpp | 2 +- core/src/packet/packet_zz.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/network/network_socket.cpp b/core/src/network/network_socket.cpp index fb828e4..b20cce1 100644 --- a/core/src/network/network_socket.cpp +++ b/core/src/network/network_socket.cpp @@ -126,7 +126,7 @@ void NetworkSocket::ws_readData(QString f_data) } QStringList l_all_packets = l_data.split("%"); - l_all_packets.removeLast(); // Remove the entry after the last delimiter + l_all_packets.removeLast(); // Remove the entry after the last delimiter l_all_packets.removeAll({}); // Remove empty or null strings. if (l_all_packets.value(0).startsWith("MC", Qt::CaseInsensitive)) { diff --git a/core/src/packet/packet_zz.cpp b/core/src/packet/packet_zz.cpp index 73017cd..69a31c2 100644 --- a/core/src/packet/packet_zz.cpp +++ b/core/src/packet/packet_zz.cpp @@ -29,7 +29,7 @@ void PacketZZ::handlePacket(AreaData *area, AOClient &client) const QString l_modcallNotice = "!!!MODCALL!!!\nArea: " + l_areaName + "\nCaller: " + l_name + "\n"; - if (m_content.size() > 0 && !m_content[0].isEmpty()) + if (m_content.size() > 0 && !m_content[0].isEmpty()) l_modcallNotice.append("Reason: " + m_content[0]); else l_modcallNotice.append("No reason given.");