[9245] Remove CellLock class and all cell-level thread locking.

* It was wasting CPU power as cell-level locking is not needed.
* Future multithreading will be on map-level.
* CellLock was just a 'proxy' between Cell and CellPair and in some cases carried redundant data.
* Some minor cleanup in Cell::Visit/Map::Visit.
This commit is contained in:
XTZGZoReX 2010-01-23 21:36:01 +01:00
parent 39b7636094
commit 0ff9250de2
19 changed files with 104 additions and 209 deletions

View file

@ -627,8 +627,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> say_do(say_builder); MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> say_do(say_builder);
MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> > say_worker(GetPlayer(),sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),say_do); MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> > say_worker(GetPlayer(),sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),say_do);
TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> >, WorldTypeMapContainer > message(say_worker); TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> >, WorldTypeMapContainer > message(say_worker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY));
cell_lock->Visit(cell_lock, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY));
} }
WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8); WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8);

View file

@ -41,8 +41,6 @@ enum District
ALL_DISTRICT = (UPPER_DISTRICT | LOWER_DISTRICT | LEFT_DISTRICT | RIGHT_DISTRICT | CENTER_DISTRICT) ALL_DISTRICT = (UPPER_DISTRICT | LOWER_DISTRICT | LEFT_DISTRICT | RIGHT_DISTRICT | CENTER_DISTRICT)
}; };
template<class T> struct CellLock;
struct MANGOS_DLL_DECL CellArea struct MANGOS_DLL_DECL CellArea
{ {
CellArea() : right_offset(0), left_offset(0), upper_offset(0), lower_offset(0) {} CellArea() : right_offset(0), left_offset(0), upper_offset(0), lower_offset(0) {}
@ -160,30 +158,13 @@ struct MANGOS_DLL_DECL Cell
uint32 All; uint32 All;
} data; } data;
template<class LOCK_TYPE, class T, class CONTAINER> void Visit(const CellLock<LOCK_TYPE> &, TypeContainerVisitor<T, CONTAINER> &visitor, Map &) const; template<class T, class CONTAINER> void Visit(const CellPair &cellPair, TypeContainerVisitor<T, CONTAINER> &visitor, Map &) const;
template<class LOCK_TYPE, class T, class CONTAINER> void Visit(const CellLock<LOCK_TYPE> &, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject &obj, float radius) const; template<class T, class CONTAINER> void Visit(const CellPair &cellPair, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject &obj, float radius) const;
static CellArea CalculateCellArea(const WorldObject &obj, float radius); static CellArea CalculateCellArea(const WorldObject &obj, float radius);
private: private:
template<class LOCK_TYPE, class T, class CONTAINER> void VisitCircle(const CellLock<LOCK_TYPE> &, TypeContainerVisitor<T, CONTAINER> &, Map &, const CellPair& , const CellPair& ) const; template<class T, class CONTAINER> void VisitCircle(const CellPair &cellPair, TypeContainerVisitor<T, CONTAINER> &, Map &, const CellPair& , const CellPair& ) const;
}; };
template<class T>
struct MANGOS_DLL_DECL CellLock
{
const Cell& i_cell;
const CellPair &i_cellPair;
CellLock(const Cell &c, const CellPair &p) : i_cell(c), i_cellPair(p) {}
CellLock(const CellLock<T> &cell) : i_cell(cell.i_cell), i_cellPair(cell.i_cellPair) {}
const Cell* operator->(void) const { return &i_cell; }
const Cell* operator->(void) { return &i_cell; }
operator const Cell &(void) const { return i_cell; }
CellLock<T>& operator=(const CellLock<T> &cell)
{
~CellLock();
new (this) CellLock<T>(cell);
return *this;
}
};
#endif #endif

View file

