From 655953ebfb7f18e18ddcc9875d263b3993be96ef Mon Sep 17 00:00:00 2001 From: 55Honey <71938210+55Honey@users.noreply.github.com> Date: Sat, 1 Oct 2022 08:45:49 +0200 Subject: [PATCH] feat: expose OnPlayerUpdateArea() (#65) --- src/ElunaLuaEngine_SC.cpp | 5 +++++ src/LuaEngine/Hooks.h | 1 + src/LuaEngine/LuaEngine.h | 1 + src/LuaEngine/PlayerHooks.cpp | 9 +++++++++ 4 files changed, 16 insertions(+) diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index c81cad8..224757f 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -722,6 +722,11 @@ public: sEluna->OnBindToInstance(player, difficulty, mapid, permanent); } + void OnUpdateArea(Player* player, uint32 oldArea, uint32 newArea) override + { + sEluna->OnUpdateArea(player, oldArea, newArea); + } + void OnUpdateZone(Player* player, uint32 newZone, uint32 newArea) override { sEluna->OnUpdateZone(player, newZone, newArea); diff --git a/src/LuaEngine/Hooks.h b/src/LuaEngine/Hooks.h index bc6b1d8..47d6031 100644 --- a/src/LuaEngine/Hooks.h +++ b/src/LuaEngine/Hooks.h @@ -208,6 +208,7 @@ namespace Hooks PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId) PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE = 45, // (event, player, achievement) PLAYER_EVENT_ON_FFAPVP_CHANGE = 46, // (event, player, hasFfaPvp) + PLAYER_EVENT_ON_UPDATE_AREA = 47, // (event, player, oldArea, newArea) PLAYER_EVENT_COUNT }; diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index 8feef69..0042593 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -469,6 +469,7 @@ public: void OnDelete(uint32 guid); void OnSave(Player* pPlayer); void OnBindToInstance(Player* pPlayer, Difficulty difficulty, uint32 mapid, bool permanent); + void OnUpdateArea(Player* pPlayer, uint32 oldArea, uint32 newArea); void OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea); void OnMapChanged(Player* pPlayer); void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, const std::string& code); diff --git a/src/LuaEngine/PlayerHooks.cpp b/src/LuaEngine/PlayerHooks.cpp index c1e85fb..f403caa 100644 --- a/src/LuaEngine/PlayerHooks.cpp +++ b/src/LuaEngine/PlayerHooks.cpp @@ -381,6 +381,15 @@ void Eluna::OnBindToInstance(Player* pPlayer, Difficulty difficulty, uint32 mapi CallAllFunctions(PlayerEventBindings, key); } +void Eluna::OnUpdateArea(Player* pPlayer, uint32 oldArea, uint32 newArea) +{ + START_HOOK(PLAYER_EVENT_ON_UPDATE_AREA); + Push(pPlayer); + Push(oldArea); + Push(newArea); + CallAllFunctions(PlayerEventBindings, key); +} + void Eluna::OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea) { START_HOOK(PLAYER_EVENT_ON_UPDATE_ZONE);