aboutsummaryrefslogtreecommitdiff
path: root/src/game/Map.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Map.h')
-rw-r--r--src/game/Map.h60
1 files changed, 49 insertions, 11 deletions
diff --git a/src/game/Map.h b/src/game/Map.h
index 2b6fcfe6900..731b5a76fcc 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -166,11 +166,11 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
return( !getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL );
}
- bool GetUnloadFlag(const GridPair &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadFlag(); }
- void SetUnloadFlag(const GridPair &p, bool unload) { getNGrid(p.x_coord, p.y_coord)->setUnloadFlag(unload); }
+ bool GetUnloadLock(const GridPair &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); }
+ void SetUnloadLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); }
void LoadGrid(float x, float y);
bool UnloadGrid(const uint32 &x, const uint32 &y, bool pForce);
- virtual void UnloadAll(bool pForce);
+ virtual void UnloadAll();
void ResetGridExpiry(NGridType &grid, float factor = 1) const
{
@@ -245,6 +245,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
}
void AddObjectToRemoveList(WorldObject *obj);
+ void AddObjectToSwitchList(WorldObject *obj, bool on);
void DoDelayedMovesAndRemoves();
virtual bool RemoveBones(uint64 guid, float x, float y);
@@ -259,11 +260,8 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
bool HavePlayers() const { return !m_mapRefManager.isEmpty(); }
uint32 GetPlayersCountExceptGMs() const;
- bool PlayersNearGrid(uint32 x,uint32 y) const;
bool ActiveObjectsNearGrid(uint32 x, uint32 y) const;
- void AddActiveObject(WorldObject* obj) { i_activeObjects.insert(obj); }
- void RemoveActiveObject(WorldObject* obj) { i_activeObjects.erase(obj); }
void AddUnitToNotify(Unit* unit);
void RelocationNotify();
@@ -271,6 +269,19 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
typedef MapRefManager PlayerList;
PlayerList const& GetPlayers() const { return m_mapRefManager; }
+
+ // must called with AddToWorld
+ template<class T>
+ void AddToActive(T* obj) { AddToActiveHelper(obj); }
+
+ void AddToActive(Creature* obj);
+
+ // must called with RemoveFromWorld
+ template<class T>
+ void RemoveFromActive(T* obj) { RemoveFromActiveHelper(obj); }
+
+ void RemoveFromActive(Creature* obj);
+
template<class T> void SwitchGridContainers(T* obj, bool active);
template<class NOTIFIER> void VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier);
template<class NOTIFIER> void VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier);
@@ -293,7 +304,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
CreatureMoveList i_creaturesToMove;
bool loaded(const GridPair &) const;
- void EnsureGridLoadedForPlayer(const Cell&, Player*, bool add_player);
+ void EnsureGridLoaded(const Cell&, Player* player = NULL);
void EnsureGridCreated(const GridPair &);
void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); }
@@ -313,6 +324,8 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
void UpdateActiveCells(const float &x, const float &y, const uint32 &t_diff);
protected:
+ void SetUnloadReferenceLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); }
+
typedef Trinity::ObjectLevelLockable<Map, ZThread::Mutex>::Lock Guard;
MapEntry const* i_mapEntry;
@@ -323,6 +336,10 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
MapRefManager m_mapRefManager;
MapRefManager::iterator m_mapRefIter;
+
+ typedef std::set<WorldObject*> ActiveNonPlayers;
+ ActiveNonPlayers m_activeNonPlayers;
+ ActiveNonPlayers::iterator m_activeNonPlayersIter;
private:
typedef GridReadGuard ReadGuard;
typedef GridWriteGuard WriteGuard;
@@ -334,9 +351,9 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
time_t i_gridExpiry;
bool i_lock;
- std::set<WorldObject *> i_activeObjects;
std::vector<uint64> i_unitsToNotify;
std::set<WorldObject *> i_objectsToRemove;
+ std::map<WorldObject*, bool> i_objectsToSwitch;
// Type specific code for add/remove to/from grid
template<class T>
@@ -350,6 +367,27 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
template<class T>
void DeleteFromWorld(T*);
+
+ template<class T>
+ void AddToActiveHelper(T* obj)
+ {
+ m_activeNonPlayers.insert(obj);
+ }
+
+ template<class T>
+ void RemoveFromActiveHelper(T* obj)
+ {
+ // Map::Update for active object in proccess
+ if(m_activeNonPlayersIter != m_activeNonPlayers.end())
+ {
+ ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
+ if(itr==m_activeNonPlayersIter)
+ ++m_activeNonPlayersIter;
+ m_activeNonPlayers.erase(itr);
+ }
+ else
+ m_activeNonPlayers.erase(obj);
+ }
};
enum InstanceResetMethod
@@ -376,7 +414,7 @@ class TRINITY_DLL_SPEC InstanceMap : public Map
InstanceData* GetInstanceData() { return i_data; }
void PermBindAllPlayers(Player *player);
time_t GetResetTime();
- void UnloadAll(bool pForce);
+ void UnloadAll();
bool CanEnter(Player* player);
void SendResetWarnings(uint32 timeLeft) const;
void SetResetSchedule(bool on);
@@ -398,7 +436,7 @@ class TRINITY_DLL_SPEC BattleGroundMap : public Map
void Remove(Player *, bool);
bool CanEnter(Player* player);
void SetUnload();
- void UnloadAll(bool pForce);
+ void UnloadAll();
};
/*inline
@@ -422,7 +460,7 @@ Map::Visit(const CellLock<LOCK_TYPE> &cell, TypeContainerVisitor<T, CONTAINER> &
if( !cell->NoCreate() || loaded(GridPair(x,y)) )
{
- EnsureGridLoadedForPlayer(cell, NULL, false);
+ EnsureGridLoaded(cell);
//LOCK_TYPE guard(i_info[x][y]->i_lock);
getNGrid(x, y)->Visit(cell_x, cell_y, visitor);
}