@ -33,18 +33,17 @@ inline Cell::Cell(CellPair const& p)
data.Part.reserved = 0; data.Part.reserved = 0;
} }
template<class LOCK_TYPE,class T, class CONTAINER> template<class T, class CONTAINER>
inline void inline void
Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const
{ {
const CellPair &standing_cell = l.i_cellPair;
if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
return; return;
uint16 district = (District)this->data.Part.reserved; uint16 district = (District)this->data.Part.reserved;
if(district == CENTER_DISTRICT) if(district == CENTER_DISTRICT)
{ {
m.Visit(l, visitor); m.Visit(*this, visitor);
return; return;
} }
@ -121,9 +120,8 @@ Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &vi
{ {
CellPair cell_pair(x,y); CellPair cell_pair(x,y);
Cell r_zone(cell_pair); Cell r_zone(cell_pair);
r_zone.data.Part.nocreate = l->data.Part.nocreate; r_zone.data.Part.nocreate = data.Part.nocreate;
CellLock<LOCK_TYPE> lock(r_zone, cell_pair); m.Visit(r_zone, visitor);
m.Visit(lock, visitor);
} }
} }
} }
@ -165,11 +163,10 @@ inline CellArea Cell::CalculateCellArea(const WorldObject &obj, float radius)
return CellArea(right, left, upper, lower); return CellArea(right, left, upper, lower);
} }
template<class LOCK_TYPE, class T, class CONTAINER> template<class T, class CONTAINER>
inline void inline void
Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject &obj, float radius) const Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject &obj, float radius) const
{ {
const CellPair &standing_cell = l.i_cellPair;
if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
return; return;
@ -178,7 +175,7 @@ Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &vi
//maybe it is better to just return when radius <= 0.0f? //maybe it is better to just return when radius <= 0.0f?
if(radius <= 0.0f) if(radius <= 0.0f)
{ {
m.Visit(l, visitor); m.Visit(*this, visitor);
return; return;
} }
//lets limit the upper value for search radius //lets limit the upper value for search radius
@ -190,7 +187,7 @@ Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &vi
//if radius fits inside standing cell //if radius fits inside standing cell
if(!area) if(!area)
{ {
m.Visit(l, visitor); m.Visit(*this, visitor);
return; return;
} }
@ -204,13 +201,13 @@ Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &vi
//there are nothing to optimize because SIZE_OF_GRID_CELL is too big... //there are nothing to optimize because SIZE_OF_GRID_CELL is too big...
if(((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4)) if(((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4))
{ {
VisitCircle(l, visitor, m, begin_cell, end_cell); VisitCircle(standing_cell, visitor, m, begin_cell, end_cell);
return; return;
} }
//ALWAYS visit standing cell first!!! Since we deal with small radiuses //ALWAYS visit standing cell first!!! Since we deal with small radiuses
//it is very essential to call visitor for standing cell firstly... //it is very essential to call visitor for standing cell firstly...
m.Visit(l, visitor); m.Visit(*this, visitor);
// loop the cell range // loop the cell range
for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++) for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
@ -222,17 +219,16 @@ Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &vi
if(cell_pair != standing_cell) if(cell_pair != standing_cell)
{ {
Cell r_zone(cell_pair); Cell r_zone(cell_pair);
r_zone.data.Part.nocreate = l->data.Part.nocreate; r_zone.data.Part.nocreate = data.Part.nocreate;
CellLock<LOCK_TYPE> lock(r_zone, cell_pair); m.Visit(r_zone, visitor);
m.Visit(lock, visitor);
} }
} }
} }
} }
template<class LOCK_TYPE, class T, class CONTAINER> template<class T, class CONTAINER>
inline void inline void
Cell::VisitCircle(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const CellPair& begin_cell, const CellPair& end_cell) const Cell::VisitCircle(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const CellPair& begin_cell, const CellPair& end_cell) const
{ {
//here is an algorithm for 'filling' circum-squared octagon //here is an algorithm for 'filling' circum-squared octagon
uint32 x_shift = (uint32)ceilf((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f); uint32 x_shift = (uint32)ceilf((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f);
@ -247,9 +243,8 @@ Cell::VisitCircle(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINE
{ {
CellPair cell_pair(x,y); CellPair cell_pair(x,y);
Cell r_zone(cell_pair); Cell r_zone(cell_pair);
r_zone.data.Part.nocreate = l->data.Part.nocreate; r_zone.data.Part.nocreate = data.Part.nocreate;
CellLock<LOCK_TYPE> lock(r_zone, cell_pair); m.Visit(r_zone, visitor);
m.Visit(lock, visitor);
} }
} }
@ -272,16 +267,14 @@ Cell::VisitCircle(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINE
//e.g. filling 2 trapezoids after filling central cell strip... //e.g. filling 2 trapezoids after filling central cell strip...
CellPair cell_pair_left(x_start - step, y); CellPair cell_pair_left(x_start - step, y);
Cell r_zone_left(cell_pair_left); Cell r_zone_left(cell_pair_left);
r_zone_left.data.Part.nocreate = l->data.Part.nocreate; r_zone_left.data.Part.nocreate = data.Part.nocreate;
CellLock<LOCK_TYPE> lock_left(r_zone_left, cell_pair_left); m.Visit(r_zone_left, visitor);
m.Visit(lock_left, visitor);
//right trapezoid cell visit //right trapezoid cell visit
CellPair cell_pair_right(x_end + step, y); CellPair cell_pair_right(x_end + step, y);
Cell r_zone_right(cell_pair_right); Cell r_zone_right(cell_pair_right);
r_zone_right.data.Part.nocreate = l->data.Part.nocreate; r_zone_right.data.Part.nocreate = data.Part.nocreate;
CellLock<LOCK_TYPE> lock_right(r_zone_right, cell_pair_right); m.Visit(r_zone_right, visitor);
m.Visit(lock_right, visitor);
} }
} }
} }

View file

@ -1962,8 +1962,7 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid
MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(pl,obj,go_check); MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(pl,obj,go_check);
TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker); TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, object_checker, *pl->GetMap());
cell_lock->Visit(cell_lock, object_checker, *pl->GetMap());
} }
return obj; return obj;

View file

@ -582,8 +582,7 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
MaNGOS::LocalizedPacketDo<MaNGOS::EmoteChatBuilder > emote_do(emote_builder); MaNGOS::LocalizedPacketDo<MaNGOS::EmoteChatBuilder > emote_do(emote_builder);
MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::EmoteChatBuilder > > emote_worker(GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), emote_do); MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::EmoteChatBuilder > > emote_worker(GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), emote_do);
TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::EmoteChatBuilder > >, WorldTypeMapContainer> message(emote_worker); TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::EmoteChatBuilder > >, WorldTypeMapContainer> message(emote_worker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
cell_lock->Visit(cell_lock, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit); GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit);

View file

