Fix issues with OP_SpecialMesg handling

This should prevent any optimizations being done on the "1 char string"

This also fully documents the packet and expands the uses of
quest::say/QuestSay
This commit is contained in:
Michael Cook (mackal)
2019-07-18 00:56:46 -04:00
parent 16d6014a87
commit 9fe17f4d46
24 changed files with 343 additions and 291 deletions
+61 -2
View File
@@ -755,7 +755,65 @@ void Lua_Mob::Say(const char *message) {
void Lua_Mob::QuestSay(Lua_Client client, const char *message) {
Lua_Safe_Call_Void();
self->QuestJournalledSay(client, message);
Journal::Options journal_opts;
journal_opts.speak_mode = Journal::SpeakMode::Say;
journal_opts.journal_mode = RuleB(NPC, EnableNPCQuestJournal) ? Journal::Mode::Log2 : Journal::Mode::None;
journal_opts.language = 0;
journal_opts.message_type = MT_NPCQuestSay;
journal_opts.target_spawn_id = 0;
self->QuestJournalledSay(client, message, journal_opts);
}
void Lua_Mob::QuestSay(Lua_Client client, const char *message, luabind::adl::object opts) {
Lua_Safe_Call_Void();
Journal::Options journal_opts;
// defaults
journal_opts.speak_mode = Journal::SpeakMode::Say;
journal_opts.journal_mode = Journal::Mode::Log2;
journal_opts.language = 0;
journal_opts.message_type = MT_NPCQuestSay;
journal_opts.target_spawn_id = 0;
if (luabind::type(opts) == LUA_TTABLE) {
auto cur = opts["speak_mode"];
if (luabind::type(cur) != LUA_TNIL) {
try {
journal_opts.speak_mode = static_cast<Journal::SpeakMode>(luabind::object_cast<int>(cur));
} catch (luabind::cast_failed) {
}
}
cur = opts["journal_mode"];
if (luabind::type(cur) != LUA_TNIL) {
try {
journal_opts.journal_mode = static_cast<Journal::Mode>(luabind::object_cast<int>(cur));
} catch (luabind::cast_failed) {
}
}
cur = opts["language"];
if (luabind::type(cur) != LUA_TNIL) {
try {
journal_opts.language = luabind::object_cast<int>(cur);
} catch (luabind::cast_failed) {
}
}
cur = opts["message_type"];
if (luabind::type(cur) != LUA_TNIL) {
try {
journal_opts.message_type = luabind::object_cast<int>(cur);
} catch (luabind::cast_failed) {
}
}
}
// if rule disables it, we override provided
if (!RuleB(NPC, EnableNPCQuestJournal))
journal_opts.journal_mode = Journal::Mode::None;
self->QuestJournalledSay(client, message, journal_opts);
}
void Lua_Mob::Shout(const char *message) {
@@ -2320,7 +2378,8 @@ luabind::scope lua_register_mob() {
.def("Message", &Lua_Mob::Message)
.def("Message_StringID", &Lua_Mob::Message_StringID)
.def("Say", &Lua_Mob::Say)
.def("QuestSay", &Lua_Mob::QuestSay)
.def("QuestSay", (void(Lua_Mob::*)(Lua_Client,const char *))&Lua_Mob::QuestSay)
.def("QuestSay", (void(Lua_Mob::*)(Lua_Client,const char *,luabind::adl::object))&Lua_Mob::QuestSay)
.def("Shout", &Lua_Mob::Shout)
.def("Emote", &Lua_Mob::Emote)
.def("InterruptSpell", (void(Lua_Mob::*)(void))&Lua_Mob::InterruptSpell)