Merge pull request #61 from AttorneyOnline/additive-fix

Add a blank space infront of additive messages, and prevent additive text between different characters
This commit is contained in:
scatterflower 2021-04-07 00:24:29 -05:00 committed by GitHub
commit 80cecdaa0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -272,6 +272,11 @@ class AreaData : public QObject {
*/
EvidenceMod evi_mod;
QMap<QString, QString> notecards;
/**
* @brief The last IC packet sent in an area.
*/
QStringList last_ic_message;
};
#endif // AREA_DATA_H

View File

@ -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();

View File

@ -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,15 @@ 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, " ");
}
args.append(QString::number(additive));
// effect