mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-04 14:36:37 +00:00
[Saylinks] Implement Auto Saylink Injection (#1525)
* Implement auto saylink injection * Cover Lua say since it takes a different code path
This commit is contained in:
@@ -598,6 +598,8 @@ RULE_INT(Chat, IntervalDurationMS, 60000, "Interval length in milliseconds")
|
||||
RULE_INT(Chat, KarmaUpdateIntervalMS, 1200000, "Karma update interval in milliseconds")
|
||||
RULE_INT(Chat, KarmaGlobalChatLimit, 72, "Amount of karma you need to be able to talk in ooc/auction/chat below the level limit")
|
||||
RULE_INT(Chat, GlobalChatLevelLimit, 8, "Level limit you need to of reached to talk in ooc/auction/chat if your karma is too low")
|
||||
RULE_BOOL(Chat, AutoInjectSaylinksToSay, true, "Automatically injects saylinks into dialogue that has [brackets in them]")
|
||||
RULE_BOOL(Chat, AutoInjectSaylinksToClientMessage, true, "Automatically injects saylinks into dialogue that has [brackets in them]")
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(Merchant)
|
||||
|
||||
+47
-3
@@ -1,5 +1,5 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
|
||||
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -11,7 +11,7 @@
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@@ -339,4 +339,48 @@ std::string EQ::SayLinkEngine::GenerateQuestSaylink(std::string saylink_text, bo
|
||||
linker.SetProxyText(link_name.c_str());
|
||||
|
||||
return linker.GenerateLink();
|
||||
}
|
||||
}
|
||||
|
||||
std::string EQ::SayLinkEngine::InjectSaylinksIfNotExist(const char *message)
|
||||
{
|
||||
std::string new_message = message;
|
||||
|
||||
int link_index = 0;
|
||||
std::vector<std::string> links = {};
|
||||
|
||||
// loop through brackets until none exist
|
||||
while (new_message.find('[') != std::string::npos && new_message.find(']') != std::string::npos) {
|
||||
std::string bracket_message = get_between(new_message, "[", "]");
|
||||
|
||||
// already a saylink
|
||||
// todo: improve this later
|
||||
if (!bracket_message.empty() && bracket_message.length() > 50) {
|
||||
links.emplace_back(bracket_message);
|
||||
}
|
||||
else {
|
||||
links.emplace_back(EQ::SayLinkEngine::GenerateQuestSaylink(bracket_message, false, bracket_message));
|
||||
}
|
||||
|
||||
// replace with anchor
|
||||
find_replace(
|
||||
new_message,
|
||||
fmt::format("[{}]", bracket_message),
|
||||
fmt::format("<link:{}>", link_index)
|
||||
);
|
||||
|
||||
link_index++;
|
||||
}
|
||||
|
||||
// pop links onto anchors
|
||||
link_index = 0;
|
||||
for (auto &link: links) {
|
||||
find_replace(
|
||||
new_message,
|
||||
fmt::format("<link:{}>", link_index),
|
||||
fmt::format("[{}]", link)
|
||||
);
|
||||
link_index++;
|
||||
}
|
||||
|
||||
return new_message;
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,17 +1,17 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
|
||||
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@@ -105,6 +105,7 @@ namespace EQ
|
||||
|
||||
void Reset();
|
||||
|
||||
static std::string InjectSaylinksIfNotExist(const char *message);
|
||||
private:
|
||||
void generate_body();
|
||||
void generate_text();
|
||||
|
||||
Reference in New Issue
Block a user