diff --git a/src/game/Maps/Map.cpp b/src/game/Maps/Map.cpp index aca3c22401c..b13cfa0d083 100644 --- a/src/game/Maps/Map.cpp +++ b/src/game/Maps/Map.cpp @@ -392,6 +392,18 @@ bool Map::EnsureGridLoaded(Cell const& cell) return false; } +void Map::ForceLoadGridsAroundPosition(float x, float y) +{ + if (!IsLoaded(x, y)) + { + CellPair p = MaNGOS::ComputeCellPair(x, y); + Cell cell(p); + EnsureGridLoadedAtEnter(cell); + NULLNotifier notifier = NULLNotifier(); + Cell::VisitAllObjects(x, y, this, notifier, GetGridActivationDistance(), false); + } +} + void Map::LoadGrid(Cell const& cell, bool no_unload) { EnsureGridLoaded(cell); diff --git a/src/game/Maps/Map.h b/src/game/Maps/Map.h index 731618713e8..8b249793577 100644 --- a/src/game/Maps/Map.h +++ b/src/game/Maps/Map.h @@ -393,6 +393,7 @@ class Map : public GridRefManager bool GetUnloadLock(GridPair const& p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); } void SetUnloadLock(GridPair const& p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); } + void ForceLoadGridsAroundPosition(float x, float y); void LoadGrid(Cell const& cell, bool no_unload = false); bool UnloadGrid(uint32 const& x, uint32 const& y, bool pForce); virtual void UnloadAll(bool pForce); diff --git a/src/game/Maps/MapManager.cpp b/src/game/Maps/MapManager.cpp index 0695fc84754..836b5e80039 100644 --- a/src/game/Maps/MapManager.cpp +++ b/src/game/Maps/MapManager.cpp @@ -277,6 +277,7 @@ void MapManager::CreateNewInstancesForPlayers() DungeonMap* pMap = static_cast(CreateInstance(dest.mapId, player)); if (pMap->CanEnter(player)) { + pMap->ForceLoadGridsAroundPosition(dest.x, dest.y); pMap->BindPlayerOrGroupOnEnter(player); player->SendNewWorld(); } diff --git a/src/game/Objects/Object.cpp b/src/game/Objects/Object.cpp index a5d053b9fac..07920f3574c 100644 --- a/src/game/Objects/Object.cpp +++ b/src/game/Objects/Object.cpp @@ -3460,13 +3460,6 @@ void WorldObject::Update(uint32 update_diff, uint32 /*time_diff*/) ExecuteDelayedActions(); } -class NULLNotifier -{ -public: - template void Visit(GridRefManager& m) {} - void Visit(CameraMapType&) {} -}; - void WorldObject::LoadMapCellsAround(float dist) const { ASSERT(IsInWorld()); diff --git a/src/game/Objects/Object.h b/src/game/Objects/Object.h index 0a135fb708a..6653e6447f5 100644 --- a/src/game/Objects/Object.h +++ b/src/game/Objects/Object.h @@ -56,6 +56,13 @@ class GenericTransport; struct FactionEntry; struct FactionTemplateEntry; +class NULLNotifier +{ +public: + template void Visit(GridRefManager& m) {} + void Visit(CameraMapType&) {} +}; + typedef std::unordered_map UpdateDataMapType; //use this class to measure time between world update ticks