Get rid of Trinity Singleton and Threading patterns and replace them with ACE_Singletons and ACE_GUARD_x macro´s with ACE_Thread_Mutex´es respectively.
Also get rid of unused CountedReference class that used Trinity threading pattern. --HG-- branch : trunk
This commit is contained in:
@@ -19,16 +19,11 @@
|
||||
*/
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
#include "AddonHandler.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "SingletonImp.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
INSTANTIATE_SINGLETON_1( AddonHandler );
|
||||
|
||||
AddonHandler::AddonHandler()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -23,19 +23,20 @@
|
||||
|
||||
#include "Common.h"
|
||||
#include "ConfigEnv.h"
|
||||
#include "Singleton.h"
|
||||
|
||||
#include "ace/Singleton.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
class AddonHandler
|
||||
{
|
||||
/* Construction */
|
||||
friend class ACE_Singleton<AddonHandler, ACE_Null_Mutex>;
|
||||
AddonHandler();
|
||||
|
||||
public:
|
||||
/* Construction */
|
||||
AddonHandler();
|
||||
~AddonHandler();
|
||||
//built addon packet
|
||||
//build addon packet
|
||||
bool BuildAddonPacket(WorldPacket* Source, WorldPacket* Target);
|
||||
};
|
||||
#define sAddOnHandler Trinity::Singleton<AddonHandler>::Instance()
|
||||
#define sAddOnHandler ACE_Singleton<AddonHandler, ACE_Null_Mutex>::instance()
|
||||
#endif
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data)
|
||||
if (!normalizePlayerName(Invitedname))
|
||||
return;
|
||||
|
||||
player = ObjectAccessor::Instance().FindPlayerByName(Invitedname.c_str());
|
||||
player = sObjectAccessor.FindPlayerByName(Invitedname.c_str());
|
||||
}
|
||||
|
||||
if (!player)
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "SingletonImp.h"
|
||||
|
||||
#include "ObjectMgr.h" // for normalizePlayerName
|
||||
#include "ChannelMgr.h"
|
||||
|
||||
|
||||
@@ -719,7 +719,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
|
||||
pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation());
|
||||
}
|
||||
|
||||
ObjectAccessor::Instance().AddObject(pCurrChar);
|
||||
sObjectAccessor.AddObject(pCurrChar);
|
||||
//sLog.outDebug("Player %s added to Map.",pCurrChar->GetName());
|
||||
|
||||
pCurrChar->SendInitialPacketsAfterAddToMap();
|
||||
|
||||
@@ -75,7 +75,7 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket)
|
||||
recvPacket >> Invitedname;
|
||||
|
||||
if (normalizePlayerName(Invitedname))
|
||||
player = ObjectAccessor::Instance().FindPlayerByName(Invitedname.c_str());
|
||||
player = sObjectAccessor.FindPlayerByName(Invitedname.c_str());
|
||||
|
||||
if (!player)
|
||||
{
|
||||
|
||||
@@ -232,8 +232,8 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
|
||||
data << uint32(clientcount); // clientcount place holder, listed count
|
||||
data << uint32(clientcount); // clientcount place holder, online count
|
||||
|
||||
ObjectAccessor::Guard guard(*HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers();
|
||||
ACE_GUARD(ACE_Thread_Mutex, g, *HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (security == SEC_PLAYER)
|
||||
@@ -935,7 +935,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
|
||||
return;
|
||||
|
||||
// check if player can enter instance : instance not full, and raid instance not in encounter fight
|
||||
if (!MapManager::Instance().CanPlayerEnter(at->target_mapId, GetPlayer(), false))
|
||||
if (!sMapMgr.CanPlayerEnter(at->target_mapId, GetPlayer(), false))
|
||||
return;
|
||||
|
||||
GetPlayer()->TeleportTo(at->target_mapId,at->target_X,at->target_Y,at->target_Z,at->target_Orientation,TELE_TO_NOT_LEAVE_TRANSPORT);
|
||||
|
||||
@@ -75,7 +75,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
|
||||
}
|
||||
|
||||
// relocate the player to the teleport destination
|
||||
Map * newMap = MapManager::Instance().CreateMap(loc.GetMapId(), GetPlayer(), 0);
|
||||
Map * newMap = sMapMgr.CreateMap(loc.GetMapId(), GetPlayer(), 0);
|
||||
// the CanEnter checks are done in TeleporTo but conditions may change
|
||||
// while the player is in transit, for example the map may get full
|
||||
if (!newMap || !newMap->CanEnter(GetPlayer()))
|
||||
@@ -302,7 +302,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
|
||||
if (plMover && !plMover->GetTransport())
|
||||
{
|
||||
// elevators also cause the client to send MOVEMENTFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
|
||||
for (MapManager::TransportSet::const_iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
|
||||
for (MapManager::TransportSet::const_iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter)
|
||||
{
|
||||
if ((*iter)->GetGUID() == movementInfo.t_guid)
|
||||
{
|
||||
|
||||
@@ -302,7 +302,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/)
|
||||
if (corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0)
|
||||
{
|
||||
// if corpse map have entrance
|
||||
if (Map const* entranceMap = MapManager::Instance().CreateBaseMap(corpseMapEntry->entrance_map))
|
||||
if (Map const* entranceMap = sMapMgr.CreateBaseMap(corpseMapEntry->entrance_map))
|
||||
{
|
||||
mapid = corpseMapEntry->entrance_map;
|
||||
x = corpseMapEntry->entrance_x;
|
||||
|
||||
@@ -23,14 +23,9 @@
|
||||
*/
|
||||
|
||||
#include "WorldLog.h"
|
||||
#include "SingletonImp.h"
|
||||
#include "ConfigEnv.h"
|
||||
#include "Log.h"
|
||||
|
||||
#define CLASS_LOCK Trinity::ClassLevelLockable<WorldLog, ACE_Thread_Mutex>
|
||||
INSTANTIATE_SINGLETON_2(WorldLog, CLASS_LOCK);
|
||||
INSTANTIATE_CLASS_MUTEX(WorldLog, ACE_Thread_Mutex);
|
||||
|
||||
WorldLog::WorldLog() : i_file(NULL)
|
||||
{
|
||||
Initialize();
|
||||
@@ -67,7 +62,7 @@ void WorldLog::outTimestampLog(char const *fmt, ...)
|
||||
{
|
||||
if (LogWorld())
|
||||
{
|
||||
Guard guard(*this);
|
||||
ACE_GUARD(ACE_Thread_Mutex, Guard, Lock);
|
||||
ASSERT(i_file);
|
||||
|
||||
Log::outTimestamp(i_file);
|
||||
@@ -95,7 +90,7 @@ void WorldLog::outLog(char const *fmt, ...)
|
||||
{
|
||||
if (LogWorld())
|
||||
{
|
||||
Guard guard(*this);
|
||||
ACE_GUARD(ACE_Thread_Mutex, Guard, Lock);
|
||||
ASSERT(i_file);
|
||||
|
||||
va_list args;
|
||||
@@ -117,6 +112,3 @@ void WorldLog::outLog(char const *fmt, ...)
|
||||
va_end(ap2);
|
||||
}
|
||||
}
|
||||
|
||||
#define sWorldLog WorldLog::Instance()
|
||||
|
||||
|
||||
@@ -26,19 +26,19 @@
|
||||
#define TRINITY_WORLDLOG_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "Singleton.h"
|
||||
#include "ace/Singleton.h"
|
||||
#include "Errors.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/// %Log packets to a file
|
||||
class WorldLog : public Trinity::Singleton<WorldLog, Trinity::ClassLevelLockable<WorldLog, ACE_Thread_Mutex> >
|
||||
class WorldLog
|
||||
{
|
||||
friend class Trinity::OperatorNew<WorldLog>;
|
||||
friend class ACE_Singleton<WorldLog, ACE_Thread_Mutex>;
|
||||
WorldLog();
|
||||
WorldLog(const WorldLog &);
|
||||
WorldLog& operator=(const WorldLog &);
|
||||
typedef Trinity::ClassLevelLockable<WorldLog, ACE_Thread_Mutex>::Lock Guard;
|
||||
ACE_Thread_Mutex Lock;
|
||||
|
||||
/// Close the file in destructor
|
||||
~WorldLog();
|
||||
@@ -57,7 +57,7 @@ class WorldLog : public Trinity::Singleton<WorldLog, Trinity::ClassLevelLockable
|
||||
bool m_dbWorld;
|
||||
};
|
||||
|
||||
#define sWorldLog WorldLog::Instance()
|
||||
#define sWorldLog (*ACE_Singleton<WorldLog, ACE_Thread_Mutex>::instance())
|
||||
#endif
|
||||
/// @}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user