@ -551,8 +551,7 @@ void Creature::DoFleeToGetAssistance()
TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestAssistCreatureInCreatureRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher); TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestAssistCreatureInCreatureRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap(), *this, radius);
SetNoSearchAssistance(true); SetNoSearchAssistance(true);
UpdateSpeed(MOVE_RUN, false); UpdateSpeed(MOVE_RUN, false);
@ -1524,8 +1523,7 @@ void Creature::CallAssistance()
TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::AnyAssistCreatureInRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher); TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::AnyAssistCreatureInRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap(), *this, radius);
} }
if (!assistList.empty()) if (!assistList.empty())
@ -1558,8 +1556,7 @@ void Creature::CallForHelp(float fRadius)
TypeContainerVisitor<MaNGOS::CreatureWorker<MaNGOS::CallOfHelpCreatureInRangeDo>, GridTypeMapContainer > grid_creature_searcher(worker); TypeContainerVisitor<MaNGOS::CreatureWorker<MaNGOS::CallOfHelpCreatureInRangeDo>, GridTypeMapContainer > grid_creature_searcher(worker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_creature_searcher, *GetMap(), *this, fRadius);
cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap(), *this, fRadius);
} }
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const

View file

@ -1234,8 +1234,7 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
*/ */
TypeContainerVisitor<MaNGOS::UnitLastSearcher<MaNGOS::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitLastSearcher<MaNGOS::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_unit_searcher, *m_creature->GetMap(), *m_creature, range);
cell_lock->Visit(cell_lock, grid_unit_searcher, *m_creature->GetMap(), *m_creature, range);
return pUnit; return pUnit;
} }
@ -1251,8 +1250,7 @@ void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher); TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_creature_searcher, *m_creature->GetMap(), *m_creature, range);
cell_lock->Visit(cell_lock, grid_creature_searcher, *m_creature->GetMap(), *m_creature, range);
} }
void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid) void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid)
@ -1267,8 +1265,7 @@ void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, flo
TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher); TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_creature_searcher, *m_creature->GetMap(), *m_creature, range);
cell_lock->Visit(cell_lock, grid_creature_searcher, *m_creature->GetMap(), *m_creature, range);
} }
//********************************* //*********************************

View file

@ -124,9 +124,8 @@ void DynamicObject::Update(uint32 p_time)
TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, WorldTypeMapContainer > world_object_notifier(notifier); TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, WorldTypeMapContainer > world_object_notifier(notifier);
TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, GridTypeMapContainer > grid_object_notifier(notifier); TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, GridTypeMapContainer > grid_object_notifier(notifier);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, world_object_notifier, *GetMap(), *this, m_radius);
cell_lock->Visit(cell_lock, world_object_notifier, *GetMap(), *this, m_radius); cell.Visit(p, grid_object_notifier, *GetMap(), *this, m_radius);
cell_lock->Visit(cell_lock, grid_object_notifier, *GetMap(), *this, m_radius);
} }
if(deleteThis) if(deleteThis)

View file

@ -308,16 +308,14 @@ void GameObject::Update(uint32 /*p_time*/)
MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, owner, radius); MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, owner, radius);
MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck> checker(this,ok, u_check); MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck> checker(this,ok, u_check);
CellLock<GridReadGuard> cell_lock(cell, p);
TypeContainerVisitor<MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker); TypeContainerVisitor<MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker);
cell_lock->Visit(cell_lock, grid_object_checker, *GetMap(), *this, radius); cell.Visit(p, grid_object_checker, *GetMap(), *this, radius);
// or unfriendly player/pet // or unfriendly player/pet
if(!ok) if(!ok)
{ {
TypeContainerVisitor<MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker); TypeContainerVisitor<MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
cell_lock->Visit(cell_lock, world_object_checker, *GetMap(), *this, radius); cell.Visit(p, world_object_checker, *GetMap(), *this, radius);
} }
} }
else // environmental trap else // environmental trap
@ -329,10 +327,8 @@ void GameObject::Update(uint32 /*p_time*/)
MaNGOS::AnyPlayerInObjectRangeCheck p_check(this, radius); MaNGOS::AnyPlayerInObjectRangeCheck p_check(this, radius);
MaNGOS::PlayerSearcher<MaNGOS::AnyPlayerInObjectRangeCheck> checker(this,p_ok, p_check); MaNGOS::PlayerSearcher<MaNGOS::AnyPlayerInObjectRangeCheck> checker(this,p_ok, p_check);
CellLock<GridReadGuard> cell_lock(cell, p);
TypeContainerVisitor<MaNGOS::PlayerSearcher<MaNGOS::AnyPlayerInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker); TypeContainerVisitor<MaNGOS::PlayerSearcher<MaNGOS::AnyPlayerInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
cell_lock->Visit(cell_lock, world_object_checker, *GetMap(), *this, radius); cell.Visit(p, world_object_checker, *GetMap(), *this, radius);
ok = p_ok; ok = p_ok;
} }
@ -798,8 +794,7 @@ void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target)
MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO,go_check); MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO,go_check);
TypeContainerVisitor<MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer > object_checker(checker); TypeContainerVisitor<MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer > object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, object_checker, *GetMap(), *target, range);
cell_lock->Visit(cell_lock, object_checker, *GetMap(), *target, range);
} }
// found correct GO // found correct GO
@ -818,10 +813,8 @@ GameObject* GameObject::LookupFishingHoleAround(float range)
MaNGOS::NearestGameObjectFishingHole u_check(*this, range); MaNGOS::NearestGameObjectFishingHole u_check(*this, range);
MaNGOS::GameObjectSearcher<MaNGOS::NearestGameObjectFishingHole> checker(this, ok, u_check); MaNGOS::GameObjectSearcher<MaNGOS::NearestGameObjectFishingHole> checker(this, ok, u_check);
CellLock<GridReadGuard> cell_lock(cell, p);
TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::NearestGameObjectFishingHole>, GridTypeMapContainer > grid_object_checker(checker); TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::NearestGameObjectFishingHole>, GridTypeMapContainer > grid_object_checker(checker);
cell_lock->Visit(cell_lock, grid_object_checker, *GetMap(), *this, range); cell.Visit(p, grid_object_checker, *GetMap(), *this, range);
return ok; return ok;
} }

