aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/GridNotifiers.cpp3
-rw-r--r--src/game/GridNotifiersImpl.h4
-rw-r--r--src/game/Map.cpp65
-rw-r--r--src/game/Map.h3
-rw-r--r--src/game/ObjectGridLoader.cpp1
-rw-r--r--src/game/SpellAuras.cpp3
-rw-r--r--src/game/Unit.cpp3
7 files changed, 51 insertions, 31 deletions
diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp
index a244e950dad..fe18dc35840 100644
--- a/src/game/GridNotifiers.cpp
+++ b/src/game/GridNotifiers.cpp
@@ -98,6 +98,9 @@ PlayerVisibilityNotifier::Notify()
// target aura duration for caster show only if target exist at caster client
if((*vItr)!=&i_player && (*vItr)->isType(TYPEMASK_UNIT))
i_player.SendInitialVisiblePackets((Unit*)(*vItr));
+
+ if(i_visibleNow.size() >= 30)
+ i_player.SetToNotify();
}
void
diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h
index 491ff67aec5..0b19f89d60c 100644
--- a/src/game/GridNotifiersImpl.h
+++ b/src/game/GridNotifiersImpl.h
@@ -190,11 +190,15 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
{
if (i_check->IsFriendlyTo( target ))
return;
+
+ i_check->CombatStart(target);
}
else
{
if (!i_check->IsHostileTo( target ))
return;
+
+ i_check->CombatStart(target);
}
// Check target immune to spell or aura
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index b39fb5780e2..7fd289d8a37 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -187,7 +187,7 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode)
: i_mapEntry (sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode),
i_id(id), i_InstanceId(InstanceId), m_unloadTimer(0), i_gridExpiry(expiry),
m_activeNonPlayersIter(m_activeNonPlayers.end())
- , i_lock(false)
+ , i_lock(true)
{
for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
{
@@ -353,12 +353,14 @@ void Map::AddNotifier(T*)
template<>
void Map::AddNotifier(Player* obj)
{
+ obj->m_IsInNotifyList = false;
AddUnitToNotify(obj);
}
template<>
void Map::AddNotifier(Creature* obj)
{
+ obj->m_IsInNotifyList = false;
AddUnitToNotify(obj);
}
@@ -460,8 +462,6 @@ bool Map::Add(Player *player)
SendInitSelf(player);
SendInitTransports(player);
- player->m_IsInNotifyList = false;
- player->m_Notified = false;
player->m_clientGUIDs.clear();
AddNotifier(player);
@@ -501,7 +501,7 @@ Map::Add(T *obj)
//something, such as vehicle, needs to be update immediately
//if(obj->GetTypeId() != TYPEID_UNIT)
- UpdateObjectVisibility(obj,cell,p);
+ UpdateObjectVisibility(obj,cell,p);
AddNotifier(obj);
}
@@ -603,20 +603,25 @@ bool Map::loaded(const GridPair &p) const
void Map::RelocationNotify()
{
- //creatures may be added to the list during update
- i_lock = true;
+ //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();
//Notify
- for(std::vector<uint64>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
+ for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
{
- Unit *unit = ObjectAccessor::GetObjectInWorld(*iter, (Unit*)NULL);
- if(!unit || !unit->IsInWorld() || unit->GetMapId() != GetId())
- {
- *iter = 0;
+ Unit *unit = *iter;
+ if(unit->m_Notified || !unit->IsInWorld() || unit->GetMapId() != GetId())
continue;
- }
unit->m_Notified = true;
+ unit->m_IsInNotifyList = false;
if(unit->GetTypeId() == TYPEID_PLAYER)
{
@@ -630,23 +635,30 @@ void Map::RelocationNotify()
VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), notifier);
}
}
-
- //Clear list
- for(std::vector<uint64>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
+ for(std::vector<Unit*>::iterator iter = i_unitsToNotify.begin(); iter != i_unitsToNotify.end(); ++iter)
{
- if(Unit *unit = ObjectAccessor::GetObjectInWorld(*iter, (Unit*)NULL))
- {
- unit->m_IsInNotifyList = false;
- unit->m_Notified = false;
- }
+ (*iter)->m_Notified = false;
}
i_unitsToNotify.clear();
+}
- i_lock = false;
+void Map::AddUnitToNotify(Unit* u)
+{
+ if(u->m_IsInNotifyList)
+ return;
+
+ u->m_IsInNotifyList = true;
+
+ if(i_lock)
+ i_unitsToNotifyBacklog.push_back(u->GetGUID());
+ else
+ i_unitsToNotify.push_back(u);
}
void Map::Update(const uint32 &t_diff)
{
+ i_lock = false;
+
resetMarkedCells();
Trinity::ObjectUpdater updater(t_diff);
@@ -755,6 +767,8 @@ void Map::Update(const uint32 &t_diff)
}
}
+ i_lock = true;
+
RelocationNotify();
// 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 !
@@ -2606,12 +2620,3 @@ void BattleGroundMap::UnloadAll()
/*--------------------------TRINITY-------------------------*/
-void Map::AddUnitToNotify(Unit* u)
-{
- if(!i_lock && !u->m_IsInNotifyList)
- {
- i_unitsToNotify.push_back(u->GetGUID());
- u->m_IsInNotifyList = true;
- }
-}
-
diff --git a/src/game/Map.h b/src/game/Map.h
index 89d1ad2a6c3..0719ec602ef 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -484,7 +484,8 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
time_t i_gridExpiry;
bool i_lock;
- std::vector<uint64> i_unitsToNotify;
+ std::vector<uint64> i_unitsToNotifyBacklog;
+ std::vector<Unit*> i_unitsToNotify;
std::set<WorldObject *> i_objectsToRemove;
std::map<WorldObject*, bool> i_objectsToSwitch;
diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp
index 1ba694d9738..78727fc7c0a 100644
--- a/src/game/ObjectGridLoader.cpp
+++ b/src/game/ObjectGridLoader.cpp
@@ -314,6 +314,7 @@ ObjectGridStoper::Visit(CreatureMapType &m)
iter->getSource()->CombatStop();
iter->getSource()->DeleteThreatList();
iter->getSource()->RemoveAllDynObjects();
+ iter->getSource()->AI()->EnterEvadeMode();
}
}
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index f7139d06820..fca044ba411 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -703,6 +703,9 @@ void AreaAura::Update(uint32 diff)
aur = new AreaAura(actualSpellInfo, m_effIndex, NULL, (*tIter), caster, NULL);
aur->SetAuraDuration(GetAuraDuration());
(*tIter)->AddAura(aur);
+
+ if(m_areaAuraType == AREA_AURA_ENEMY)
+ caster->CombatStart(*tIter);
}
}
}
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 39daf01415a..f607d24cb6d 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -12769,6 +12769,9 @@ bool Unit::HandleAuraRaidProcFromCharge( Aura* triggeredByAura )
void Unit::SetToNotify()
{
+ if(m_IsInNotifyList)
+ return;
+
if(Map *map = GetMap())
map->AddUnitToNotify(this);
}