fix: restore gossip menu after lua script

Cherry pick from https://github.com/ElunaLuaEngine/Eluna/pull/405
Co-authored by https://github.com/Rochet2
This commit is contained in:
55Honey
2022-03-24 20:26:38 +01:00
parent 6fb5300b4e
commit b12768eb2f

View File

@@ -116,22 +116,32 @@ bool Eluna::OnGossipHello(Player* pPlayer, Creature* pCreature)
bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action)
{
START_HOOK_WITH_RETVAL(CreatureGossipBindings, GOSSIP_EVENT_ON_SELECT, pCreature->GetEntry(), false);
auto original_menu = *pPlayer->PlayerTalkClass;
pPlayer->PlayerTalkClass->ClearMenus();
Push(pPlayer);
Push(pCreature);
Push(sender);
Push(action);
return CallAllFunctionsBool(CreatureGossipBindings, key, true);
auto preventDefault = CallAllFunctionsBool(CreatureGossipBindings, key, true);
if (!preventDefault) {
*pPlayer->PlayerTalkClass = original_menu;
}
return preventDefault;
}
bool Eluna::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code)
{
START_HOOK_WITH_RETVAL(CreatureGossipBindings, GOSSIP_EVENT_ON_SELECT, pCreature->GetEntry(), false);
auto original_menu = *pPlayer->PlayerTalkClass;
pPlayer->PlayerTalkClass->ClearMenus();
Push(pPlayer);
Push(pCreature);
Push(sender);
Push(action);
Push(code);
return CallAllFunctionsBool(CreatureGossipBindings, key, true);
auto preventDefault = CallAllFunctionsBool(CreatureGossipBindings, key, true);
if (!preventDefault) {
*pPlayer->PlayerTalkClass = original_menu;
}
return preventDefault;
}