View file

@ -5374,8 +5374,7 @@ bool ChatHandler::HandleRespawnCommand(const char* /*args*/)
MaNGOS::WorldObjectWorker<MaNGOS::RespawnDo> worker(pl,u_do); MaNGOS::WorldObjectWorker<MaNGOS::RespawnDo> worker(pl,u_do);
TypeContainerVisitor<MaNGOS::WorldObjectWorker<MaNGOS::RespawnDo>, GridTypeMapContainer > obj_worker(worker); TypeContainerVisitor<MaNGOS::WorldObjectWorker<MaNGOS::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, obj_worker, *pl->GetMap());
cell_lock->Visit(cell_lock, obj_worker, *pl->GetMap());
return true; return true;
} }

View file

@ -508,8 +508,7 @@ void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self)
MaNGOS::MessageDeliverer post_man(*player, msg, to_self); MaNGOS::MessageDeliverer post_man(*player, msg, to_self);
TypeContainerVisitor<MaNGOS::MessageDeliverer, WorldTypeMapContainer > message(post_man); TypeContainerVisitor<MaNGOS::MessageDeliverer, WorldTypeMapContainer > message(post_man);
CellLock<ReadGuard> cell_lock(cell, p); cell.Visit(p, message, *this, *player, GetVisibilityDistance());
cell_lock->Visit(cell_lock, message, *this, *player, GetVisibilityDistance());
} }
void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg)
@ -533,8 +532,7 @@ void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg)
//we have alot of blinking mobs because monster move packet send is broken... //we have alot of blinking mobs because monster move packet send is broken...
MaNGOS::ObjectMessageDeliverer post_man(*obj,msg); MaNGOS::ObjectMessageDeliverer post_man(*obj,msg);
TypeContainerVisitor<MaNGOS::ObjectMessageDeliverer, WorldTypeMapContainer > message(post_man); TypeContainerVisitor<MaNGOS::ObjectMessageDeliverer, WorldTypeMapContainer > message(post_man);
CellLock<ReadGuard> cell_lock(cell, p); cell.Visit(p, message, *this, *obj, GetVisibilityDistance());
cell_lock->Visit(cell_lock, message, *this, *obj, GetVisibilityDistance());
} }
void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only) void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only)
@ -556,8 +554,7 @@ void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, boo
MaNGOS::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only); MaNGOS::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only);
TypeContainerVisitor<MaNGOS::MessageDistDeliverer , WorldTypeMapContainer > message(post_man); TypeContainerVisitor<MaNGOS::MessageDistDeliverer , WorldTypeMapContainer > message(post_man);
CellLock<ReadGuard> cell_lock(cell, p); cell.Visit(p, message, *this, *player, dist);
cell_lock->Visit(cell_lock, message, *this, *player, dist);
} }
void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist)
@ -579,8 +576,7 @@ void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist)
MaNGOS::ObjectMessageDistDeliverer post_man(*obj, msg, dist); MaNGOS::ObjectMessageDistDeliverer post_man(*obj, msg, dist);
TypeContainerVisitor<MaNGOS::ObjectMessageDistDeliverer, WorldTypeMapContainer > message(post_man); TypeContainerVisitor<MaNGOS::ObjectMessageDistDeliverer, WorldTypeMapContainer > message(post_man);
CellLock<ReadGuard> cell_lock(cell, p); cell.Visit(p, message, *this, *obj, dist);
cell_lock->Visit(cell_lock, message, *this, *obj, dist);
} }
bool Map::loaded(const GridPair &p) const bool Map::loaded(const GridPair &p) const
@ -643,9 +639,8 @@ void Map::Update(const uint32 &t_diff)
Cell cell(pair); Cell cell(pair);
cell.data.Part.reserved = CENTER_DISTRICT; cell.data.Part.reserved = CENTER_DISTRICT;
cell.SetNoCreate(); cell.SetNoCreate();
CellLock<NullGuard> cell_lock(cell, pair); cell.Visit(pair, grid_object_update, *this);
cell_lock->Visit(cell_lock, grid_object_update, *this); cell.Visit(pair, world_object_update, *this);
cell_lock->Visit(cell_lock, world_object_update, *this);
} }
} }
} }
@ -692,9 +687,8 @@ void Map::Update(const uint32 &t_diff)
Cell cell(pair); Cell cell(pair);
cell.data.Part.reserved = CENTER_DISTRICT; cell.data.Part.reserved = CENTER_DISTRICT;
cell.SetNoCreate(); cell.SetNoCreate();
CellLock<NullGuard> cell_lock(cell, pair); cell.Visit(pair, grid_object_update, *this);
cell_lock->Visit(cell_lock, grid_object_update, *this); cell.Visit(pair, world_object_update, *this);
cell_lock->Visit(cell_lock, world_object_update, *this);
} }
} }
} }
@ -2009,8 +2003,7 @@ void Map::UpdateObjectVisibility( WorldObject* obj, Cell cell, CellPair cellpair
cell.SetNoCreate(); cell.SetNoCreate();
MaNGOS::VisibleChangesNotifier notifier(*obj); MaNGOS::VisibleChangesNotifier notifier(*obj);
TypeContainerVisitor<MaNGOS::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier); TypeContainerVisitor<MaNGOS::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier);
CellLock<GridReadGuard> cell_lock(cell, cellpair); cell.Visit(cellpair, player_notifier, *this, *obj, GetVisibilityDistance());
cell_lock->Visit(cell_lock, player_notifier, *this, *obj, GetVisibilityDistance());
} }
void Map::UpdatePlayerVisibility( Player* player, Cell cell, CellPair cellpair ) void Map::UpdatePlayerVisibility( Player* player, Cell cell, CellPair cellpair )
@ -2020,8 +2013,7 @@ void Map::UpdatePlayerVisibility( Player* player, Cell cell, CellPair cellpair )
MaNGOS::PlayerNotifier pl_notifier(*player); MaNGOS::PlayerNotifier pl_notifier(*player);
TypeContainerVisitor<MaNGOS::PlayerNotifier, WorldTypeMapContainer > player_notifier(pl_notifier); TypeContainerVisitor<MaNGOS::PlayerNotifier, WorldTypeMapContainer > player_notifier(pl_notifier);
CellLock<ReadGuard> cell_lock(cell, cellpair); cell.Visit(cellpair, player_notifier, *this, *player, GetVisibilityDistance());
cell_lock->Visit(cell_lock, player_notifier, *this, *player, GetVisibilityDistance());
} }
void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpair ) void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpair )
@ -2032,9 +2024,8 @@ void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpa
cell.SetNoCreate(); cell.SetNoCreate();
TypeContainerVisitor<MaNGOS::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier); TypeContainerVisitor<MaNGOS::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);
TypeContainerVisitor<MaNGOS::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier); TypeContainerVisitor<MaNGOS::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier);
CellLock<GridReadGuard> cell_lock(cell, cellpair); cell.Visit(cellpair, world_notifier, *this, *player, GetVisibilityDistance());
cell_lock->Visit(cell_lock, world_notifier, *this, *player, GetVisibilityDistance()); cell.Visit(cellpair, grid_notifier, *this, *player, GetVisibilityDistance());
cell_lock->Visit(cell_lock, grid_notifier, *this, *player, GetVisibilityDistance());
// send data // send data
notifier.Notify(); notifier.Notify();
@ -2042,20 +2033,18 @@ void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpa
void Map::PlayerRelocationNotify( Player* player, Cell cell, CellPair cellpair ) void Map::PlayerRelocationNotify( Player* player, Cell cell, CellPair cellpair )
{ {
CellLock<ReadGuard> cell_lock(cell, cellpair);
MaNGOS::PlayerRelocationNotifier relocationNotifier(*player); MaNGOS::PlayerRelocationNotifier relocationNotifier(*player);
cell.data.Part.reserved = ALL_DISTRICT; cell.data.Part.reserved = ALL_DISTRICT;
TypeContainerVisitor<MaNGOS::PlayerRelocationNotifier, GridTypeMapContainer > p2grid_relocation(relocationNotifier); TypeContainerVisitor<MaNGOS::PlayerRelocationNotifier, GridTypeMapContainer > p2grid_relocation(relocationNotifier);
TypeContainerVisitor<MaNGOS::PlayerRelocationNotifier, WorldTypeMapContainer > p2world_relocation(relocationNotifier); TypeContainerVisitor<MaNGOS::PlayerRelocationNotifier, WorldTypeMapContainer > p2world_relocation(relocationNotifier);
cell_lock->Visit(cell_lock, p2grid_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS); cell.Visit(cellpair, p2grid_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS);
cell_lock->Visit(cell_lock, p2world_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS); cell.Visit(cellpair, p2world_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS);
} }
void Map::CreatureRelocationNotify(Creature *creature, Cell cell, CellPair cellpair) void Map::CreatureRelocationNotify(Creature *creature, Cell cell, CellPair cellpair)
{ {
CellLock<ReadGuard> cell_lock(cell, cellpair);
MaNGOS::CreatureRelocationNotifier relocationNotifier(*creature); MaNGOS::CreatureRelocationNotifier relocationNotifier(*creature);
cell.data.Part.reserved = ALL_DISTRICT; cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate(); // not trigger load unloaded grids at notifier call cell.SetNoCreate(); // not trigger load unloaded grids at notifier call
@ -2063,8 +2052,8 @@ void Map::CreatureRelocationNotify(Creature *creature, Cell cell, CellPair cellp
TypeContainerVisitor<MaNGOS::CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocationNotifier); TypeContainerVisitor<MaNGOS::CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocationNotifier);
TypeContainerVisitor<MaNGOS::CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocationNotifier); TypeContainerVisitor<MaNGOS::CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocationNotifier);
cell_lock->Visit(cell_lock, c2world_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS); cell.Visit(cellpair, c2world_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS);
cell_lock->Visit(cell_lock, c2grid_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS); cell.Visit(cellpair, c2grid_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS);
} }
void Map::SendInitSelf( Player * player ) void Map::SendInitSelf( Player * player )
@ -3123,8 +3112,7 @@ void Map::ScriptsProcess()
MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(summoner, go,go_check); MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(summoner, go,go_check);
TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker); TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, object_checker, *summoner->GetMap());
cell_lock->Visit(cell_lock, object_checker, *summoner->GetMap());
if ( !go ) if ( !go )
{ {
@ -3183,8 +3171,7 @@ void Map::ScriptsProcess()
MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(caster,door,go_check); MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(caster,door,go_check);
TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker); TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, object_checker, *caster->GetMap());
cell_lock->Visit(cell_lock, object_checker, *caster->GetMap());
if (!door) if (!door)
{ {
@ -3239,8 +3226,7 @@ void Map::ScriptsProcess()
MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(caster,door,go_check); MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(caster,door,go_check);
TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker); TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, object_checker, *caster->GetMap());
cell_lock->Visit(cell_lock, object_checker, *caster->GetMap());
if ( !door ) if ( !door )
{ {

View file

@ -47,27 +47,6 @@ struct ScriptInfo;
struct ScriptAction; struct ScriptAction;
class BattleGround; class BattleGround;
typedef ACE_RW_Thread_Mutex GridRWLock;
template<class MUTEX, class LOCK_TYPE>
struct RGuard
{
RGuard(MUTEX &l) : i_lock(l.getReadLock()) {}
MaNGOS::GeneralLock<LOCK_TYPE> i_lock;
};
template<class MUTEX, class LOCK_TYPE>
struct WGuard
{
WGuard(MUTEX &l) : i_lock(l.getWriteLock()) {}
MaNGOS::GeneralLock<LOCK_TYPE> i_lock;
};
typedef RGuard<GridRWLock, ACE_Thread_Mutex> GridReadGuard;
typedef WGuard<GridRWLock, ACE_Thread_Mutex> GridWriteGuard;
typedef MaNGOS::SingleThreaded<GridRWLock>::Lock NullGuard;
//****************************************** //******************************************
// Map file format defines // Map file format defines
//****************************************** //******************************************
@ -280,7 +259,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
void PlayerRelocation(Player *, float x, float y, float z, float angl); void PlayerRelocation(Player *, float x, float y, float z, float angl);
void CreatureRelocation(Creature *creature, float x, float y, float z, float orientation); void CreatureRelocation(Creature *creature, float x, float y, float z, float orientation);
template<class LOCK_TYPE, class T, class CONTAINER> void Visit(const CellLock<LOCK_TYPE> &cell, TypeContainerVisitor<T, CONTAINER> &visitor); template<class T, class CONTAINER> void Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor);
bool IsRemovalGrid(float x, float y) const bool IsRemovalGrid(float x, float y) const
{ {
@ -523,9 +502,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
//InstanceMaps and BattleGroundMaps... //InstanceMaps and BattleGroundMaps...
Map* m_parentMap; Map* m_parentMap;
typedef GridReadGuard ReadGuard;
typedef GridWriteGuard WriteGuard;
NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
GridMap *GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; GridMap *GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells; std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
@ -638,19 +614,18 @@ Map::CalculateGridMask(const uint32 &y) const
} }
*/ */
template<class LOCK_TYPE, class T, class CONTAINER> template<class T, class CONTAINER>
inline void inline void
Map::Visit(const CellLock<LOCK_TYPE> &cell, TypeContainerVisitor<T, CONTAINER> &visitor) Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor)
{ {
const uint32 x = cell->GridX(); const uint32 x = cell.GridX();
const uint32 y = cell->GridY(); const uint32 y = cell.GridY();
const uint32 cell_x = cell->CellX(); const uint32 cell_x = cell.CellX();
const uint32 cell_y = cell->CellY(); const uint32 cell_y = cell.CellY();
if( !cell->NoCreate() || loaded(GridPair(x,y)) ) if( !cell.NoCreate() || loaded(GridPair(x,y)) )
{ {
EnsureGridLoaded(cell); EnsureGridLoaded(cell);
//LOCK_TYPE guard(i_info[x][y]->i_lock);
getNGrid(x, y)->Visit(cell_x, cell_y, visitor); getNGrid(x, y)->Visit(cell_x, cell_y, visitor);
} }
} }

