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:
@@ -325,7 +325,7 @@ void Map::DeleteFromWorld(T* obj)
|
||||
template<>
|
||||
void Map::DeleteFromWorld(Player* pl)
|
||||
{
|
||||
ObjectAccessor::Instance().RemoveObject(pl);
|
||||
sObjectAccessor.RemoveObject(pl);
|
||||
delete pl;
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ Map::EnsureGridCreated(const GridPair &p)
|
||||
{
|
||||
if (!getNGrid(p.x_coord, p.y_coord))
|
||||
{
|
||||
Guard guard(*this);
|
||||
ACE_GUARD(ACE_Thread_Mutex, Guard, Lock);
|
||||
if (!getNGrid(p.x_coord, p.y_coord))
|
||||
{
|
||||
sLog.outDebug("Creating grid[%u,%u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId);
|
||||
@@ -395,7 +395,7 @@ bool Map::EnsureGridLoaded(const Cell &cell)
|
||||
loader.LoadN();
|
||||
|
||||
// Add resurrectable corpses to world object list in grid
|
||||
ObjectAccessor::Instance().AddCorpsesToGrid(GridPair(cell.GridX(),cell.GridY()),(*grid)(cell.CellX(), cell.CellY()), this);
|
||||
sObjectAccessor.AddCorpsesToGrid(GridPair(cell.GridX(),cell.GridY()),(*grid)(cell.CellX(), cell.CellY()), this);
|
||||
|
||||
setGridObjectDataLoaded(true,cell.GridX(), cell.GridY());
|
||||
return true;
|
||||
@@ -828,7 +828,7 @@ bool Map::RemoveBones(uint64 guid, float x, float y)
|
||||
{
|
||||
if (IsRemovalGrid(x, y))
|
||||
{
|
||||
Corpse * corpse = ObjectAccessor::Instance().GetObjectInWorld(GetId(), x, y, guid, (Corpse*)NULL);
|
||||
Corpse * corpse = sObjectAccessor.GetObjectInWorld(GetId(), x, y, guid, (Corpse*)NULL);
|
||||
if (corpse && corpse->GetTypeId() == TYPEID_CORPSE && corpse->GetType() == CORPSE_BONES)
|
||||
corpse->DeleteBonesFromWorld();
|
||||
else
|
||||
@@ -2069,7 +2069,7 @@ void Map::SendInitSelf(Player * player)
|
||||
void Map::SendInitTransports(Player * player)
|
||||
{
|
||||
// Hack to send out transports
|
||||
MapManager::TransportMap& tmap = MapManager::Instance().m_TransportsByMap;
|
||||
MapManager::TransportMap& tmap = sMapMgr.m_TransportsByMap;
|
||||
|
||||
// no transports at map
|
||||
if (tmap.find(player->GetMapId()) == tmap.end())
|
||||
@@ -2096,7 +2096,7 @@ void Map::SendInitTransports(Player * player)
|
||||
void Map::SendRemoveTransports(Player * player)
|
||||
{
|
||||
// Hack to send out transports
|
||||
MapManager::TransportMap& tmap = MapManager::Instance().m_TransportsByMap;
|
||||
MapManager::TransportMap& tmap = sMapMgr.m_TransportsByMap;
|
||||
|
||||
// no transports at map
|
||||
if (tmap.find(player->GetMapId()) == tmap.end())
|
||||
@@ -2196,7 +2196,7 @@ void Map::RemoveAllObjectsInRemoveList()
|
||||
{
|
||||
case TYPEID_CORPSE:
|
||||
{
|
||||
Corpse* corpse = ObjectAccessor::Instance().GetCorpse(*obj, obj->GetGUID());
|
||||
Corpse* corpse = sObjectAccessor.GetCorpse(*obj, obj->GetGUID());
|
||||
if (!corpse)
|
||||
sLog.outError("Tried to delete corpse/bones %u that is not in map.", obj->GetGUIDLow());
|
||||
else
|
||||
@@ -2408,7 +2408,7 @@ bool InstanceMap::Add(Player *player)
|
||||
// Is it needed?
|
||||
|
||||
{
|
||||
Guard guard(*this);
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, Lock, false);
|
||||
// Check moved to void WorldSession::HandleMoveWorldportAckOpcode()
|
||||
//if (!CanEnter(player))
|
||||
//return false;
|
||||
@@ -2733,7 +2733,7 @@ bool BattleGroundMap::CanEnter(Player * player)
|
||||
bool BattleGroundMap::Add(Player * player)
|
||||
{
|
||||
{
|
||||
Guard guard(*this);
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, Lock, false);
|
||||
//Check moved to void WorldSession::HandleMoveWorldportAckOpcode()
|
||||
//if (!CanEnter(player))
|
||||
//return false;
|
||||
@@ -2877,7 +2877,7 @@ void Map::ScriptsProcess()
|
||||
source = HashMapHolder<Corpse>::Find(step.sourceGUID);
|
||||
break;
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
|
||||
for (MapManager::TransportSet::iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter)
|
||||
{
|
||||
if ((*iter)->GetGUID() == step.sourceGUID)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define TRINITY_MAP_H
|
||||
|
||||
#include "Define.h"
|
||||
#include "ThreadingModel.h"
|
||||
#include "ace/RW_Thread_Mutex.h"
|
||||
#include "ace/Thread_Mutex.h"
|
||||
|
||||
@@ -239,7 +238,7 @@ typedef UNORDERED_MAP<Creature*, CreatureMover> CreatureMoveList;
|
||||
|
||||
typedef std::map<uint32/*leaderDBGUID*/, CreatureGroup*> CreatureGroupHolderType;
|
||||
|
||||
class Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockable<Map, ACE_Thread_Mutex>
|
||||
class Map : public GridRefManager<NGridType>
|
||||
{
|
||||
friend class MapReference;
|
||||
public:
|
||||
@@ -490,7 +489,7 @@ class Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockabl
|
||||
protected:
|
||||
void SetUnloadReferenceLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); }
|
||||
|
||||
typedef Trinity::ObjectLevelLockable<Map, ACE_Thread_Mutex>::Lock Guard;
|
||||
ACE_Thread_Mutex Lock;
|
||||
|
||||
MapEntry const* i_mapEntry;
|
||||
uint8 i_spawnMode;
|
||||
|
||||
@@ -170,7 +170,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player * player)
|
||||
{
|
||||
// if no instanceId via group members or instance saves is found
|
||||
// the instance will be created for the first time
|
||||
NewInstanceId = MapManager::Instance().GenerateInstanceId();
|
||||
NewInstanceId = sMapMgr.GenerateInstanceId();
|
||||
|
||||
Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid());
|
||||
map = CreateInstance(NewInstanceId, NULL, diff);
|
||||
@@ -183,7 +183,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player * player)
|
||||
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave *save, Difficulty difficulty)
|
||||
{
|
||||
// load/create a map
|
||||
Guard guard(*this);
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
|
||||
|
||||
// make sure we have a valid map id
|
||||
const MapEntry* entry = sMapStore.LookupEntry(GetId());
|
||||
@@ -219,7 +219,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave *save,
|
||||
BattleGroundMap* MapInstanced::CreateBattleGround(uint32 InstanceId, BattleGround* bg)
|
||||
{
|
||||
// load/create a map
|
||||
Guard guard(*this);
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
|
||||
|
||||
sLog.outDebug("MapInstanced::CreateBattleGround: map bg %d for %d created.", InstanceId, GetId());
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "MapManager.h"
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "SingletonImp.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
@@ -37,10 +36,6 @@
|
||||
#include "Language.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
#define CLASS_LOCK Trinity::ClassLevelLockable<MapManager, ACE_Thread_Mutex>
|
||||
INSTANTIATE_SINGLETON_2(MapManager, CLASS_LOCK);
|
||||
INSTANTIATE_CLASS_MUTEX(MapManager, ACE_Thread_Mutex);
|
||||
|
||||
extern GridState* si_GridStates[]; // debugging code, should be deleted some day
|
||||
|
||||
MapManager::MapManager()
|
||||
@@ -116,7 +111,7 @@ Map* MapManager::_createBaseMap(uint32 id)
|
||||
|
||||
if (m == NULL)
|
||||
{
|
||||
Guard guard(*this);
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
|
||||
|
||||
const MapEntry* entry = sMapStore.LookupEntry(id);
|
||||
if (entry && entry->Instanceable())
|
||||
@@ -236,7 +231,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
InstanceGroupBind* boundedInstance = pGroup->GetBoundInstance(player);
|
||||
if (boundedInstance && boundedInstance->save)
|
||||
{
|
||||
if (Map *boundedMap = MapManager::Instance().FindMap(mapid,boundedInstance->save->GetInstanceId()))
|
||||
if (Map *boundedMap = sMapMgr.FindMap(mapid,boundedInstance->save->GetInstanceId()))
|
||||
{
|
||||
// Player permanently bounded to different instance than groups one
|
||||
InstancePlayerBind* playerBoundedInstance = player->GetBoundInstance(mapid, player->GetDungeonDifficulty());
|
||||
@@ -307,7 +302,7 @@ void MapManager::Update(uint32 diff)
|
||||
for (iter = i_maps.begin(); iter != i_maps.end(); ++iter)
|
||||
iter->second->DelayedUpdate(i_timer.GetCurrent());
|
||||
|
||||
ObjectAccessor::Instance().Update(i_timer.GetCurrent());
|
||||
sObjectAccessor.Update(i_timer.GetCurrent());
|
||||
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
|
||||
(*iter)->Update(i_timer.GetCurrent());
|
||||
|
||||
@@ -361,7 +356,7 @@ void MapManager::InitMaxInstanceId()
|
||||
|
||||
uint32 MapManager::GetNumInstances()
|
||||
{
|
||||
Guard guard(*this);
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
|
||||
|
||||
uint32 ret = 0;
|
||||
for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
|
||||
@@ -378,7 +373,7 @@ uint32 MapManager::GetNumInstances()
|
||||
|
||||
uint32 MapManager::GetNumPlayersInInstances()
|
||||
{
|
||||
Guard guard(*this);
|
||||
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
|
||||
|
||||
uint32 ret = 0;
|
||||
for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define TRINITY_MAPMANAGER_H
|
||||
|
||||
#include "Define.h"
|
||||
#include "Singleton.h"
|
||||
#include "ace/Singleton.h"
|
||||
#include "ace/Thread_Mutex.h"
|
||||
#include "Common.h"
|
||||
#include "Map.h"
|
||||
@@ -31,10 +31,9 @@
|
||||
|
||||
class Transport;
|
||||
|
||||
class MapManager : public Trinity::Singleton<MapManager, Trinity::ClassLevelLockable<MapManager, ACE_Thread_Mutex> >
|
||||
class MapManager
|
||||
{
|
||||
|
||||
friend class Trinity::OperatorNew<MapManager>;
|
||||
friend class ACE_Singleton<MapManager, ACE_Thread_Mutex>;
|
||||
typedef UNORDERED_MAP<uint32, Map*> MapMapType;
|
||||
typedef std::pair<UNORDERED_MAP<uint32, Map*>::iterator, bool> MapMapPair;
|
||||
|
||||
@@ -162,7 +161,7 @@ class MapManager : public Trinity::Singleton<MapManager, Trinity::ClassLevelLock
|
||||
return (iter == i_maps.end() ? NULL : iter->second);
|
||||
}
|
||||
|
||||
typedef Trinity::ClassLevelLockable<MapManager, ACE_Thread_Mutex>::Lock Guard;
|
||||
ACE_Thread_Mutex Lock;
|
||||
uint32 i_gridCleanUpDelay;
|
||||
MapMapType i_maps;
|
||||
IntervalTimer i_timer;
|
||||
@@ -170,4 +169,5 @@ class MapManager : public Trinity::Singleton<MapManager, Trinity::ClassLevelLock
|
||||
uint32 i_MaxInstanceId;
|
||||
MapUpdater m_updater;
|
||||
};
|
||||
#define sMapMgr (*ACE_Singleton<MapManager, ACE_Thread_Mutex>::instance())
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user