mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Merge pull request #8247 from ille/recursivedeadlock
Core/Maps: Use Thread-Safe Interface design pattern to allow recursive calls on non...
This commit is contained in:
@@ -144,7 +144,7 @@ void Map::LoadMap(int gx, int gy, bool reload)
|
||||
|
||||
// load grid map for base map
|
||||
if (!m_parentMap->GridMaps[gx][gy])
|
||||
m_parentMap->EnsureGridCreated(GridCoord(63-gx, 63-gy));
|
||||
m_parentMap->EnsureGridCreated_i(GridCoord(63-gx, 63-gy));
|
||||
|
||||
((MapInstanced*)(m_parentMap))->AddGridMapReference(GridCoord(gx, gy));
|
||||
GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy];
|
||||
@@ -307,32 +307,34 @@ void Map::DeleteFromWorld(Player* player)
|
||||
delete player;
|
||||
}
|
||||
|
||||
void Map::EnsureGridCreated(const GridCoord &p)
|
||||
{
|
||||
TRINITY_GUARD(ACE_Thread_Mutex, Lock);
|
||||
EnsureGridCreated_i(p);
|
||||
}
|
||||
|
||||
//Create NGrid so the object can be added to it
|
||||
//But object data is not loaded here
|
||||
void Map::EnsureGridCreated(const GridCoord &p)
|
||||
void Map::EnsureGridCreated_i(const GridCoord &p)
|
||||
{
|
||||
if (!getNGrid(p.x_coord, p.y_coord))
|
||||
{
|
||||
TRINITY_GUARD(ACE_Thread_Mutex, Lock);
|
||||
if (!getNGrid(p.x_coord, p.y_coord))
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "Creating grid[%u, %u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId);
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "Creating grid[%u, %u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId);
|
||||
|
||||
setNGrid(new NGridType(p.x_coord*MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld->getBoolConfig(CONFIG_GRID_UNLOAD)),
|
||||
p.x_coord, p.y_coord);
|
||||
setNGrid(new NGridType(p.x_coord*MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld->getBoolConfig(CONFIG_GRID_UNLOAD)),
|
||||
p.x_coord, p.y_coord);
|
||||
|
||||
// build a linkage between this map and NGridType
|
||||
buildNGridLinkage(getNGrid(p.x_coord, p.y_coord));
|
||||
// build a linkage between this map and NGridType
|
||||
buildNGridLinkage(getNGrid(p.x_coord, p.y_coord));
|
||||
|
||||
getNGrid(p.x_coord, p.y_coord)->SetGridState(GRID_STATE_IDLE);
|
||||
getNGrid(p.x_coord, p.y_coord)->SetGridState(GRID_STATE_IDLE);
|
||||
|
||||
//z coord
|
||||
int gx = (MAX_NUMBER_OF_GRIDS - 1) - p.x_coord;
|
||||
int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord;
|
||||
//z coord
|
||||
int gx = (MAX_NUMBER_OF_GRIDS - 1) - p.x_coord;
|
||||
int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord;
|
||||
|
||||
if (!GridMaps[gx][gy])
|
||||
LoadMapAndVMap(gx, gy);
|
||||
}
|
||||
if (!GridMaps[gx][gy])
|
||||
LoadMapAndVMap(gx, gy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -499,6 +499,7 @@ class Map : public GridRefManager<NGridType>
|
||||
|
||||
bool IsGridLoaded(const GridCoord &) const;
|
||||
void EnsureGridCreated(const GridCoord &);
|
||||
void EnsureGridCreated_i(const GridCoord &);
|
||||
bool EnsureGridLoaded(Cell const&);
|
||||
void EnsureGridLoadedForActiveObject(Cell const&, WorldObject* object);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user