View file

@ -1544,8 +1544,7 @@ void WorldObject::MonsterSay(int32 textId, uint32 language, uint64 TargetGuid)
MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build); MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build);
MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> > say_worker(this,sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),say_do); MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> > say_worker(this,sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),say_do);
TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker); TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY));
cell_lock->Visit(cell_lock, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY));
} }
void WorldObject::MonsterYell(int32 textId, uint32 language, uint64 TargetGuid) void WorldObject::MonsterYell(int32 textId, uint32 language, uint64 TargetGuid)
@ -1560,8 +1559,7 @@ void WorldObject::MonsterYell(int32 textId, uint32 language, uint64 TargetGuid)
MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build); MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build);
MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> > say_worker(this,sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL),say_do); MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> > say_worker(this,sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL),say_do);
TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker); TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL));
cell_lock->Visit(cell_lock, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL));
} }
void WorldObject::MonsterYellToZone(int32 textId, uint32 language, uint64 TargetGuid) void WorldObject::MonsterYellToZone(int32 textId, uint32 language, uint64 TargetGuid)
@ -1589,8 +1587,7 @@ void WorldObject::MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossE
MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build); MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build);
MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> > say_worker(this,sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),say_do); MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> > say_worker(this,sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),say_do);
TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker); TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> >, WorldTypeMapContainer > message(say_worker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(IsBossEmote ? CONFIG_LISTEN_RANGE_YELL : CONFIG_LISTEN_RANGE_TEXTEMOTE));
cell_lock->Visit(cell_lock, message, *GetMap(), *this, sWorld.getConfig(IsBossEmote ? CONFIG_LISTEN_RANGE_YELL : CONFIG_LISTEN_RANGE_TEXTEMOTE));
} }
void WorldObject::MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisper) void WorldObject::MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisper)
@ -1829,9 +1826,8 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
TypeContainerVisitor<MaNGOS::WorldObjectWorker<MaNGOS::NearUsedPosDo>, GridTypeMapContainer > grid_obj_worker(worker); TypeContainerVisitor<MaNGOS::WorldObjectWorker<MaNGOS::NearUsedPosDo>, GridTypeMapContainer > grid_obj_worker(worker);
TypeContainerVisitor<MaNGOS::WorldObjectWorker<MaNGOS::NearUsedPosDo>, WorldTypeMapContainer > world_obj_worker(worker); TypeContainerVisitor<MaNGOS::WorldObjectWorker<MaNGOS::NearUsedPosDo>, WorldTypeMapContainer > world_obj_worker(worker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_obj_worker, *GetMap(), *this, distance2d);
cell_lock->Visit(cell_lock, grid_obj_worker, *GetMap(), *this, distance2d); cell.Visit(p, world_obj_worker, *GetMap(), *this, distance2d);
cell_lock->Visit(cell_lock, world_obj_worker, *GetMap(), *this, distance2d);
} }
// maybe can just place in primary position // maybe can just place in primary position
@ -1989,10 +1985,9 @@ void WorldObject::BuildUpdateData( UpdateDataMapType & update_players)
cell.SetNoCreate(); cell.SetNoCreate();
WorldObjectChangeAccumulator notifier(*this, update_players); WorldObjectChangeAccumulator notifier(*this, update_players);
TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier); TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
CellLock<GridReadGuard> cell_lock(cell, p);
Map* aMap = GetMap(); Map* aMap = GetMap();
//we must build packets for all visible players //we must build packets for all visible players
cell_lock->Visit(cell_lock, player_notifier, *aMap, *this, aMap->GetVisibilityDistance()); cell.Visit(p, player_notifier, *aMap, *this, aMap->GetVisibilityDistance());
ClearUpdateMask(false); ClearUpdateMask(false);
} }

