Fix TC build, analysis warnings and triggering addon message hooks

This commit is contained in:
Rochet2
2015-01-06 12:43:53 +02:00
parent 6371728547
commit 5e7b0ee0f7
6 changed files with 28 additions and 28 deletions

View File

@@ -17,7 +17,7 @@ extern "C"
#include "lauxlib.h" #include "lauxlib.h"
}; };
class ElunaBind class ElunaBind : public ElunaUtil::RWLockable
{ {
public: public:
struct Binding struct Binding
@@ -61,7 +61,7 @@ public:
}; };
template<typename T> template<typename T>
class EventBind : public ElunaBind, public ElunaUtil::RWLockable class EventBind : public ElunaBind
{ {
public: public:
EventBind(const char* bindGroupName, Eluna& _E) : ElunaBind(bindGroupName, _E) EventBind(const char* bindGroupName, Eluna& _E) : ElunaBind(bindGroupName, _E)
@@ -141,7 +141,7 @@ public:
}; };
template<typename T> template<typename T>
class EntryBind : public ElunaBind, public ElunaUtil::RWLockable class EntryBind : public ElunaBind
{ {
public: public:
typedef UNORDERED_MAP<uint32, EventToFunctionsMap> EntryToEventsMap; typedef UNORDERED_MAP<uint32, EventToFunctionsMap> EntryToEventsMap;

View File

@@ -45,7 +45,7 @@ ElunaEventProcessor::ElunaEventProcessor(Eluna** _E, WorldObject* _obj) : m_time
{ {
if (obj) if (obj)
{ {
EventMgr::WriteGuard lock((*E)->eventMgr->GetLock()); EventMgr::WriteGuard guard((*E)->eventMgr->GetLock());
(*E)->eventMgr->processors.insert(this); (*E)->eventMgr->processors.insert(this);
} }
} }
@@ -56,7 +56,7 @@ ElunaEventProcessor::~ElunaEventProcessor()
if (obj && Eluna::initialized) if (obj && Eluna::initialized)
{ {
EventMgr::WriteGuard lock((*E)->eventMgr->GetLock()); EventMgr::WriteGuard guard((*E)->eventMgr->GetLock());
(*E)->eventMgr->processors.erase(this); (*E)->eventMgr->processors.erase(this);
} }
} }
@@ -133,7 +133,7 @@ EventMgr::EventMgr(Eluna** _E) : globalProcessor(new ElunaEventProcessor(_E, NUL
EventMgr::~EventMgr() EventMgr::~EventMgr()
{ {
{ {
ReadGuard lock(GetLock()); ReadGuard guard(GetLock());
if (!processors.empty()) if (!processors.empty())
for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors
(*it)->RemoveEvents_internal(); (*it)->RemoveEvents_internal();
@@ -145,7 +145,7 @@ EventMgr::~EventMgr()
void EventMgr::RemoveEvents() void EventMgr::RemoveEvents()
{ {
ReadGuard lock(GetLock()); ReadGuard guard(GetLock());
if (!processors.empty()) if (!processors.empty())
for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors
(*it)->RemoveEvents(); (*it)->RemoveEvents();
@@ -154,7 +154,7 @@ void EventMgr::RemoveEvents()
void EventMgr::RemoveEvent(int eventId) void EventMgr::RemoveEvent(int eventId)
{ {
ReadGuard lock(GetLock()); ReadGuard guard(GetLock());
if (!processors.empty()) if (!processors.empty())
for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors
(*it)->RemoveEvent(eventId); (*it)->RemoveEvent(eventId);

View File

@@ -119,9 +119,9 @@ namespace ElunaUtil
/* /*
* Usage: * Usage:
* Inherit this class, then when needing lock, use * Inherit this class, then when needing lock, use
* ReadGuard lock(_lock); * ReadGuard guard(GetLock());
* or * or
* WriteGuard lock(_lock); * WriteGuard guard(GetLock());
* *
* The lock is automatically released at end of scope * The lock is automatically released at end of scope
*/ */

View File

@@ -1190,12 +1190,12 @@ void Eluna::OnMapChanged(Player* player)
bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg) 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) if (lang == LANG_ADDON)
return OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, NULL); return OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, NULL);
if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_CHAT))
return true;
LOCK_ELUNA; LOCK_ELUNA;
bool result = true; bool result = true;
Push(pPlayer); 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) 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) if (lang == LANG_ADDON)
return OnAddonMessage(pPlayer, type, msg, NULL, NULL, pGroup, NULL); return OnAddonMessage(pPlayer, type, msg, NULL, NULL, pGroup, NULL);
if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_GROUP_CHAT))
return true;
LOCK_ELUNA; LOCK_ELUNA;
bool result = true; bool result = true;
Push(pPlayer); 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) 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) if (lang == LANG_ADDON)
return OnAddonMessage(pPlayer, type, msg, NULL, pGuild, NULL, NULL); return OnAddonMessage(pPlayer, type, msg, NULL, pGuild, NULL, NULL);
if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_GUILD_CHAT))
return true;
LOCK_ELUNA; LOCK_ELUNA;
bool result = true; bool result = true;
Push(pPlayer); 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) 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) if (lang == LANG_ADDON)
return OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, pChannel); return OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, pChannel);
if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_CHANNEL_CHAT))
return true;
LOCK_ELUNA; LOCK_ELUNA;
bool result = true; bool result = true;
Push(pPlayer); 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) 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) if (lang == LANG_ADDON)
return OnAddonMessage(pPlayer, type, msg, pReceiver, NULL, NULL, NULL); return OnAddonMessage(pPlayer, type, msg, pReceiver, NULL, NULL, NULL);
if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_WHISPER))
return true;
LOCK_ELUNA; LOCK_ELUNA;
bool result = true; bool result = true;
Push(pPlayer); Push(pPlayer);

View File

@@ -89,13 +89,13 @@ void Eluna::ReloadEluna()
EventMgr::ProcessorSet oldProcessors; EventMgr::ProcessorSet oldProcessors;
{ {
EventMgr::ReadGuard lock(sEluna->eventMgr->GetLock()); EventMgr::ReadGuard guard(sEluna->eventMgr->GetLock());
oldProcessors = sEluna->eventMgr->processors; oldProcessors = sEluna->eventMgr->processors;
} }
Uninitialize(); Uninitialize();
Initialize(); Initialize();
{ {
EventMgr::WriteGuard lock(sEluna->eventMgr->GetLock()); EventMgr::WriteGuard guard(sEluna->eventMgr->GetLock());
sEluna->eventMgr->processors.insert(oldProcessors.begin(), oldProcessors.end()); sEluna->eventMgr->processors.insert(oldProcessors.begin(), oldProcessors.end());
} }

View File

@@ -156,7 +156,7 @@ public:
#ifdef TRINITY #ifdef TRINITY
typedef std::recursive_mutex LockType; typedef std::recursive_mutex LockType;
typedef std::lock_guard<LockType> ElunaGuard; typedef std::lock_guard<LockType> Guard;
#else #else
typedef ACE_Recursive_Thread_Mutex LockType; typedef ACE_Recursive_Thread_Mutex LockType;
typedef ACE_Guard<LockType> Guard; typedef ACE_Guard<LockType> Guard;