2010-10-07 15:35:36 +02:00
|
|
|
/*
|
2014-01-01 00:07:53 +01:00
|
|
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
2010-10-07 15:35:36 +02:00
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-10-02 16:23:55 -05:00
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
#include "GridNotifiers.h"
|
2010-02-27 22:16:36 +01:00
|
|
|
#include "GridNotifiersImpl.h"
|
2008-10-02 16:23:55 -05:00
|
|
|
#include "WorldPacket.h"
|
|
|
|
|
#include "WorldSession.h"
|
|
|
|
|
#include "UpdateData.h"
|
|
|
|
|
#include "Item.h"
|
|
|
|
|
#include "Map.h"
|
2010-06-07 23:40:17 +02:00
|
|
|
#include "Transport.h"
|
2008-10-02 16:23:55 -05:00
|
|
|
#include "ObjectAccessor.h"
|
2010-02-27 18:28:17 +02:00
|
|
|
#include "CellImpl.h"
|
2011-08-20 00:29:57 +02:00
|
|
|
#include "SpellInfo.h"
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
using namespace Trinity;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-10-24 23:33:17 +01:00
|
|
|
void VisibleNotifier::SendToSelf()
|
2009-12-19 10:12:40 +01:00
|
|
|
{
|
|
|
|
|
// 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
|
|
|
|
|
if (Transport* transport = i_player.GetTransport())
|
2013-10-16 18:37:29 +02:00
|
|
|
for (std::set<WorldObject*>::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end();++itr)
|
2009-12-19 10:12:40 +01:00
|
|
|
{
|
2010-04-07 19:14:10 +02:00
|
|
|
if (vis_guids.find((*itr)->GetGUID()) != vis_guids.end())
|
2009-12-19 10:12:40 +01:00
|
|
|
{
|
|
|
|
|
vis_guids.erase((*itr)->GetGUID());
|
|
|
|
|
|
2013-10-16 18:37:29 +02:00
|
|
|
switch ((*itr)->GetTypeId())
|
|
|
|
|
{
|
|
|
|
|
case TYPEID_GAMEOBJECT:
|
|
|
|
|
i_player.UpdateVisibilityOf((*itr)->ToGameObject(), i_data, i_visibleNow);
|
|
|
|
|
break;
|
|
|
|
|
case TYPEID_PLAYER:
|
|
|
|
|
i_player.UpdateVisibilityOf((*itr)->ToPlayer(), i_data, i_visibleNow);
|
|
|
|
|
if (!(*itr)->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
|
|
|
|
|
(*itr)->ToPlayer()->UpdateVisibilityOf(&i_player);
|
|
|
|
|
break;
|
|
|
|
|
case TYPEID_UNIT:
|
|
|
|
|
i_player.UpdateVisibilityOf((*itr)->ToCreature(), i_data, i_visibleNow);
|
|
|
|
|
break;
|
2013-10-16 19:14:00 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
2013-10-16 18:37:29 +02:00
|
|
|
}
|
2009-12-19 10:12:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-07 19:12:44 +02:00
|
|
|
for (Player::ClientGUIDs::const_iterator it = vis_guids.begin();it != vis_guids.end(); ++it)
|
2009-12-19 10:12:40 +01:00
|
|
|
{
|
|
|
|
|
i_player.m_clientGUIDs.erase(*it);
|
|
|
|
|
i_data.AddOutOfRangeGUID(*it);
|
2010-02-27 15:25:14 +02:00
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (IS_PLAYER_GUID(*it))
|
2010-02-27 15:25:14 +02:00
|
|
|
{
|
2011-11-07 11:06:39 -06:00
|
|
|
Player* player = ObjectAccessor::FindPlayer(*it);
|
|
|
|
|
if (player && player->IsInWorld() && !player->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
|
|
|
|
|
player->UpdateVisibilityOf(&i_player);
|
2010-02-27 15:25:14 +02:00
|
|
|
}
|
2009-12-19 10:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!i_data.HasData())
|
2009-12-19 10:12:40 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
WorldPacket packet;
|
|
|
|
|
i_data.BuildPacket(&packet);
|
|
|
|
|
i_player.GetSession()->SendPacket(&packet);
|
|
|
|
|
|
2010-04-07 19:12:44 +02:00
|
|
|
for (std::set<Unit*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it)
|
2009-12-19 10:12:40 +01:00
|
|
|
i_player.SendInitialVisiblePackets(*it);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-24 23:33:17 +01:00
|
|
|
void VisibleChangesNotifier::Visit(PlayerMapType &m)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2011-10-24 23:33:17 +01:00
|
|
|
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
if (iter->GetSource() == &i_object)
|
2008-10-02 16:23:55 -05:00
|
|
|
continue;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2013-06-11 21:25:12 -02:30
|
|
|
iter->GetSource()->UpdateVisibilityOf(&i_object);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2013-06-11 21:25:12 -02:30
|
|
|
if (iter->GetSource()->HasSharedVision())
|
2012-10-26 14:30:52 +02:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
for (SharedVisionList::const_iterator i = iter->GetSource()->GetSharedVisionList().begin();
|
|
|
|
|
i != iter->GetSource()->GetSharedVisionList().end(); ++i)
|
2012-10-26 14:30:52 +02:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
if ((*i)->m_seer == iter->GetSource())
|
2009-06-14 21:04:55 -05:00
|
|
|
(*i)->UpdateVisibilityOf(&i_object);
|
2012-10-26 14:30:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-10-24 23:33:17 +01:00
|
|
|
void VisibleChangesNotifier::Visit(CreatureMapType &m)
|
2009-06-14 21:04:55 -05:00
|
|
|
{
|
2009-10-17 16:20:24 -07:00
|
|
|
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2013-06-11 21:25:12 -02:30
|
|
|
if (iter->GetSource()->HasSharedVision())
|
|
|
|
|
for (SharedVisionList::const_iterator i = iter->GetSource()->GetSharedVisionList().begin();
|
|
|
|
|
i != iter->GetSource()->GetSharedVisionList().end(); ++i)
|
|
|
|
|
if ((*i)->m_seer == iter->GetSource())
|
2009-06-14 21:04:55 -05:00
|
|
|
(*i)->UpdateVisibilityOf(&i_object);
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-10-24 23:33:17 +01:00
|
|
|
void VisibleChangesNotifier::Visit(DynamicObjectMapType &m)
|
2009-06-14 21:04:55 -05:00
|
|
|
{
|
2009-10-17 16:20:24 -07:00
|
|
|
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2013-07-20 21:52:05 +02:00
|
|
|
if (Unit* caster = iter->GetSource()->GetCaster())
|
|
|
|
|
if (Player* player = caster->ToPlayer())
|
|
|
|
|
if (player->m_seer == iter->GetSource())
|
|
|
|
|
player->UpdateVisibilityOf(&i_object);
|
2009-06-14 21:04:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-02-27 15:25:14 +02:00
|
|
|
inline void CreatureUnitRelocationWorker(Creature* c, Unit* u)
|
|
|
|
|
{
|
2013-06-11 19:54:27 -02:30
|
|
|
if (!u->IsAlive() || !c->IsAlive() || c == u || u->IsInFlight())
|
2010-02-27 15:25:14 +02:00
|
|
|
return;
|
|
|
|
|
|
2012-02-03 19:02:17 +02:00
|
|
|
if (c->HasReactState(REACT_AGGRESSIVE) && !c->HasUnitState(UNIT_STATE_SIGHTLESS))
|
2013-06-11 21:25:12 -02:30
|
|
|
if (c->IsAIEnabled && c->CanSeeOrDetect(u, false, true))
|
2010-03-06 18:18:32 +02:00
|
|
|
c->AI()->MoveInLineOfSight_Safe(u);
|
2010-02-27 15:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PlayerRelocationNotifier::Visit(PlayerMapType &m)
|
|
|
|
|
{
|
2012-03-12 04:33:24 +01:00
|
|
|
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2010-02-27 15:25:14 +02:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
Player* player = iter->GetSource();
|
2010-02-27 15:25:14 +02:00
|
|
|
|
2011-11-07 11:06:39 -06:00
|
|
|
vis_guids.erase(player->GetGUID());
|
2010-02-27 15:25:14 +02:00
|
|
|
|
2011-11-07 11:06:39 -06:00
|
|
|
i_player.UpdateVisibilityOf(player, i_data, i_visibleNow);
|
2010-02-27 15:25:14 +02:00
|
|
|
|
2011-11-07 11:06:39 -06:00
|
|
|
if (player->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
|
2010-02-27 15:25:14 +02:00
|
|
|
continue;
|
|
|
|
|
|
2011-11-07 11:06:39 -06:00
|
|
|
player->UpdateVisibilityOf(&i_player);
|
2010-02-27 15:25:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PlayerRelocationNotifier::Visit(CreatureMapType &m)
|
|
|
|
|
{
|
|
|
|
|
bool relocated_for_ai = (&i_player == i_player.m_seer);
|
|
|
|
|
|
2010-04-07 19:12:44 +02:00
|
|
|
for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
|
2010-02-27 15:25:14 +02:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
Creature* c = iter->GetSource();
|
2010-02-27 15:25:14 +02:00
|
|
|
|
|
|
|
|
vis_guids.erase(c->GetGUID());
|
|
|
|
|
|
2011-04-29 20:47:02 +02:00
|
|
|
i_player.UpdateVisibilityOf(c, i_data, i_visibleNow);
|
2010-02-27 15:25:14 +02:00
|
|
|
|
|
|
|
|
if (relocated_for_ai && !c->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
|
|
|
|
|
CreatureUnitRelocationWorker(c, &i_player);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CreatureRelocationNotifier::Visit(PlayerMapType &m)
|
|
|
|
|
{
|
2012-10-26 14:30:52 +02:00
|
|
|
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2010-02-27 15:25:14 +02:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
Player* player = iter->GetSource();
|
2010-02-27 15:25:14 +02:00
|
|
|
|
2011-11-07 11:18:00 -06:00
|
|
|
if (!player->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
|
|
|
|
|
player->UpdateVisibilityOf(&i_creature);
|
2010-02-27 15:25:14 +02:00
|
|
|
|
2011-11-07 11:18:00 -06:00
|
|
|
CreatureUnitRelocationWorker(&i_creature, player);
|
2010-02-27 15:25:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CreatureRelocationNotifier::Visit(CreatureMapType &m)
|
|
|
|
|
{
|
2013-06-11 19:54:27 -02:30
|
|
|
if (!i_creature.IsAlive())
|
2010-02-27 15:25:14 +02:00
|
|
|
return;
|
|
|
|
|
|
2012-10-26 14:30:52 +02:00
|
|
|
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2010-02-27 15:25:14 +02:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
Creature* c = iter->GetSource();
|
2010-02-27 15:25:14 +02:00
|
|
|
CreatureUnitRelocationWorker(&i_creature, c);
|
|
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!c->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
|
2010-02-27 15:25:14 +02:00
|
|
|
CreatureUnitRelocationWorker(c, &i_creature);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DelayedUnitRelocation::Visit(CreatureMapType &m)
|
|
|
|
|
{
|
2010-04-07 19:12:44 +02:00
|
|
|
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2010-02-27 15:25:14 +02:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
Creature* unit = iter->GetSource();
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!unit->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
|
2010-02-27 15:25:14 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
CreatureRelocationNotifier relocate(*unit);
|
|
|
|
|
|
|
|
|
|
TypeContainerVisitor<CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocate);
|
|
|
|
|
TypeContainerVisitor<CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocate);
|
|
|
|
|
|
|
|
|
|
cell.Visit(p, c2world_relocation, i_map, *unit, i_radius);
|
|
|
|
|
cell.Visit(p, c2grid_relocation, i_map, *unit, i_radius);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DelayedUnitRelocation::Visit(PlayerMapType &m)
|
|
|
|
|
{
|
2010-04-07 19:12:44 +02:00
|
|
|
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2010-02-27 15:25:14 +02:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
Player* player = iter->GetSource();
|
2011-09-15 14:08:17 +02:00
|
|
|
WorldObject const* viewPoint = player->m_seer;
|
2010-02-27 15:25:14 +02:00
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!viewPoint->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
|
2010-02-27 15:25:14 +02:00
|
|
|
continue;
|
|
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (player != viewPoint && !viewPoint->IsPositionValid())
|
2010-02-27 15:25:14 +02:00
|
|
|
continue;
|
|
|
|
|
|
2011-10-18 10:53:34 -04:00
|
|
|
CellCoord pair2(Trinity::ComputeCellCoord(viewPoint->GetPositionX(), viewPoint->GetPositionY()));
|
2010-02-27 15:25:14 +02:00
|
|
|
Cell cell2(pair2);
|
|
|
|
|
//cell.SetNoCreate(); need load cells around viewPoint or player, that's why its commented
|
|
|
|
|
|
|
|
|
|
PlayerRelocationNotifier relocate(*player);
|
|
|
|
|
TypeContainerVisitor<PlayerRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocate);
|
|
|
|
|
TypeContainerVisitor<PlayerRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocate);
|
|
|
|
|
|
|
|
|
|
cell2.Visit(pair2, c2world_relocation, i_map, *viewPoint, i_radius);
|
|
|
|
|
cell2.Visit(pair2, c2grid_relocation, i_map, *viewPoint, i_radius);
|
|
|
|
|
|
|
|
|
|
relocate.SendToSelf();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AIRelocationNotifier::Visit(CreatureMapType &m)
|
|
|
|
|
{
|
|
|
|
|
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
|
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
Creature* c = iter->GetSource();
|
2010-02-27 15:25:14 +02:00
|
|
|
CreatureUnitRelocationWorker(c, &i_unit);
|
2010-04-07 19:14:10 +02:00
|
|
|
if (isCreature)
|
2010-02-27 15:25:14 +02:00
|
|
|
CreatureUnitRelocationWorker((Creature*)&i_unit, c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-24 23:33:17 +01:00
|
|
|
void MessageDistDeliverer::Visit(PlayerMapType &m)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2008-11-05 20:51:05 -06:00
|
|
|
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
Player* target = iter->GetSource();
|
2014-06-01 22:27:29 -05:00
|
|
|
if (!target->IsInPhase(i_source))
|
2009-01-31 16:38:50 -06:00
|
|
|
continue;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-11-13 17:18:09 +01:00
|
|
|
if (target->GetExactDist2dSq(i_source) > i_distSq)
|
2009-05-27 09:09:22 -05:00
|
|
|
continue;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-27 09:09:22 -05:00
|
|
|
// Send packet to all who are sharing the player's vision
|
2012-10-26 14:30:52 +02:00
|
|
|
if (target->HasSharedVision())
|
2009-05-27 09:09:22 -05:00
|
|
|
{
|
2009-06-07 17:38:08 -05:00
|
|
|
SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
|
2009-10-17 16:20:24 -07:00
|
|
|
for (; i != target->GetSharedVisionList().end(); ++i)
|
2010-04-07 19:14:10 +02:00
|
|
|
if ((*i)->m_seer == target)
|
2009-05-27 09:09:22 -05:00
|
|
|
SendPacket(*i);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (target->m_seer == target || target->GetVehicle())
|
2009-06-07 17:38:08 -05:00
|
|
|
SendPacket(target);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-09-05 14:01:50 +02:00
|
|
|
void MessageDistDeliverer::Visit(CreatureMapType &m)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2008-11-05 20:51:05 -06:00
|
|
|
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
Creature* target = iter->GetSource();
|
2014-06-01 22:27:29 -05:00
|
|
|
if (!target->IsInPhase(i_source))
|
2009-01-31 16:38:50 -06:00
|
|
|
continue;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-09-05 14:01:50 +02:00
|
|
|
if (target->GetExactDist2dSq(i_source) > i_distSq)
|
2009-05-27 09:09:22 -05:00
|
|
|
continue;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-27 09:09:22 -05:00
|
|
|
// Send packet to all who are sharing the creature's vision
|
2012-10-26 14:30:52 +02:00
|
|
|
if (target->HasSharedVision())
|
2008-11-05 20:51:05 -06:00
|
|
|
{
|
2011-09-05 14:01:50 +02:00
|
|
|
SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
|
|
|
|
|
for (; i != target->GetSharedVisionList().end(); ++i)
|
|
|
|
|
if ((*i)->m_seer == target)
|
2009-05-27 09:09:22 -05:00
|
|
|
SendPacket(*i);
|
2008-11-14 20:40:35 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-09-05 14:01:50 +02:00
|
|
|
void MessageDistDeliverer::Visit(DynamicObjectMapType &m)
|
2008-11-14 20:40:35 -06:00
|
|
|
{
|
|
|
|
|
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
|
|
|
|
{
|
2013-06-11 21:25:12 -02:30
|
|
|
DynamicObject* target = iter->GetSource();
|
2014-06-01 22:27:29 -05:00
|
|
|
if (!target->IsInPhase(i_source))
|
2009-01-31 16:38:50 -06:00
|
|
|
continue;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-09-05 14:01:50 +02:00
|
|
|
if (target->GetExactDist2dSq(i_source) > i_distSq)
|
2009-05-27 09:09:22 -05:00
|
|
|
continue;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2013-07-20 21:52:05 +02:00
|
|
|
if (Unit* caster = target->GetCaster())
|
2008-11-14 20:40:35 -06:00
|
|
|
{
|
2009-05-27 09:09:22 -05:00
|
|
|
// Send packet back to the caster if the caster has vision of dynamic object
|
2013-07-20 21:52:05 +02:00
|
|
|
Player* player = caster->ToPlayer();
|
|
|
|
|
if (player && player->m_seer == target)
|
|
|
|
|
SendPacket(player);
|
2008-11-05 20:51:05 -06:00
|
|
|
}
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-27 09:09:22 -05:00
|
|
|
/*
|
2008-11-05 20:51:05 -06:00
|
|
|
void
|
2011-11-07 11:06:39 -06:00
|
|
|
MessageDistDeliverer::VisitObject(Player* player)
|
2008-11-05 20:51:05 -06:00
|
|
|
{
|
2011-11-07 11:06:39 -06:00
|
|
|
if (!i_ownTeamOnly || (i_source.GetTypeId() == TYPEID_PLAYER && player->GetTeam() == ((Player&)i_source).GetTeam()))
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2011-11-07 11:06:39 -06:00
|
|
|
SendPacket(player);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
|
|
|
|
}
|
2009-05-27 09:09:22 -05:00
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-10-24 23:33:17 +01:00
|
|
|
template<class T>
|
|
|
|
|
void ObjectUpdater::Visit(GridRefManager<T> &m)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2009-10-17 16:20:24 -07:00
|
|
|
for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
|
2013-06-11 21:25:12 -02:30
|
|
|
if (iter->GetSource()->IsInWorld())
|
|
|
|
|
iter->GetSource()->Update(i_timeDiff);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-08-20 00:29:57 +02:00
|
|
|
bool AnyDeadUnitObjectInRangeCheck::operator()(Player* u)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2013-06-11 19:54:27 -02:30
|
|
|
return !u->IsAlive() && !u->HasAuraType(SPELL_AURA_GHOST) && i_searchObj->IsWithinDistInMap(u, i_range);
|
2011-08-20 00:29:57 +02:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-08-20 00:29:57 +02:00
|
|
|
bool AnyDeadUnitObjectInRangeCheck::operator()(Corpse* u)
|
|
|
|
|
{
|
|
|
|
|
return u->GetType() != CORPSE_BONES && i_searchObj->IsWithinDistInMap(u, i_range);
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-08-20 00:29:57 +02:00
|
|
|
bool AnyDeadUnitObjectInRangeCheck::operator()(Creature* u)
|
|
|
|
|
{
|
2013-06-11 19:54:27 -02:30
|
|
|
return !u->IsAlive() && i_searchObj->IsWithinDistInMap(u, i_range);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-08-20 00:29:57 +02:00
|
|
|
bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Player* u)
|
2010-08-04 12:12:58 +02:00
|
|
|
{
|
2012-02-21 20:03:27 +01:00
|
|
|
return AnyDeadUnitObjectInRangeCheck::operator()(u) && i_check(u);
|
2011-08-20 00:29:57 +02:00
|
|
|
}
|
2010-08-04 12:12:58 +02:00
|
|
|
|
2011-08-20 00:29:57 +02:00
|
|
|
bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Corpse* u)
|
|
|
|
|
{
|
2012-02-21 20:03:27 +01:00
|
|
|
return AnyDeadUnitObjectInRangeCheck::operator()(u) && i_check(u);
|
2011-08-20 00:29:57 +02:00
|
|
|
}
|
2010-08-04 12:12:58 +02:00
|
|
|
|
2011-08-20 00:29:57 +02:00
|
|
|
bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Creature* u)
|
|
|
|
|
{
|
2012-02-21 20:03:27 +01:00
|
|
|
return AnyDeadUnitObjectInRangeCheck::operator()(u) && i_check(u);
|
2010-08-04 12:12:58 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 18:37:29 +02:00
|
|
|
template void ObjectUpdater::Visit<Creature>(CreatureMapType&);
|
|
|
|
|
template void ObjectUpdater::Visit<GameObject>(GameObjectMapType&);
|
|
|
|
|
template void ObjectUpdater::Visit<DynamicObject>(DynamicObjectMapType&);
|
2013-05-26 04:28:19 +03:00
|
|
|
template void ObjectUpdater::Visit<AreaTrigger>(AreaTriggerMapType &);
|
2013-10-26 17:06:50 +02:00
|
|
|
|