From ea131504e784065c06b48e58062623ec6dae874d Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Tue, 6 Apr 2021 23:45:47 -0500 Subject: [PATCH] Prevent additive text between different characters. --- include/area_data.h | 5 +++++ src/area_data.cpp | 3 ++- src/packets.cpp | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/area_data.h b/include/area_data.h index fca0248..abe05a2 100644 --- a/include/area_data.h +++ b/include/area_data.h @@ -272,6 +272,11 @@ class AreaData : public QObject { */ EvidenceMod evi_mod; QMap notecards; + + /** + * @brief The last IC packet sent in an area. + */ + QStringList last_ic_message; }; #endif // AREA_DATA_H diff --git a/src/area_data.cpp b/src/area_data.cpp index f30b36d..b129497 100644 --- a/src/area_data.cpp +++ b/src/area_data.cpp @@ -24,7 +24,8 @@ AreaData::AreaData(QString p_name, int p_index) : locked(FREE), document("No document."), def_hp(10), - pro_hp(10) + pro_hp(10), + last_ic_message() { QStringList name_split = p_name.split(":"); name_split.removeFirst(); diff --git a/src/packets.cpp b/src/packets.cpp index d0bbe57..94b501e 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -168,6 +168,8 @@ void AOClient::pktIcChat(AreaData* area, int argc, QStringList argv, AOPacket pa area->logger->logIC(this, &validated_packet); server->broadcast(validated_packet, current_area); + area->last_ic_message.clear(); + area->last_ic_message.append(validated_packet.contents); } void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket packet) @@ -601,6 +603,12 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) int additive = incoming_args[24].toInt(); if (additive != 0 && additive != 1) return invalid; + else if (area->last_ic_message.isEmpty()){ + additive = 0; + } + else if (!(char_id == area->last_ic_message[8].toInt())) { + additive = 0; + } else if (additive == 1) { args[4].insert(0, " "); }