*Update of relocation notify code.
--HG-- branch : trunk
This commit is contained in:
@@ -30,23 +30,6 @@
|
||||
|
||||
using namespace Trinity;
|
||||
|
||||
/*void
|
||||
Trinity::PlayerNotifier::Visit(PlayerMapType &m)
|
||||
{
|
||||
for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
if( iter->getSource() == &i_player )
|
||||
continue;
|
||||
|
||||
iter->getSource()->UpdateVisibilityOf(&i_player);
|
||||
i_player.UpdateVisibilityOf(iter->getSource());
|
||||
|
||||
if (!i_player.GetSharedVisionList().empty())
|
||||
for (SharedVisionList::const_iterator it = i_player.GetSharedVisionList().begin(); it != i_player.GetSharedVisionList().end(); ++it)
|
||||
(*it)->UpdateVisibilityOf(iter->getSource());
|
||||
}
|
||||
}*/
|
||||
|
||||
void
|
||||
VisibleChangesNotifier::Visit(PlayerMapType &m)
|
||||
{
|
||||
@@ -60,27 +43,7 @@ VisibleChangesNotifier::Visit(PlayerMapType &m)
|
||||
}
|
||||
|
||||
void
|
||||
VisibleNotifier::Visit(PlayerMapType &m)
|
||||
{
|
||||
for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
if( iter->getSource() == &i_player )
|
||||
continue;
|
||||
|
||||
iter->getSource()->UpdateVisibilityOf(&i_player);
|
||||
//i_player.UpdateVisibilityOf(iter->getSource());
|
||||
|
||||
//if (!i_player.GetSharedVisionList().empty())
|
||||
// for (SharedVisionList::const_iterator it = i_player.GetSharedVisionList().begin(); it != i_player.GetSharedVisionList().end(); ++it)
|
||||
// (*it)->UpdateVisibilityOf(iter->getSource());
|
||||
|
||||
i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow);
|
||||
i_clientGUIDs.erase(iter->getSource()->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VisibleNotifier::Notify()
|
||||
PlayerRelocationNotifier::Notify()
|
||||
{
|
||||
// at this moment i_clientGUIDs have guids that not iterate at grid level checks
|
||||
// but exist one case when this possible and object not out of range: transports
|
||||
@@ -146,7 +109,7 @@ VisibleNotifier::Notify()
|
||||
// send data at target visibility change (adding to client)
|
||||
for(std::set<WorldObject*>::const_iterator vItr = i_visibleNow.begin(); vItr != i_visibleNow.end(); ++vItr)
|
||||
if((*vItr)!=&i_player && (*vItr)->isType(TYPEMASK_UNIT))
|
||||
i_player.SendAuraDurationsForTarget((Unit*)(*vItr));
|
||||
i_player.SendInitialVisiblePackets((Unit*)(*vItr));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+25
-36
@@ -38,16 +38,7 @@ class Player;
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
|
||||
/*struct TRINITY_DLL_DECL PlayerNotifier
|
||||
{
|
||||
explicit PlayerNotifier(Player &pl) : i_player(pl) {}
|
||||
void Visit(PlayerMapType &);
|
||||
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
|
||||
Player &i_player;
|
||||
};*/
|
||||
|
||||
struct TRINITY_DLL_DECL VisibleNotifier
|
||||
struct TRINITY_DLL_DECL PlayerRelocationNotifier
|
||||
{
|
||||
Player &i_player;
|
||||
UpdateData i_data;
|
||||
@@ -55,12 +46,28 @@ namespace Trinity
|
||||
Player::ClientGUIDs i_clientGUIDs;
|
||||
std::set<WorldObject*> i_visibleNow;
|
||||
|
||||
explicit VisibleNotifier(Player &player) : i_player(player),i_clientGUIDs(player.m_clientGUIDs) {}
|
||||
template<class T> void Visit(GridRefManager<T> &m);
|
||||
void Visit(PlayerMapType &);
|
||||
PlayerRelocationNotifier(Player &player) : i_player(player),i_clientGUIDs(player.m_clientGUIDs) {}
|
||||
|
||||
#ifdef WIN32
|
||||
template<class T> inline void Visit(GridRefManager<T> &);
|
||||
template<> inline void Visit(PlayerMapType &);
|
||||
template<> inline void Visit(CreatureMapType &);
|
||||
#endif
|
||||
|
||||
void Notify(void);
|
||||
};
|
||||
|
||||
struct TRINITY_DLL_DECL CreatureRelocationNotifier
|
||||
{
|
||||
Creature &i_creature;
|
||||
CreatureRelocationNotifier(Creature &c) : i_creature(c) {}
|
||||
template<class T> void Visit(GridRefManager<T> &) {}
|
||||
#ifdef WIN32
|
||||
template<> inline void Visit(PlayerMapType &);
|
||||
template<> inline void Visit(CreatureMapType &);
|
||||
#endif
|
||||
};
|
||||
|
||||
struct TRINITY_DLL_DECL VisibleChangesNotifier
|
||||
{
|
||||
WorldObject &i_object;
|
||||
@@ -168,25 +175,6 @@ namespace Trinity
|
||||
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
|
||||
};
|
||||
|
||||
struct TRINITY_DLL_DECL PlayerRelocationNotifier
|
||||
{
|
||||
Player &i_player;
|
||||
PlayerRelocationNotifier(Player &pl) : i_player(pl) {}
|
||||
template<class T> void Visit(GridRefManager<T> &) {}
|
||||
void Visit(PlayerMapType &);
|
||||
void Visit(CreatureMapType &);
|
||||
};
|
||||
|
||||
struct TRINITY_DLL_DECL CreatureRelocationNotifier
|
||||
{
|
||||
Creature &i_creature;
|
||||
CreatureRelocationNotifier(Creature &c) : i_creature(c) {}
|
||||
template<class T> void Visit(GridRefManager<T> &) {}
|
||||
#ifdef WIN32
|
||||
template<> void Visit(PlayerMapType &);
|
||||
#endif
|
||||
};
|
||||
|
||||
struct TRINITY_DLL_DECL DynamicObjectUpdater
|
||||
{
|
||||
DynamicObject &i_dynobject;
|
||||
@@ -968,10 +956,11 @@ namespace Trinity
|
||||
};
|
||||
|
||||
#ifndef WIN32
|
||||
template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &);
|
||||
template<> void PlayerRelocationNotifier::Visit<Player>(PlayerMapType &);
|
||||
template<> void CreatureRelocationNotifier::Visit<Player>(PlayerMapType &);
|
||||
template<> void CreatureRelocationNotifier::Visit<Creature>(CreatureMapType &);
|
||||
template<class T> inline void PlayerRelocationNotifier::Visit(GridRefManager<T> &);
|
||||
template<> inline void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &);
|
||||
template<> inline void PlayerRelocationNotifier::Visit<Player>(PlayerMapType &);
|
||||
template<> inline void CreatureRelocationNotifier::Visit<Player>(PlayerMapType &);
|
||||
template<> inline void CreatureRelocationNotifier::Visit<Creature>(CreatureMapType &);
|
||||
template<> inline void DynamicObjectUpdater::Visit<Creature>(CreatureMapType &);
|
||||
template<> inline void DynamicObjectUpdater::Visit<Player>(PlayerMapType &);
|
||||
#endif
|
||||
|
||||
@@ -29,17 +29,6 @@
|
||||
#include "CreatureAI.h"
|
||||
#include "SpellAuras.h"
|
||||
|
||||
template<class T>
|
||||
inline void
|
||||
Trinity::VisibleNotifier::Visit(GridRefManager<T> &m)
|
||||
{
|
||||
for(typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow);
|
||||
i_clientGUIDs.erase(iter->getSource()->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
Trinity::ObjectUpdater::Visit(CreatureMapType &m)
|
||||
{
|
||||
@@ -48,28 +37,10 @@ Trinity::ObjectUpdater::Visit(CreatureMapType &m)
|
||||
iter->getSource()->Update(i_timeDiff);
|
||||
}
|
||||
|
||||
inline void
|
||||
Trinity::PlayerRelocationNotifier::Visit(PlayerMapType &m)
|
||||
{
|
||||
for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
if(&i_player==iter->getSource())
|
||||
continue;
|
||||
|
||||
// visibility for players updated by ObjectAccessor::UpdateVisibilityFor calls in appropriate places
|
||||
|
||||
// Cancel Trade
|
||||
if(i_player.GetTrader()==iter->getSource())
|
||||
// iteraction distance
|
||||
if(!i_player.IsWithinDistInMap(iter->getSource(), 5))
|
||||
i_player.GetSession()->SendCancelTrade(); // will clode both side trade windows
|
||||
}
|
||||
}
|
||||
|
||||
inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
|
||||
{
|
||||
// update creature visibility at player/creature move
|
||||
pl->UpdateVisibilityOf(c);
|
||||
if(!pl->isAlive() || !c->isAlive() || pl->isInFlight())
|
||||
return;
|
||||
|
||||
// Creature AI reaction
|
||||
if(c->HasReactState(REACT_AGGRESSIVE) && !c->hasUnitState(UNIT_STAT_SIGHTLESS))
|
||||
@@ -94,27 +65,71 @@ inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2)
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void
|
||||
Trinity::PlayerRelocationNotifier::Visit(GridRefManager<T> &m)
|
||||
{
|
||||
for(typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow);
|
||||
i_clientGUIDs.erase(iter->getSource()->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void
|
||||
Trinity::PlayerRelocationNotifier::Visit(PlayerMapType &m)
|
||||
{
|
||||
for(PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
if(iter->getSource()->m_Notified) //self is also skipped in this check
|
||||
continue;
|
||||
|
||||
i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow);
|
||||
i_clientGUIDs.erase(iter->getSource()->GetGUID());
|
||||
|
||||
iter->getSource()->UpdateVisibilityOf(&i_player);
|
||||
|
||||
//if (!i_player.GetSharedVisionList().empty())
|
||||
// for (SharedVisionList::const_iterator it = i_player.GetSharedVisionList().begin(); it != i_player.GetSharedVisionList().end(); ++it)
|
||||
// (*it)->UpdateVisibilityOf(iter->getSource());
|
||||
|
||||
// Cancel Trade
|
||||
if(i_player.GetTrader()==iter->getSource())
|
||||
if(!i_player.IsWithinDistInMap(iter->getSource(), 5)) // iteraction distance
|
||||
i_player.GetSession()->SendCancelTrade(); // will clode both side trade windows
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void
|
||||
Trinity::PlayerRelocationNotifier::Visit(CreatureMapType &m)
|
||||
{
|
||||
if(!i_player.isAlive() || i_player.isInFlight())
|
||||
return;
|
||||
for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
if(iter->getSource()->m_Notified)
|
||||
continue;
|
||||
|
||||
for(CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
||||
if( !iter->getSource()->m_Notified && iter->getSource()->isAlive())
|
||||
PlayerCreatureRelocationWorker(&i_player,iter->getSource());
|
||||
i_player.UpdateVisibilityOf(iter->getSource(),i_data,i_data_updates,i_visibleNow);
|
||||
i_clientGUIDs.erase(iter->getSource()->GetGUID());
|
||||
|
||||
PlayerCreatureRelocationWorker(&i_player, iter->getSource());
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void
|
||||
Trinity::CreatureRelocationNotifier::Visit(PlayerMapType &m)
|
||||
{
|
||||
if(!i_creature.isAlive())
|
||||
return;
|
||||
for(PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
if(iter->getSource()->m_Notified)
|
||||
continue;
|
||||
|
||||
for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
||||
if( !iter->getSource()->m_Notified && iter->getSource()->isAlive() && !iter->getSource()->isInFlight())
|
||||
PlayerCreatureRelocationWorker(iter->getSource(), &i_creature);
|
||||
iter->getSource()->UpdateVisibilityOf(&i_creature);
|
||||
|
||||
PlayerCreatureRelocationWorker(iter->getSource(), &i_creature);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
@@ -124,11 +139,15 @@ Trinity::CreatureRelocationNotifier::Visit(CreatureMapType &m)
|
||||
if(!i_creature.isAlive())
|
||||
return;
|
||||
|
||||
for(CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
||||
for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
Creature* c = iter->getSource();
|
||||
if( !iter->getSource()->m_Notified && c != &i_creature && c->isAlive())
|
||||
CreatureCreatureRelocationWorker(c, &i_creature);
|
||||
if(iter->getSource()->m_Notified)
|
||||
continue;
|
||||
|
||||
if(!iter->getSource()->isAlive())
|
||||
continue;
|
||||
|
||||
CreatureCreatureRelocationWorker(iter->getSource(), &i_creature);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-20
@@ -624,34 +624,15 @@ void Map::RelocationNotify()
|
||||
|
||||
if(unit->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
//UpdatePlayerVisibility((Player*)unit, cell, val);
|
||||
//Trinity::PlayerNotifier pl_notifier(*player);
|
||||
//VisitWorld(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), pl_notifier);
|
||||
|
||||
//UpdateObjectsVisibilityFor((Player*)unit, cell, val);
|
||||
Trinity::VisibleNotifier ob_notifier(*((Player*)unit));
|
||||
VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), ob_notifier);
|
||||
ob_notifier.Notify();
|
||||
|
||||
Trinity::PlayerRelocationNotifier notifier(*((Player*)unit));
|
||||
VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), notifier);
|
||||
notifier.Notify();
|
||||
}
|
||||
else
|
||||
{
|
||||
Trinity::CreatureRelocationNotifier notifier(*((Creature*)unit));
|
||||
VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), notifier);
|
||||
}
|
||||
|
||||
// Update visibility back to player who is controlling the unit
|
||||
if(unit->GetSharedVisionList().size())
|
||||
{
|
||||
for(SharedVisionList::const_iterator it = unit->GetSharedVisionList().begin(); it != unit->GetSharedVisionList().end(); ++it)
|
||||
{
|
||||
Trinity::VisibleNotifier ob_notifier(**it);
|
||||
VisitAll(unit->GetPositionX(), unit->GetPositionY(), World::GetMaxVisibleDistance(), ob_notifier);
|
||||
ob_notifier.Notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Clear list
|
||||
@@ -768,6 +749,28 @@ void Map::Update(const uint32 &t_diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update bindsight players
|
||||
if(obj->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
if(!((Unit*)obj)->GetSharedVisionList().empty())
|
||||
for(SharedVisionList::const_iterator it = ((Unit*)obj)->GetSharedVisionList().begin(); it != ((Unit*)obj)->GetSharedVisionList().end(); ++it)
|
||||
{
|
||||
Trinity::PlayerRelocationNotifier notifier(**it);
|
||||
VisitAll(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), notifier);
|
||||
notifier.Notify();
|
||||
}
|
||||
}
|
||||
else if(obj->GetTypeId() == TYPEID_DYNAMICOBJECT)
|
||||
{
|
||||
if(Unit *caster = ((DynamicObject*)obj)->GetCaster())
|
||||
if(caster->GetTypeId() == TYPEID_PLAYER && caster->GetUInt64Value(PLAYER_FARSIGHT) == obj->GetGUID())
|
||||
{
|
||||
Trinity::PlayerRelocationNotifier notifier(*((Player*)caster));
|
||||
VisitAll(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), notifier);
|
||||
notifier.Notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-27
@@ -16785,19 +16785,7 @@ void Player::HandleStealthedUnitsDetection()
|
||||
sLog.outDebug("Object %u (Type: %u) is detected in stealth by player %u. Distance = %f",(*i)->GetGUIDLow(),(*i)->GetTypeId(),GetGUIDLow(),GetDistance(*i));
|
||||
#endif
|
||||
|
||||
// target aura duration for caster show only if target exist at caster client
|
||||
// send data at target visibility change (adding to client)
|
||||
if((*i)!=this && (*i)->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
SendAuraDurationsForTarget(*i);
|
||||
//if(((Unit*)(*i))->isAlive()) //should be always alive
|
||||
{
|
||||
if((*i)->GetTypeId()==TYPEID_UNIT)
|
||||
((Creature*)(*i))->SendMonsterMoveWithSpeedToCurrentDestination(this);
|
||||
if(((Unit*)(*i))->getVictim())
|
||||
((Unit*)(*i))->SendAttackStart(((Unit*)(*i))->getVictim());
|
||||
}
|
||||
}
|
||||
SendInitialVisiblePackets(*i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17781,21 +17769,24 @@ void Player::UpdateVisibilityOf(WorldObject* target)
|
||||
|
||||
// target aura duration for caster show only if target exist at caster client
|
||||
// send data at target visibility change (adding to client)
|
||||
if(target!=this && target->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
SendAuraDurationsForTarget((Unit*)target);
|
||||
if(((Unit*)target)->isAlive())
|
||||
{
|
||||
if(target->GetTypeId()==TYPEID_UNIT)
|
||||
((Creature*)target)->SendMonsterMoveWithSpeedToCurrentDestination(this);
|
||||
if(((Unit*)target)->getVictim())
|
||||
((Unit*)target)->SendAttackStart(((Unit*)target)->getVictim());
|
||||
}
|
||||
}
|
||||
if(target->isType(TYPEMASK_UNIT))
|
||||
SendInitialVisiblePackets((Unit*)target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SendInitialVisiblePackets(Unit* target)
|
||||
{
|
||||
SendAuraDurationsForTarget(target);
|
||||
if(target->isAlive())
|
||||
{
|
||||
if(target->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE)
|
||||
target->SendMonsterMoveWithSpeedToCurrentDestination(this);
|
||||
if(target->hasUnitState(UNIT_STAT_MELEE_ATTACKING) && target->getVictim())
|
||||
target->SendAttackStart(target->getVictim());
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, T* target)
|
||||
{
|
||||
@@ -17842,7 +17833,7 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType&
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
/*template<>
|
||||
void Player::UpdateVisibilityOf<Creature>(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow)
|
||||
{
|
||||
if(HaveAtClient(target))
|
||||
@@ -17875,10 +17866,10 @@ void Player::UpdateVisibilityOf<Creature>(Creature* target, UpdateData& data, Up
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
template void Player::UpdateVisibilityOf(Player* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
|
||||
//template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
|
||||
template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
|
||||
template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
|
||||
template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
|
||||
template void Player::UpdateVisibilityOf(DynamicObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
|
||||
|
||||
@@ -2024,6 +2024,7 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
bool IsVisibleGloballyFor(Player* pl) const;
|
||||
|
||||
void UpdateVisibilityOf(WorldObject* target);
|
||||
void SendInitialVisiblePackets(Unit* target);
|
||||
|
||||
template<class T>
|
||||
void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set<WorldObject*>& visibleNow);
|
||||
|
||||
Reference in New Issue
Block a user