diff --git a/ElunaBinding.h b/ElunaBinding.h index 5d3c0f6..d65a94e 100644 --- a/ElunaBinding.h +++ b/ElunaBinding.h @@ -17,7 +17,7 @@ extern "C" #include "lauxlib.h" }; -class ElunaBind +class ElunaBind : public ElunaUtil::RWLockable { public: struct Binding @@ -61,7 +61,7 @@ public: }; template -class EventBind : public ElunaBind, public ElunaUtil::RWLockable +class EventBind : public ElunaBind { public: EventBind(const char* bindGroupName, Eluna& _E) : ElunaBind(bindGroupName, _E) @@ -141,7 +141,7 @@ public: }; template -class EntryBind : public ElunaBind, public ElunaUtil::RWLockable +class EntryBind : public ElunaBind { public: typedef UNORDERED_MAP EntryToEventsMap; diff --git a/ElunaEventMgr.cpp b/ElunaEventMgr.cpp index b640e2f..cc765c9 100644 --- a/ElunaEventMgr.cpp +++ b/ElunaEventMgr.cpp @@ -45,7 +45,7 @@ ElunaEventProcessor::ElunaEventProcessor(Eluna** _E, WorldObject* _obj) : m_time { if (obj) { - EventMgr::WriteGuard lock((*E)->eventMgr->GetLock()); + EventMgr::WriteGuard guard((*E)->eventMgr->GetLock()); (*E)->eventMgr->processors.insert(this); } } @@ -56,7 +56,7 @@ ElunaEventProcessor::~ElunaEventProcessor() if (obj && Eluna::initialized) { - EventMgr::WriteGuard lock((*E)->eventMgr->GetLock()); + EventMgr::WriteGuard guard((*E)->eventMgr->GetLock()); (*E)->eventMgr->processors.erase(this); } } @@ -133,7 +133,7 @@ EventMgr::EventMgr(Eluna** _E) : globalProcessor(new ElunaEventProcessor(_E, NUL EventMgr::~EventMgr() { { - ReadGuard lock(GetLock()); + ReadGuard guard(GetLock()); if (!processors.empty()) for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors (*it)->RemoveEvents_internal(); @@ -145,7 +145,7 @@ EventMgr::~EventMgr() void EventMgr::RemoveEvents() { - ReadGuard lock(GetLock()); + ReadGuard guard(GetLock()); if (!processors.empty()) for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors (*it)->RemoveEvents(); @@ -154,7 +154,7 @@ void EventMgr::RemoveEvents() void EventMgr::RemoveEvent(int eventId) { - ReadGuard lock(GetLock()); + ReadGuard guard(GetLock()); if (!processors.empty()) for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors (*it)->RemoveEvent(eventId); diff --git a/ElunaUtility.h b/ElunaUtility.h index b56ade6..1ca5b29 100644 --- a/ElunaUtility.h +++ b/ElunaUtility.h @@ -119,9 +119,9 @@ namespace ElunaUtil /* * Usage: * Inherit this class, then when needing lock, use - * ReadGuard lock(_lock); + * ReadGuard guard(GetLock()); * or - * WriteGuard lock(_lock); + * WriteGuard guard(GetLock()); * * The lock is automatically released at end of scope */ diff --git a/HookMgr.cpp b/HookMgr.cpp index 6084275..b6ce2f2 100644 --- a/HookMgr.cpp +++ b/HookMgr.cpp @@ -1190,12 +1190,12 @@ void Eluna::OnMapChanged(Player* player) bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg) { - if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_CHAT)) - return true; - if (lang == LANG_ADDON) return OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, NULL); + if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_CHAT)) + return true; + LOCK_ELUNA; bool result = true; Push(pPlayer); @@ -1223,12 +1223,12 @@ bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg) bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Group* pGroup) { - if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_GROUP_CHAT)) - return true; - if (lang == LANG_ADDON) return OnAddonMessage(pPlayer, type, msg, NULL, NULL, pGroup, NULL); + if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_GROUP_CHAT)) + return true; + LOCK_ELUNA; bool result = true; Push(pPlayer); @@ -1257,12 +1257,12 @@ bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Guild* pGuild) { - if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_GUILD_CHAT)) - return true; - if (lang == LANG_ADDON) return OnAddonMessage(pPlayer, type, msg, NULL, pGuild, NULL, NULL); + if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_GUILD_CHAT)) + return true; + LOCK_ELUNA; bool result = true; Push(pPlayer); @@ -1291,12 +1291,12 @@ bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Channel* pChannel) { - if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_CHANNEL_CHAT)) - return true; - if (lang == LANG_ADDON) return OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, pChannel); + if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_CHANNEL_CHAT)) + return true; + LOCK_ELUNA; bool result = true; Push(pPlayer); @@ -1325,12 +1325,12 @@ bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Player* pReceiver) { - if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_WHISPER)) - return true; - if (lang == LANG_ADDON) return OnAddonMessage(pPlayer, type, msg, pReceiver, NULL, NULL, NULL); + if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_WHISPER)) + return true; + LOCK_ELUNA; bool result = true; Push(pPlayer); diff --git a/LuaEngine.cpp b/LuaEngine.cpp index f1ec9c9..29a7f9b 100644 --- a/LuaEngine.cpp +++ b/LuaEngine.cpp @@ -89,13 +89,13 @@ void Eluna::ReloadEluna() EventMgr::ProcessorSet oldProcessors; { - EventMgr::ReadGuard lock(sEluna->eventMgr->GetLock()); + EventMgr::ReadGuard guard(sEluna->eventMgr->GetLock()); oldProcessors = sEluna->eventMgr->processors; } Uninitialize(); Initialize(); { - EventMgr::WriteGuard lock(sEluna->eventMgr->GetLock()); + EventMgr::WriteGuard guard(sEluna->eventMgr->GetLock()); sEluna->eventMgr->processors.insert(oldProcessors.begin(), oldProcessors.end()); } diff --git a/LuaEngine.h b/LuaEngine.h index 92d4716..2b3ef7f 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -156,7 +156,7 @@ public: #ifdef TRINITY typedef std::recursive_mutex LockType; - typedef std::lock_guard ElunaGuard; + typedef std::lock_guard Guard; #else typedef ACE_Recursive_Thread_Mutex LockType; typedef ACE_Guard Guard;