[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:
Chris Miles
2021-09-12 22:08:30 -05:00
committed by GitHub
parent 94c1a50cc8
commit 6b93130c13
8 changed files with 112 additions and 30 deletions
+5 -5
View File
@@ -1593,7 +1593,7 @@ XS(XS__addldonpoints) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: quest::addldonpoints(uint32 theme_id, int points)");
uint32 theme_id = (uint32) SvUV(ST(0));
int points = (int) SvIV(ST(1));
quest_manager.addldonpoints(theme_id, points);
@@ -6483,7 +6483,7 @@ XS(XS__gethexcolorcode) {
sv_setpv(TARG, hex_color_code.c_str());
XSprePUSH;
PUSHTARG;
XSRETURN(1);
XSRETURN(1);
}
XS(XS__getaaexpmodifierbycharid);
@@ -6491,7 +6491,7 @@ XS(XS__getaaexpmodifierbycharid) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: quest::getaaexpmodifierbycharid(uint32 character_id, uint32 zone_id)");
dXSTARG;
double aa_modifier;
uint32 character_id = (uint32) SvUV(ST(0));
@@ -6507,7 +6507,7 @@ XS(XS__getexpmodifierbycharid) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: quest::getexpmodifierbycharid(uint32 character_id, uint32 zone_id)");
dXSTARG;
double exp_modifier;
uint32 character_id = (uint32) SvUV(ST(0));
@@ -6870,7 +6870,7 @@ XS(XS__getspellstat) {
uint8 slot = 0;
if (items == 3)
slot = (uint8) SvUV(ST(2));
stat_value = quest_manager.getspellstat(spell_id, stat_identifier, slot);
XSprePUSH;
+13 -3
View File
@@ -4185,8 +4185,10 @@ bool Entity::CheckCoordLosNoZLeaps(float cur_x, float cur_y, float cur_z,
return false;
}
void EntityList::QuestJournalledSayClose(Mob *sender, float dist, const char *mobname, const char *message,
Journal::Options &opts)
void EntityList::QuestJournalledSayClose(
Mob *sender, float dist, const char *mobname, const char *message,
Journal::Options &opts
)
{
SerializeBuffer buf(sizeof(SpecialMesgHeader_Struct) + 12 + 64 + 64);
@@ -4199,7 +4201,15 @@ void EntityList::QuestJournalledSayClose(Mob *sender, float dist, const char *mo
buf.WriteInt32(0); // location, client doesn't seem to do anything with this
buf.WriteInt32(0);
buf.WriteInt32(0);
buf.WriteString(message);
// auto inject saylinks (say)
if (RuleB(Chat, AutoInjectSaylinksToSay)) {
std::string new_message = EQ::SayLinkEngine::InjectSaylinksIfNotExist(message);
buf.WriteString(new_message);
}
else {
buf.WriteString(message);
}
auto outapp = new EQApplicationPacket(OP_SpecialMesg, buf);
+10 -2
View File
@@ -755,7 +755,15 @@ double Lua_Mob::GetSize() {
void Lua_Mob::Message(int type, const char *message) {
Lua_Safe_Call_Void();
self->Message(type, message);
// auto inject saylinks
if (RuleB(Chat, AutoInjectSaylinksToClientMessage)) {
std::string new_message = EQ::SayLinkEngine::InjectSaylinksIfNotExist(message);
self->Message(type, new_message.c_str());
}
else {
self->Message(type, message);
}
}
void Lua_Mob::MessageString(int type, int string_id, uint32 distance) {
@@ -2747,7 +2755,7 @@ luabind::scope lua_register_mob() {
.def("GetNimbusEffect2", (uint8(Lua_Mob::*)(void))&Lua_Mob::GetNimbusEffect2)
.def("GetNimbusEffect3", (uint8(Lua_Mob::*)(void))&Lua_Mob::GetNimbusEffect3)
.def("IsTargetable", (bool(Lua_Mob::*)(void))&Lua_Mob::IsTargetable)
.def("HasShieldEquiped", (bool(Lua_Mob::*)(void))&Lua_Mob::HasShieldEquiped)
.def("HasShieldEquiped", (bool(Lua_Mob::*)(void))&Lua_Mob::HasShieldEquiped)
.def("HasTwoHandBluntEquiped", (bool(Lua_Mob::*)(void))&Lua_Mob::HasTwoHandBluntEquiped)
.def("HasTwoHanderEquipped", (bool(Lua_Mob::*)(void))&Lua_Mob::HasTwoHanderEquipped)
.def("GetHerosForgeModel", (int32(Lua_Mob::*)(uint8))&Lua_Mob::GetHerosForgeModel)
+13 -4
View File
@@ -2923,10 +2923,19 @@ void Mob::Say(const char *format, ...)
talker = this;
}
entity_list.MessageCloseString(
talker, false, 200, 10,
GENERIC_SAY, GetCleanName(), buf
);
if (RuleB(Chat, AutoInjectSaylinksToSay)) {
std::string new_message = EQ::SayLinkEngine::InjectSaylinksIfNotExist(buf);
entity_list.MessageCloseString(
talker, false, 200, 10,
GENERIC_SAY, GetCleanName(), new_message.c_str()
);
}
else {
entity_list.MessageCloseString(
talker, false, 200, 10,
GENERIC_SAY, GetCleanName(), buf
);
}
}
//
+18 -10
View File
@@ -989,7 +989,7 @@ XS(XS_Mob_BuffCount) {
VALIDATE_THIS_IS_MOB;
RETVAL = THIS->BuffCount();
XSprePUSH;
PUSHu((UV) RETVAL);
PUSHu((UV) RETVAL);
}
XSRETURN(1);
}
@@ -2620,7 +2620,15 @@ XS(XS_Mob_Message) {
uint32 type = (uint32) SvUV(ST(1));
char *message = (char *) SvPV_nolen(ST(2));
VALIDATE_THIS_IS_MOB;
THIS->Message(type, message);
// auto inject saylinks
if (RuleB(Chat, AutoInjectSaylinksToClientMessage)) {
std::string new_message = EQ::SayLinkEngine::InjectSaylinksIfNotExist(message);
THIS->Message(type, new_message.c_str());
}
else {
THIS->Message(type, message);
}
}
XSRETURN_EMPTY;
}
@@ -6016,7 +6024,7 @@ XS(XS_Mob_GetClassName) {
XSprePUSH;
PUSHTARG;
}
XSRETURN(1);
XSRETURN(1);
}
XS(XS_Mob_GetRaceName);
@@ -6039,7 +6047,7 @@ XS(XS_Mob_GetRaceName) {
XS(XS_Mob_DeleteBucket);
XS(XS_Mob_DeleteBucket) {
dXSARGS;
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Mob::DeleteBucket(THIS, std::string bucket_name)"); // @categories Script Utility
{
@@ -6053,7 +6061,7 @@ XS(XS_Mob_DeleteBucket) {
XS(XS_Mob_GetBucket);
XS(XS_Mob_GetBucket) {
dXSARGS;
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Mob::GetBucket(THIS, std::string bucket_name)"); // @categories Script Utility
{
@@ -6072,7 +6080,7 @@ XS(XS_Mob_GetBucket) {
XS(XS_Mob_GetBucketExpires);
XS(XS_Mob_GetBucketExpires) {
dXSARGS;
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Mob::GetBucketExpires(THIS, std::string bucket_name)"); // @categories Script Utility
{
@@ -6091,7 +6099,7 @@ XS(XS_Mob_GetBucketExpires) {
XS(XS_Mob_GetBucketKey);
XS(XS_Mob_GetBucketKey) {
dXSARGS;
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Mob::GetBucketKey(THIS)"); // @categories Script Utility
{
@@ -6109,7 +6117,7 @@ XS(XS_Mob_GetBucketKey) {
XS(XS_Mob_GetBucketRemaining);
XS(XS_Mob_GetBucketRemaining) {
dXSARGS;
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Mob::GetBucketRemaining(THIS, std::string bucket_name)"); // @categories Script Utility
{
@@ -6128,7 +6136,7 @@ XS(XS_Mob_GetBucketRemaining) {
XS(XS_Mob_SetBucket);
XS(XS_Mob_SetBucket) {
dXSARGS;
dXSARGS;
if (items < 3 || items > 4)
Perl_croak(aTHX_ "Usage: Mob::SetBucket(THIS, std::string bucket_name, std::string bucket_value, [std::string expiration])"); // @categories Script Utility
{
@@ -6146,7 +6154,7 @@ XS(XS_Mob_SetBucket) {
}
XS(XS_Mob_IsHorse);
XS(XS_Mob_IsHorse) {
XS(XS_Mob_IsHorse) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Mob::IsHorse(THIS)"); // @categories Script Utility