[Saylinks] Multiple saylinks in brackets (#1643)

* Saylink edge case where multiple saylinks show up within a bracket

* Update partial
This commit is contained in:
Chris Miles 2021-10-27 00:01:37 -05:00 committed by GitHub
parent fb66afd565
commit 6e5bf4b941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,7 @@
#include "item_instance.h"
#include "item_data.h"
#include "../zone/zonedb.h"
#include <algorithm>
bool EQ::saylink::DegenerateLinkBody(SayLinkBody_Struct &say_link_body_struct, const std::string &say_link_body)
{
@ -350,7 +350,7 @@ std::string EQ::SayLinkEngine::InjectSaylinksIfNotExist(const char *message)
std::vector<std::string> saylinks = {};
int saylink_length = 50;
std::string saylink_separator = "\u0012";
std::string saylink_partial = "000";
std::string saylink_partial = "00000";
LogSaylinkDetail("new_message pre pass 1 [{}]", new_message);
@ -375,6 +375,8 @@ std::string EQ::SayLinkEngine::InjectSaylinksIfNotExist(const char *message)
LogSaylinkDetail("new_message post pass 1 [{}]", new_message);
LogSaylinkDetail("saylink separator count [{}]", std::count(new_message.begin(), new_message.end(), '\u0012'));
// loop through brackets until none exist
if (new_message.find('[') != std::string::npos) {
for (auto &b: split_string(new_message, "[")) {
@ -388,6 +390,12 @@ std::string EQ::SayLinkEngine::InjectSaylinksIfNotExist(const char *message)
continue;
}
// skip where multiple saylinks are within brackets
if (bracket_message.find(saylink_separator) != std::string::npos &&
std::count(bracket_message.begin(), bracket_message.end(), '\u0012') > 1) {
continue;
}
// if non empty bracket contents
if (!bracket_message.empty()) {
LogSaylinkDetail("Found bracket_message [{}]", bracket_message);