View file

@ -17422,9 +17422,8 @@ void Player::HandleStealthedUnitsDetection()
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyStealthedCheck >, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyStealthedCheck >, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyStealthedCheck >, GridTypeMapContainer > grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyStealthedCheck >, GridTypeMapContainer > grid_unit_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, world_unit_searcher, *GetMap(), *this, MAX_PLAYER_STEALTH_DETECT_RANGE);
cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap(), *this, MAX_PLAYER_STEALTH_DETECT_RANGE); cell.Visit(p, grid_unit_searcher, *GetMap(), *this, MAX_PLAYER_STEALTH_DETECT_RANGE);
cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap(), *this, MAX_PLAYER_STEALTH_DETECT_RANGE);
WorldObject const* viewPoint = GetViewPoint(); WorldObject const* viewPoint = GetViewPoint();

View file

@ -457,13 +457,12 @@ WorldObject* Spell::FindCorpseUsing()
MaNGOS::WorldObjectSearcher<T> searcher(m_caster, result, u_check); MaNGOS::WorldObjectSearcher<T> searcher(m_caster, result, u_check);
TypeContainerVisitor<MaNGOS::WorldObjectSearcher<T>, GridTypeMapContainer > grid_searcher(searcher); TypeContainerVisitor<MaNGOS::WorldObjectSearcher<T>, GridTypeMapContainer > grid_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_searcher, *m_caster->GetMap(), *m_caster, max_range);
cell_lock->Visit(cell_lock, grid_searcher, *m_caster->GetMap(), *m_caster, max_range);
if (!result) if (!result)
{ {
TypeContainerVisitor<MaNGOS::WorldObjectSearcher<T>, WorldTypeMapContainer > world_searcher(searcher); TypeContainerVisitor<MaNGOS::WorldObjectSearcher<T>, WorldTypeMapContainer > world_searcher(searcher);
cell_lock->Visit(cell_lock, world_searcher, *m_caster->GetMap(), *m_caster, max_range); cell.Visit(p, world_searcher, *m_caster->GetMap(), *m_caster, max_range);
} }
return result; return result;
@ -1453,9 +1452,8 @@ void Spell::SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList& targetUni
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, world_unit_searcher, *m_caster->GetMap(), *m_caster, max_range);
cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); cell.Visit(p, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range);
cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range);
} }
if(tempTargetUnitMap.empty()) if(tempTargetUnitMap.empty())
@ -1523,9 +1521,8 @@ void Spell::SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList& targetUni
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, world_unit_searcher, *m_caster->GetMap(), *m_caster, max_range);
cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); cell.Visit(p, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range);
cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range);
} }
if(tempTargetUnitMap.empty()) if(tempTargetUnitMap.empty())
@ -1618,10 +1615,9 @@ void Spell::SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList& targetUni
MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(m_caster, tempTargetUnitMap, u_check); MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(m_caster, tempTargetUnitMap, u_check);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer> world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer> world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer> grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer> grid_unit_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range); cell.Visit(p, world_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range);
cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range); cell.Visit(p, grid_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range);
} }
if (tempTargetUnitMap.empty()) if (tempTargetUnitMap.empty())
break; break;
@ -4314,8 +4310,7 @@ SpellCastResult Spell::CheckCast(bool strict)
MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(m_caster, p_GameObject, go_check); MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(m_caster, p_GameObject, go_check);
TypeContainerVisitor<MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer > object_checker(checker); TypeContainerVisitor<MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer > object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, object_checker, *m_caster->GetMap(), *m_caster, range);
cell_lock->Visit(cell_lock, object_checker, *m_caster->GetMap(), *m_caster, range);
if (p_GameObject) if (p_GameObject)
{ {
@ -4353,8 +4348,7 @@ SpellCastResult Spell::CheckCast(bool strict)
TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher); TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_creature_searcher, *m_caster->GetMap(), *m_caster, range);
cell_lock->Visit(cell_lock, grid_creature_searcher, *m_caster->GetMap(), *m_caster, range);
if (p_Creature) if (p_Creature)
{ {
@ -5494,9 +5488,8 @@ SpellCastResult Spell::CheckItems()
MaNGOS::GameObjectSearcher<MaNGOS::GameObjectFocusCheck> checker(m_caster, ok, go_check); MaNGOS::GameObjectSearcher<MaNGOS::GameObjectFocusCheck> checker(m_caster, ok, go_check);
TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectFocusCheck>, GridTypeMapContainer > object_checker(checker); TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectFocusCheck>, GridTypeMapContainer > object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p);
Map& map = *m_caster->GetMap(); Map& map = *m_caster->GetMap();
cell_lock->Visit(cell_lock, object_checker, map, *m_caster, map.GetVisibilityDistance()); cell.Visit(p, object_checker, map, *m_caster, map.GetVisibilityDistance());
if(!ok) if(!ok)
return SPELL_FAILED_REQUIRES_SPELL_FOCUS; return SPELL_FAILED_REQUIRES_SPELL_FOCUS;
@ -6232,9 +6225,8 @@ void Spell::FillAreaTargets(UnitList &targetUnitMap, float x, float y, float rad
MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, targetUnitMap, radius, pushType, spellTargets); MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, targetUnitMap, radius, pushType, spellTargets);
TypeContainerVisitor<MaNGOS::SpellNotifierCreatureAndPlayer, WorldTypeMapContainer > world_notifier(notifier); TypeContainerVisitor<MaNGOS::SpellNotifierCreatureAndPlayer, WorldTypeMapContainer > world_notifier(notifier);
TypeContainerVisitor<MaNGOS::SpellNotifierCreatureAndPlayer, GridTypeMapContainer > grid_notifier(notifier); TypeContainerVisitor<MaNGOS::SpellNotifierCreatureAndPlayer, GridTypeMapContainer > grid_notifier(notifier);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, world_notifier, *m_caster->GetMap(), *m_caster, radius);
cell_lock->Visit(cell_lock, world_notifier, *m_caster->GetMap(), *m_caster, radius); cell.Visit(p, grid_notifier, *m_caster->GetMap(), *m_caster, radius);
cell_lock->Visit(cell_lock, grid_notifier, *m_caster->GetMap(), *m_caster, radius);
} }
void Spell::FillRaidOrPartyTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster) void Spell::FillRaidOrPartyTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster)

