mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 14:16:31 +00:00
First Commit
For Azeroth!
This commit is contained in:
363
src/server/game/Grids/Notifiers/GridNotifiers.cpp
Normal file
363
src/server/game/Grids/Notifiers/GridNotifiers.cpp
Normal file
@@ -0,0 +1,363 @@
|
||||
/*
|
||||
* Copyright (C)
|
||||
* Copyright (C)
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "UpdateData.h"
|
||||
#include "Item.h"
|
||||
#include "Map.h"
|
||||
#include "Transport.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "CellImpl.h"
|
||||
#include "SpellInfo.h"
|
||||
|
||||
using namespace Trinity;
|
||||
|
||||
|
||||
void VisibleNotifier::Visit(GameObjectMapType &m)
|
||||
{
|
||||
for (GameObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
vis_guids.erase(iter->GetSource()->GetGUID());
|
||||
i_player.UpdateVisibilityOf(iter->GetSource(), i_data, i_visibleNow);
|
||||
}
|
||||
}
|
||||
|
||||
void VisibleNotifier::SendToSelf()
|
||||
{
|
||||
// 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())
|
||||
for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end();++itr)
|
||||
{
|
||||
if (vis_guids.find((*itr)->GetGUID()) != vis_guids.end())
|
||||
{
|
||||
vis_guids.erase((*itr)->GetGUID());
|
||||
|
||||
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);
|
||||
(*itr)->ToPlayer()->UpdateVisibilityOf(&i_player);
|
||||
break;
|
||||
case TYPEID_UNIT:
|
||||
i_player.UpdateVisibilityOf((*itr)->ToCreature(), i_data, i_visibleNow);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Player::ClientGUIDs::const_iterator it = vis_guids.begin();it != vis_guids.end(); ++it)
|
||||
{
|
||||
// pussywizard: static transports are removed only in RemovePlayerFromMap and here if can no longer detect (eg. phase changed)
|
||||
if (IS_TRANSPORT_GUID(*it))
|
||||
if (GameObject* staticTrans = i_player.GetMap()->GetGameObject(*it))
|
||||
if (i_player.CanSeeOrDetect(staticTrans, false, true))
|
||||
continue;
|
||||
|
||||
i_player.m_clientGUIDs.erase(*it);
|
||||
i_data.AddOutOfRangeGUID(*it);
|
||||
|
||||
if (IS_PLAYER_GUID(*it))
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(*it);
|
||||
if (player && player->IsInMap(&i_player))
|
||||
player->UpdateVisibilityOf(&i_player);
|
||||
}
|
||||
}
|
||||
|
||||
if (!i_data.HasData())
|
||||
return;
|
||||
|
||||
WorldPacket packet;
|
||||
i_data.BuildPacket(&packet);
|
||||
i_player.GetSession()->SendPacket(&packet);
|
||||
|
||||
for (std::vector<Unit*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it)
|
||||
i_player.GetInitialVisiblePackets(*it);
|
||||
}
|
||||
|
||||
void VisibleChangesNotifier::Visit(PlayerMapType &m)
|
||||
{
|
||||
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
if (iter->GetSource() == &i_object)
|
||||
continue;
|
||||
|
||||
iter->GetSource()->UpdateVisibilityOf(&i_object);
|
||||
|
||||
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())
|
||||
(*i)->UpdateVisibilityOf(&i_object);
|
||||
}
|
||||
}
|
||||
|
||||
void VisibleChangesNotifier::Visit(CreatureMapType &m)
|
||||
{
|
||||
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
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())
|
||||
(*i)->UpdateVisibilityOf(&i_object);
|
||||
}
|
||||
|
||||
void VisibleChangesNotifier::Visit(DynamicObjectMapType &m)
|
||||
{
|
||||
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
if (IS_PLAYER_GUID(iter->GetSource()->GetCasterGUID()))
|
||||
if (Unit* caster = iter->GetSource()->GetCaster())
|
||||
if (Player* player = caster->ToPlayer())
|
||||
if (player->m_seer == iter->GetSource())
|
||||
player->UpdateVisibilityOf(&i_object);
|
||||
}
|
||||
|
||||
inline void CreatureUnitRelocationWorker(Creature* c, Unit* u)
|
||||
{
|
||||
if (!u->IsAlive() || !c->IsAlive() || c == u || u->IsInFlight())
|
||||
return;
|
||||
|
||||
if (c->HasReactState(REACT_AGGRESSIVE) && !c->HasUnitState(UNIT_STATE_SIGHTLESS))
|
||||
if (c->IsAIEnabled && c->CanSeeOrDetect(u, false, true))
|
||||
c->AI()->MoveInLineOfSight_Safe(u);
|
||||
}
|
||||
|
||||
void PlayerRelocationNotifier::Visit(PlayerMapType &m)
|
||||
{
|
||||
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
Player* player = iter->GetSource();
|
||||
vis_guids.erase(player->GetGUID());
|
||||
i_player.UpdateVisibilityOf(player, i_data, i_visibleNow);
|
||||
player->UpdateVisibilityOf(&i_player); // this notifier with different Visit(PlayerMapType&) than VisibleNotifier is needed to update visibility of self for other players when we move (eg. stealth detection changes)
|
||||
}
|
||||
}
|
||||
|
||||
void CreatureRelocationNotifier::Visit(PlayerMapType &m)
|
||||
{
|
||||
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
Player* player = iter->GetSource();
|
||||
|
||||
// NOTIFY_VISIBILITY_CHANGED does not guarantee that player will do it himself (because distance is also checked), but screw it, it's not that important
|
||||
if (!player->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
|
||||
player->UpdateVisibilityOf(&i_creature);
|
||||
|
||||
// NOTIFY_AI_RELOCATION does not guarantee that player will do it himself (because distance is also checked), but screw it, it's not that important
|
||||
if (!player->m_seer->isNeedNotify(NOTIFY_AI_RELOCATION) && !i_creature.IsMoveInLineOfSightStrictlyDisabled())
|
||||
CreatureUnitRelocationWorker(&i_creature, player);
|
||||
}
|
||||
}
|
||||
|
||||
void AIRelocationNotifier::Visit(CreatureMapType &m)
|
||||
{
|
||||
bool self = isCreature && !((Creature*)(&i_unit))->IsMoveInLineOfSightStrictlyDisabled();
|
||||
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
Creature* c = iter->GetSource();
|
||||
|
||||
// NOTIFY_VISIBILITY_CHANGED | NOTIFY_AI_RELOCATION does not guarantee that unit will do it itself (because distance is also checked), but screw it, it's not that important
|
||||
if (!c->isNeedNotify(NOTIFY_VISIBILITY_CHANGED | NOTIFY_AI_RELOCATION) && !c->IsMoveInLineOfSightStrictlyDisabled())
|
||||
CreatureUnitRelocationWorker(c, &i_unit);
|
||||
|
||||
if (self)
|
||||
CreatureUnitRelocationWorker((Creature*)&i_unit, c);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageDistDeliverer::Visit(PlayerMapType &m)
|
||||
{
|
||||
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
Player* target = iter->GetSource();
|
||||
if (!target->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (target->GetExactDist2dSq(i_source) > i_distSq)
|
||||
continue;
|
||||
|
||||
// Send packet to all who are sharing the player's vision
|
||||
if (target->HasSharedVision())
|
||||
{
|
||||
SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
|
||||
for (; i != target->GetSharedVisionList().end(); ++i)
|
||||
if ((*i)->m_seer == target)
|
||||
SendPacket(*i);
|
||||
}
|
||||
|
||||
if (target->m_seer == target || target->GetVehicle())
|
||||
SendPacket(target);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageDistDeliverer::Visit(CreatureMapType &m)
|
||||
{
|
||||
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
Creature* target = iter->GetSource();
|
||||
if (!target->HasSharedVision() || !target->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (target->GetExactDist2dSq(i_source) > i_distSq)
|
||||
continue;
|
||||
|
||||
// Send packet to all who are sharing the creature's vision
|
||||
SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
|
||||
for (; i != target->GetSharedVisionList().end(); ++i)
|
||||
if ((*i)->m_seer == target)
|
||||
SendPacket(*i);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageDistDeliverer::Visit(DynamicObjectMapType &m)
|
||||
{
|
||||
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
DynamicObject* target = iter->GetSource();
|
||||
if (!IS_PLAYER_GUID(target->GetCasterGUID()) || !target->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
// Xinef: Check whether the dynobject allows to see through it
|
||||
if (!target->IsViewpoint())
|
||||
continue;
|
||||
|
||||
if (target->GetExactDist2dSq(i_source) > i_distSq)
|
||||
continue;
|
||||
|
||||
// Send packet back to the caster if the caster has vision of dynamic object
|
||||
Player* caster = (Player*)target->GetCaster();
|
||||
if (caster && caster->m_seer == target)
|
||||
SendPacket(caster);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageDistDelivererToHostile::Visit(PlayerMapType &m)
|
||||
{
|
||||
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
Player* target = iter->GetSource();
|
||||
if (!target->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (target->GetExactDist2dSq(i_source) > i_distSq)
|
||||
continue;
|
||||
|
||||
// Send packet to all who are sharing the player's vision
|
||||
if (target->HasSharedVision())
|
||||
{
|
||||
SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
|
||||
for (; i != target->GetSharedVisionList().end(); ++i)
|
||||
if ((*i)->m_seer == target)
|
||||
SendPacket(*i);
|
||||
}
|
||||
|
||||
if (target->m_seer == target || target->GetVehicle())
|
||||
SendPacket(target);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageDistDelivererToHostile::Visit(CreatureMapType &m)
|
||||
{
|
||||
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
Creature* target = iter->GetSource();
|
||||
if (!target->HasSharedVision() || !target->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (target->GetExactDist2dSq(i_source) > i_distSq)
|
||||
continue;
|
||||
|
||||
// Send packet to all who are sharing the creature's vision
|
||||
SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
|
||||
for (; i != target->GetSharedVisionList().end(); ++i)
|
||||
if ((*i)->m_seer == target)
|
||||
SendPacket(*i);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageDistDelivererToHostile::Visit(DynamicObjectMapType &m)
|
||||
{
|
||||
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
DynamicObject* target = iter->GetSource();
|
||||
if (!IS_PLAYER_GUID(target->GetCasterGUID()) || !target->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (target->GetExactDist2dSq(i_source) > i_distSq)
|
||||
continue;
|
||||
|
||||
// Send packet back to the caster if the caster has vision of dynamic object
|
||||
Player* caster = (Player*)target->GetCaster();
|
||||
if (caster && caster->m_seer == target)
|
||||
SendPacket(caster);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void ObjectUpdater::Visit(GridRefManager<T> &m)
|
||||
{
|
||||
T* obj;
|
||||
for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); )
|
||||
{
|
||||
obj = iter->GetSource();
|
||||
++iter;
|
||||
if (obj->IsInWorld())
|
||||
obj->Update(i_timeDiff);
|
||||
}
|
||||
}
|
||||
|
||||
bool AnyDeadUnitObjectInRangeCheck::operator()(Player* u)
|
||||
{
|
||||
return !u->IsAlive() && !u->HasAuraType(SPELL_AURA_GHOST) && i_searchObj->IsWithinDistInMap(u, i_range);
|
||||
}
|
||||
|
||||
bool AnyDeadUnitObjectInRangeCheck::operator()(Corpse* u)
|
||||
{
|
||||
return u->GetType() != CORPSE_BONES && i_searchObj->IsWithinDistInMap(u, i_range);
|
||||
}
|
||||
|
||||
bool AnyDeadUnitObjectInRangeCheck::operator()(Creature* u)
|
||||
{
|
||||
return !u->IsAlive() && i_searchObj->IsWithinDistInMap(u, i_range);
|
||||
}
|
||||
|
||||
bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Player* u)
|
||||
{
|
||||
return AnyDeadUnitObjectInRangeCheck::operator()(u) && i_check(u);
|
||||
}
|
||||
|
||||
bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Corpse* u)
|
||||
{
|
||||
return AnyDeadUnitObjectInRangeCheck::operator()(u) && i_check(u);
|
||||
}
|
||||
|
||||
bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Creature* u)
|
||||
{
|
||||
return AnyDeadUnitObjectInRangeCheck::operator()(u) && i_check(u);
|
||||
}
|
||||
|
||||
template void ObjectUpdater::Visit<Creature>(CreatureMapType&);
|
||||
template void ObjectUpdater::Visit<GameObject>(GameObjectMapType&);
|
||||
template void ObjectUpdater::Visit<DynamicObject>(DynamicObjectMapType&);
|
||||
1536
src/server/game/Grids/Notifiers/GridNotifiers.h
Normal file
1536
src/server/game/Grids/Notifiers/GridNotifiers.h
Normal file
File diff suppressed because it is too large
Load Diff
586
src/server/game/Grids/Notifiers/GridNotifiersImpl.h
Normal file
586
src/server/game/Grids/Notifiers/GridNotifiersImpl.h
Normal file
@@ -0,0 +1,586 @@
|
||||
/*
|
||||
* Copyright (C)
|
||||
* Copyright (C)
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef TRINITY_GRIDNOTIFIERSIMPL_H
|
||||
#define TRINITY_GRIDNOTIFIERSIMPL_H
|
||||
|
||||
#include "GridNotifiers.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "Corpse.h"
|
||||
#include "Player.h"
|
||||
#include "UpdateData.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
template<class T>
|
||||
inline void Trinity::VisibleNotifier::Visit(GridRefManager<T> &m)
|
||||
{
|
||||
// Xinef: Update gameobjects only
|
||||
if (i_gobjOnly)
|
||||
return;
|
||||
|
||||
for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
vis_guids.erase(iter->GetSource()->GetGUID());
|
||||
i_player.UpdateVisibilityOf(iter->GetSource(), i_data, i_visibleNow);
|
||||
}
|
||||
}
|
||||
|
||||
// SEARCHERS & LIST SEARCHERS & WORKERS
|
||||
|
||||
// WorldObject searchers & workers
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectSearcher<Check>::Visit(GameObjectMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_GAMEOBJECT))
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectSearcher<Check>::Visit(PlayerMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_PLAYER))
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectSearcher<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_CREATURE))
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectSearcher<Check>::Visit(CorpseMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_CORPSE))
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectSearcher<Check>::Visit(DynamicObjectMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_DYNAMICOBJECT))
|
||||
return;
|
||||
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectLastSearcher<Check>::Visit(GameObjectMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_GAMEOBJECT))
|
||||
return;
|
||||
|
||||
for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectLastSearcher<Check>::Visit(PlayerMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_PLAYER))
|
||||
return;
|
||||
|
||||
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectLastSearcher<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_CREATURE))
|
||||
return;
|
||||
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectLastSearcher<Check>::Visit(CorpseMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_CORPSE))
|
||||
return;
|
||||
|
||||
for (CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectLastSearcher<Check>::Visit(DynamicObjectMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_DYNAMICOBJECT))
|
||||
return;
|
||||
|
||||
for (DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectListSearcher<Check>::Visit(PlayerMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_PLAYER))
|
||||
return;
|
||||
|
||||
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectListSearcher<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_CREATURE))
|
||||
return;
|
||||
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectListSearcher<Check>::Visit(CorpseMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_CORPSE))
|
||||
return;
|
||||
|
||||
for (CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectListSearcher<Check>::Visit(GameObjectMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_GAMEOBJECT))
|
||||
return;
|
||||
|
||||
for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::WorldObjectListSearcher<Check>::Visit(DynamicObjectMapType &m)
|
||||
{
|
||||
if (!(i_mapTypeMask & GRID_MAP_TYPE_MASK_DYNAMICOBJECT))
|
||||
return;
|
||||
|
||||
for (DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
// Gameobject searchers
|
||||
|
||||
template<class Check>
|
||||
void Trinity::GameObjectSearcher<Check>::Visit(GameObjectMapType &m)
|
||||
{
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::GameObjectLastSearcher<Check>::Visit(GameObjectMapType &m)
|
||||
{
|
||||
for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::GameObjectListSearcher<Check>::Visit(GameObjectMapType &m)
|
||||
{
|
||||
for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
// Unit searchers
|
||||
|
||||
template<class Check>
|
||||
void Trinity::UnitSearcher<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::UnitSearcher<Check>::Visit(PlayerMapType &m)
|
||||
{
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::UnitLastSearcher<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::UnitLastSearcher<Check>::Visit(PlayerMapType &m)
|
||||
{
|
||||
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::UnitListSearcher<Check>::Visit(PlayerMapType &m)
|
||||
{
|
||||
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::UnitListSearcher<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
// Creature searchers
|
||||
|
||||
template<class Check>
|
||||
void Trinity::CreatureSearcher<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::CreatureLastSearcher<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::CreatureListSearcher<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::PlayerListSearcher<Check>::Visit(PlayerMapType &m)
|
||||
{
|
||||
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
if (i_check(itr->GetSource()))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::PlayerListSearcherWithSharedVision<Check>::Visit(PlayerMapType &m)
|
||||
{
|
||||
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
if (i_check(itr->GetSource(), true))
|
||||
i_objects.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::PlayerListSearcherWithSharedVision<Check>::Visit(CreatureMapType &m)
|
||||
{
|
||||
for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
if (itr->GetSource()->InSamePhase(i_phaseMask) && itr->GetSource()->HasSharedVision())
|
||||
for (SharedVisionList::const_iterator i = itr->GetSource()->GetSharedVisionList().begin(); i != itr->GetSource()->GetSharedVisionList().end(); ++i)
|
||||
if (i_check(*i, false))
|
||||
i_objects.push_back(*i);
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::PlayerSearcher<Check>::Visit(PlayerMapType &m)
|
||||
{
|
||||
// already found
|
||||
if (i_object)
|
||||
return;
|
||||
|
||||
for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
{
|
||||
i_object = itr->GetSource();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Check>
|
||||
void Trinity::PlayerLastSearcher<Check>::Visit(PlayerMapType& m)
|
||||
{
|
||||
for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->GetSource()->InSamePhase(i_phaseMask))
|
||||
continue;
|
||||
|
||||
if (i_check(itr->GetSource()))
|
||||
i_object = itr->GetSource();
|
||||
}
|
||||
}
|
||||
|
||||
template<class Builder>
|
||||
void Trinity::LocalizedPacketDo<Builder>::operator()(Player* p)
|
||||
{
|
||||
LocaleConstant loc_idx = p->GetSession()->GetSessionDbLocaleIndex();
|
||||
uint32 cache_idx = loc_idx+1;
|
||||
WorldPacket* data;
|
||||
|
||||
// create if not cached yet
|
||||
if (i_data_cache.size() < cache_idx + 1 || !i_data_cache[cache_idx])
|
||||
{
|
||||
if (i_data_cache.size() < cache_idx + 1)
|
||||
i_data_cache.resize(cache_idx + 1);
|
||||
|
||||
data = new WorldPacket();
|
||||
|
||||
i_builder(*data, loc_idx);
|
||||
|
||||
ASSERT(data->GetOpcode() != MSG_NULL_ACTION);
|
||||
|
||||
i_data_cache[cache_idx] = data;
|
||||
}
|
||||
else
|
||||
data = i_data_cache[cache_idx];
|
||||
|
||||
p->SendDirectMessage(data);
|
||||
}
|
||||
|
||||
template<class Builder>
|
||||
void Trinity::LocalizedPacketListDo<Builder>::operator()(Player* p)
|
||||
{
|
||||
LocaleConstant loc_idx = p->GetSession()->GetSessionDbLocaleIndex();
|
||||
uint32 cache_idx = loc_idx+1;
|
||||
WorldPacketList* data_list;
|
||||
|
||||
// create if not cached yet
|
||||
if (i_data_cache.size() < cache_idx+1 || i_data_cache[cache_idx].empty())
|
||||
{
|
||||
if (i_data_cache.size() < cache_idx+1)
|
||||
i_data_cache.resize(cache_idx+1);
|
||||
|
||||
data_list = &i_data_cache[cache_idx];
|
||||
|
||||
i_builder(*data_list, loc_idx);
|
||||
}
|
||||
else
|
||||
data_list = &i_data_cache[cache_idx];
|
||||
|
||||
for (size_t i = 0; i < data_list->size(); ++i)
|
||||
p->SendDirectMessage((*data_list)[i]);
|
||||
}
|
||||
|
||||
#endif // TRINITY_GRIDNOTIFIERSIMPL_H
|
||||
Reference in New Issue
Block a user