@@ -223,13 +223,19 @@ ObjectGridLoader::Visit(GameObjectMapType& m)
223223 uint32 y = (i_cell.GridY () * MAX_NUMBER_OF_CELLS) + i_cell.CellY ();
224224 CellPair cell_pair (x, y);
225225 uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord ;
226-
227- CellObjectGuids const & cell_guids = sObjectMgr .GetCellObjectGuids (i_map->GetId (), cell_id);
228-
229226 GridType& grid = (*i_map->getNGrid (i_cell.GridX (), i_cell.GridY ()))(i_cell.CellX (), i_cell.CellY ());
230- LoadHelper (cell_guids.gameobjects , cell_pair, m, i_gameObjects, i_map, grid);
231- std::shared_lock<std::shared_timed_mutex> lock (i_map->GetPersistentState ()->GetCellObjectGuidsMutex ());
232- LoadHelper (i_map->GetPersistentState ()->GetCellObjectGuids (cell_id).gameobjects , cell_pair, m, i_gameObjects, i_map, grid);
227+
228+ {
229+ std::shared_lock<std::shared_timed_mutex> lock (sObjectMgr .GetCellLoadingObjectsMutex ());
230+ if (auto const & cellGuids = sObjectMgr .GetCellObjectGuids (i_map->GetId (), cell_id))
231+ LoadHelper (cellGuids->gameobjects , cell_pair, m, i_gameObjects, i_map, grid);
232+ }
233+
234+ {
235+ std::shared_lock<std::shared_timed_mutex> lock (i_map->GetPersistentState ()->GetCellObjectGuidsMutex ());
236+ if (auto const & cellGuids = i_map->GetPersistentState ()->GetCellObjectGuids (cell_id))
237+ LoadHelper (cellGuids->gameobjects , cell_pair, m, i_gameObjects, i_map, grid);
238+ }
233239}
234240
235241void
@@ -239,13 +245,19 @@ ObjectGridLoader::Visit(CreatureMapType& m)
239245 uint32 y = (i_cell.GridY () * MAX_NUMBER_OF_CELLS) + i_cell.CellY ();
240246 CellPair cell_pair (x, y);
241247 uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord ;
242-
243- CellObjectGuids const & cell_guids = sObjectMgr .GetCellObjectGuids (i_map->GetId (), cell_id);
244-
245248 GridType& grid = (*i_map->getNGrid (i_cell.GridX (), i_cell.GridY ()))(i_cell.CellX (), i_cell.CellY ());
246- LoadHelper (cell_guids.creatures , cell_pair, m, i_creatures, i_map, grid);
247- std::shared_lock<std::shared_timed_mutex> lock (i_map->GetPersistentState ()->GetCellObjectGuidsMutex ());
248- LoadHelper (i_map->GetPersistentState ()->GetCellObjectGuids (cell_id).creatures , cell_pair, m, i_creatures, i_map, grid);
249+
250+ {
251+ std::shared_lock<std::shared_timed_mutex> lock (sObjectMgr .GetCellLoadingObjectsMutex ());
252+ if (auto const & cellGuids = sObjectMgr .GetCellObjectGuids (i_map->GetId (), cell_id))
253+ LoadHelper (cellGuids->creatures , cell_pair, m, i_creatures, i_map, grid);
254+ }
255+
256+ {
257+ std::shared_lock<std::shared_timed_mutex> lock (i_map->GetPersistentState ()->GetCellObjectGuidsMutex ());
258+ if (auto const & cellGuids = i_map->GetPersistentState ()->GetCellObjectGuids (cell_id))
259+ LoadHelper (cellGuids->creatures , cell_pair, m, i_creatures, i_map, grid);
260+ }
249261}
250262
251263void
@@ -255,10 +267,13 @@ ObjectWorldLoader::Visit(CorpseMapType& m)
255267 uint32 y = (i_cell.GridY () * MAX_NUMBER_OF_CELLS) + i_cell.CellY ();
256268 CellPair cell_pair (x, y);
257269 uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord ;
258-
259- CellObjectGuids const & cell_guids = sObjectMgr .GetCellObjectGuids (i_map->GetId (), cell_id);
260270 GridType& grid = (*i_map->getNGrid (i_cell.GridX (), i_cell.GridY ()))(i_cell.CellX (), i_cell.CellY ());
261- LoadHelper (cell_guids.corpses , cell_pair, m, i_corpses, i_map, grid);
271+
272+ {
273+ std::shared_lock<std::shared_timed_mutex> lock (sObjectMgr .GetCellLoadingObjectsMutex ());
274+ if (auto const & cellGuids = sObjectMgr .GetCellObjectGuids (i_map->GetId (), cell_id))
275+ LoadHelper (cellGuids->corpses , cell_pair, m, i_corpses, i_map, grid);
276+ }
262277}
263278
264279void
0 commit comments