View file

@ -764,9 +764,8 @@ void AreaAura::Update(uint32 diff)
MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(caster,targets, u_check); MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(caster,targets, u_check);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, world_unit_searcher, *caster->GetMap(), *caster, m_radius);
cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap(), *caster, m_radius); cell.Visit(p, grid_unit_searcher, *caster->GetMap(), *caster, m_radius);
cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap(), *caster, m_radius);
break; break;
} }
case AREA_AURA_ENEMY: case AREA_AURA_ENEMY:
@ -780,9 +779,8 @@ void AreaAura::Update(uint32 diff)
MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(caster, targets, u_check); MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(caster, targets, u_check);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, world_unit_searcher, *caster->GetMap(), *caster, m_radius);
cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap(), *caster, m_radius); cell.Visit(p, grid_unit_searcher, *caster->GetMap(), *caster, m_radius);
cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap(), *caster, m_radius);
break; break;
} }
case AREA_AURA_OWNER: case AREA_AURA_OWNER:
@ -7459,10 +7457,8 @@ void Aura::PeriodicDummyTick()
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_object_checker, *m_target->GetMap(), *m_target, radius);
cell.Visit(p, world_object_checker, *m_target->GetMap(), *m_target, radius);
cell_lock->Visit(cell_lock, grid_object_checker, *m_target->GetMap(), *m_target, radius);
cell_lock->Visit(cell_lock, world_object_checker, *m_target->GetMap(), *m_target, radius);
} }
if(targets.empty()) if(targets.empty())

