aboutsummaryrefslogtreecommitdiff
path: root/src/game/Map.cpp
diff options
context:
space:
mode:
authorMachiavelli <none@none>2009-06-10 08:45:45 +0200
committerMachiavelli <none@none>2009-06-10 08:45:45 +0200
commitee9beadbc20d24ec11346858db36c029c9c04b90 (patch)
treead8d5f89f9b7e1418c5bc00990370224b91453f3 /src/game/Map.cpp
parentf137dc02ecadb515928655dd6603f33187731fec (diff)
parentc9d9ae1e491243f82be5ac84dc2ad51dfbae35eb (diff)
Merge
--HG-- branch : trunk
Diffstat (limited to 'src/game/Map.cpp')
-rw-r--r--src/game/Map.cpp91
1 files changed, 54 insertions, 37 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 3af876f6fde..e3da8480719 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -370,16 +370,16 @@ void Map::AddNotifier(T*)
template<>
void Map::AddNotifier(Player* obj)
{
- obj->m_Notified = false;
- obj->m_IsInNotifyList = false;
+ //obj->m_Notified = false;
+ //obj->m_IsInNotifyList = false;
AddUnitToNotify(obj);
}
template<>
void Map::AddNotifier(Creature* obj)
{
- obj->m_Notified = false;
- obj->m_IsInNotifyList = false;
+ //obj->m_Notified = false;
+ //obj->m_IsInNotifyList = false;
AddUnitToNotify(obj);
}
@@ -561,25 +561,21 @@ bool Map::loaded(const GridPair &p) const
void Map::RelocationNotify()
{
- //Move backlog to notify list
- for(std::vector<uint64>::iterator iter = i_unitsToNotifyBacklog.begin(); iter != i_unitsToNotifyBacklog.end(); ++iter)
- {
- if(Unit *unit = ObjectAccessor::GetObjectInWorld(*iter, (Unit*)NULL))
- {
- i_unitsToNotify.push_back(unit);
- }
- }
- i_unitsToNotifyBacklog.clear();
+ i_lock = true;
//Notify
for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
{
Unit *unit = *iter;
- if(unit->m_Notified || !unit->IsInWorld() || unit->GetMapId() != GetId())
+ if(!unit)
+ continue;
+
+ unit->m_NotifyListPos = -1;
+
+ if(unit->m_Notified)
continue;
unit->m_Notified = true;
- unit->m_IsInNotifyList = false;
float dist = abs(unit->GetPositionX() - unit->oldX) + abs(unit->GetPositionY() - unit->oldY);
if(dist > 10.0f)
@@ -592,10 +588,10 @@ void Map::RelocationNotify()
if(unit->GetTypeId() == TYPEID_PLAYER)
{
Trinity::PlayerRelocationNotifier notifier(*((Player*)unit));
- if(((Player*)unit)->m_seer != unit)
+ //if(((Player*)unit)->m_seer != unit)
VisitAll(((Player*)unit)->m_seer->GetPositionX(), ((Player*)unit)->m_seer->GetPositionY(), World::GetMaxVisibleDistance() + dist, notifier);
- else
- VisitAll(((Player*)unit)->GetPositionX(), ((Player*)unit)->GetPositionY(), World::GetMaxVisibleDistance() + dist, notifier);
+ //else
+ //VisitAll(((Player*)unit)->GetPositionX(), ((Player*)unit)->GetPositionY(), World::GetMaxVisibleDistance() + dist, notifier);
notifier.Notify();
}
else
@@ -605,31 +601,55 @@ void Map::RelocationNotify()
}
}
for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
+ if(*iter)
+ (*iter)->m_Notified = false;
+ i_unitsToNotify.clear();
+
+ i_lock = false;
+
+ if(!i_unitsToNotifyBacklog.empty())
{
- (*iter)->m_Notified = false;
+ i_unitsToNotify.insert(i_unitsToNotify.end(), i_unitsToNotifyBacklog.begin(), i_unitsToNotifyBacklog.end());
+ i_unitsToNotifyBacklog.clear();
}
- i_unitsToNotify.clear();
}
void Map::AddUnitToNotify(Unit* u)
{
- if(u->m_IsInNotifyList)
- return;
+ if(u->m_NotifyListPos < 0)
+ {
+ u->oldX = u->GetPositionX();
+ u->oldY = u->GetPositionY();
- u->m_IsInNotifyList = true;
- u->oldX = u->GetPositionX();
- u->oldY = u->GetPositionY();
+ if(i_lock)
+ {
+ u->m_NotifyListPos = i_unitsToNotifyBacklog.size();
+ i_unitsToNotifyBacklog.push_back(u);
+ }
+ else
+ {
+ u->m_NotifyListPos = i_unitsToNotify.size();
+ i_unitsToNotify.push_back(u);
+ }
+ }
+}
+void Map::RemoveUnitFromNotify(int32 slot)
+{
if(i_lock)
- i_unitsToNotifyBacklog.push_back(u->GetGUID());
+ {
+ assert(slot < i_unitsToNotifyBacklog.size());
+ i_unitsToNotifyBacklog[slot] = NULL;
+ }
else
- i_unitsToNotify.push_back(u);
+ {
+ assert(slot < i_unitsToNotify.size());
+ i_unitsToNotify[slot] = NULL;
+ }
}
void Map::Update(const uint32 &t_diff)
{
- i_lock = false;
-
resetMarkedCells();
Trinity::ObjectUpdater updater(t_diff);
@@ -734,10 +754,7 @@ void Map::Update(const uint32 &t_diff)
}
}
- i_lock = true;
-
MoveAllCreaturesInMoveList();
- RelocationNotify();
RemoveAllObjectsInRemoveList();
// Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load !
@@ -2109,11 +2126,11 @@ inline void Map::setNGrid(NGridType *grid, uint32 x, uint32 y)
i_grids[x][y] = grid;
}
-void Map::DoDelayedMovesAndRemoves()
-{
- MoveAllCreaturesInMoveList();
- RemoveAllObjectsInRemoveList();
-}
+//void Map::DoDelayedMovesAndRemoves()
+//{
+ //MoveAllCreaturesInMoveList();
+ //RemoveAllObjectsInRemoveList();
+//}
void Map::AddObjectToRemoveList(WorldObject *obj)
{