View file

@ -90,9 +90,8 @@ TotemAI::UpdateAI(const uint32 /*diff*/)
TypeContainerVisitor<MaNGOS::UnitLastSearcher<MaNGOS::NearestAttackableUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker); TypeContainerVisitor<MaNGOS::UnitLastSearcher<MaNGOS::NearestAttackableUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker);
TypeContainerVisitor<MaNGOS::UnitLastSearcher<MaNGOS::NearestAttackableUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker); TypeContainerVisitor<MaNGOS::UnitLastSearcher<MaNGOS::NearestAttackableUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, grid_object_checker, *m_creature->GetMap(), *m_creature, max_range);
cell_lock->Visit(cell_lock, grid_object_checker, *m_creature->GetMap(), *m_creature, max_range); cell.Visit(p, world_object_checker, *m_creature->GetMap(), *m_creature, max_range);
cell_lock->Visit(cell_lock, world_object_checker, *m_creature->GetMap(), *m_creature, max_range);
} }
// If have target // If have target

View file

@ -12562,17 +12562,14 @@ Unit* Unit::SelectNearbyTarget(Unit* except /*= NULL*/) const
std::list<Unit *> targets; std::list<Unit *> targets;
{ MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE);
MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE); MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck> searcher(this, targets, u_check);
MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck> searcher(this, targets, u_check);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p); cell.Visit(p, world_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE);
cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE); cell.Visit(p, grid_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE);
cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE);
}
// remove current target // remove current target
if(except) if(except)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9244" #define REVISION_NR "9245"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__